This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS: MSP430F5529 trying to generate a 5 MHz square wave to serve as a clock pulse for other equipment

Other Parts Discussed in Thread: MSP430F5529

Tool/software: Code Composer Studio

Hello,

I'm not very experience with programming micro-controllers and this is the first time I have worked with the MSP430F5529.

I need to produce a square wave with a frequency of 5MHz to serve as a clock pulse for another piece of equipment that I am working with. I have set the MCLK to 25 MHz and I have raised the voltage to accommodate this clock frequency. However, when I run the following code

for(;;) {

        P2OUT ^= 0x01;


    }

P2.0 is only toggled at a frequency of 1.61 MHz. Is there anyway to iterate through this loop faster? Presumably after that speed is increased, I can set a delay using __delay_cylces() to achieve the precise frequency.

Please help me if possible. I would appreciate any advice or suggestions.

  • Hello William,

    As well as raising the VCC voltage, did you change VCORE to the appropriate setting?

    There are a few factors that can influence the speed of GPIO toggling in this manner. For example, it takes about a microsecond for the device to change the output on the GPIO register. Also, you are suing several clock cycles going around the infinite loop before you toggle.  Delays can further be introduced if you have interrupts going on as you are manually changing the GPIO output.  this infinite loop also ties up your whole system.

    Some better options follow as they do not need CPU intervention to be accomplished:

    • Set SMCLK to your desired output frequency (MCLCK may need to be a multiple to make this work) and output SMLCK on its dedicated pin.
    • Use a Timer peripheral to auto-toggle a timer output at your desired output frequency. You will still need to make either MCLK or SMLCK a multiple of what you want to output, the Timer gives you further division options as well. For example, if you runt he timer at 10MHz, use it in UP mode Toggle output mode, you would get a 5MHz output. 

**Attention** This is a public forum