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.

Reg: increasing ACLK frequency for MSP430F5529-EXP-board ...

Other Parts Discussed in Thread: MSP430F5529

Hi,

I have the TI MSP430F5529-EXP board. I have the following program which toggles P1.0 @ 32KHz appx. -

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= BIT0; // Set P1.0 to output direction (LED1)

for (;;)
{

P1OUT ^= BIT0; // Toggle P1.0 using exclusive-OR
}
}

The board has the LFXTCLK clock xtal as 32.768KHz (which pbbly goes to the ACLK) and the XT2CLK clock xtal as 4MHz. I've tried some programs (changing the UCSCTL regs etc.) but all of them still toggle P1.0 @ 32KHz. I guess this is because the ACLK is still being sourced by LFXTCLK.

I wanted to know if there is any way in s/w of increasing the speed of ACLK from 32KHz to 4 or 8 MHz so that P1.0 toggles faster (and the entire program in general speeds up)? How do I change the source of ACLK or speed it up?

Also, since ACLK is connected to a 32KHz xtal, if I change the xtal to something like 25MHz, will it help in speeding up the ACLK frequency in general?

Thanks for your time and help,

Regards,

Zubin Kumar.


 

  • zubin kumar said:

    The board has the LFXTCLK clock xtal as 32.768KHz (which pbbly goes to the ACLK) and the XT2CLK clock xtal as 4MHz. I've tried some programs (changing the UCSCTL regs etc.) but all of them still toggle P1.0 @ 32KHz. I guess this is because the ACLK is still being sourced by LFXTCLK.

    I wanted to know if there is any way in s/w of increasing the speed of ACLK from 32KHz to 4 or 8 MHz so that P1.0 toggles faster (and the entire program in general speeds up)? How do I change the source of ACLK or speed it up?

    Yes, it is possible to change the source to ACLK via software.  I would suggest you take a look at the MSP430x5xx Family User's Guide (SLAU208) available on the MSP430F5529 Product Folder in Chapter 5.  Figure 5-1 has a good illustration of the possible sources to ACLK, MCLK and SMCLK.

    In addition, there are C code examples on the MSP430F5529 Product Folder in the Software and Tools section which provide good examples to start from.

     

    zubin kumar said:

    Also, since ACLK is connected to a 32KHz xtal, if I change the xtal to something like 25MHz, will it help in speeding up the ACLK frequency in general?

    
    

    You don't need to go to that extreme to increase the frequency of ACLK.  The MSP430x5xx family of devices uses the UCS (Unified Clock System) which provides a lot of flexibility in the various sources of clocks for ACLK.  Again, refer to Figure 5-1 in the MSP430x5xx Family User's Guide (SLAU208) for details.

  • zubin kumar said:
    The board has the LFXTCLK clock xtal as 32.768KHz (which pbbly goes to the ACLK) and the XT2CLK clock xtal as 4MHz

    Indeed, teh default is that the XT1 LF crystal goes to ACLK, however, HF XT2 is not configured and off at this moment, and MCLK (the CPU) runs from DCO, which has a default speed of 1MHz on 5x devices.

    So the code is executed with 1Mhz (may start slower or faster until the FLL has adjusted the clock speed)

    I'm surprised the LED only flashes with 32kHz. Toggling BIT0 should take only 4 MCLK cycles, and the endless loop two more, so the speed should be 1MHz/12 (two loops per flash) = ~83kHz.

    Enabling the 4MHz crystal and swithcing MCLK to XT2 will speed up the MCU by factor 4. But iof you don't need a precise frequency, you can as well reprogram the FLL and the RSEL settings in the clock system, so the MSP runs with any frequency up to 23MHz without a crystal. Even if the DCO can deliver much more than 23MHz, you must not exceed 25MHz, and the way the DCO works, teh output frequency is only an average of two frequencies it modulates between - and the higher one must not exceed 25MHz, so the average is below. 23,4MHz is the worst-case safe frequency.

    With a 25MHz crystal there is no modulation and you can go for 25MHz.

    However, the CPU core runs from MCLK, which is totally independent of ACLK. ACLK is usually used for sourcing an RTC or some low-frequency, but high-precision timings, But the 32,768Hz crystal is also used for driving the FLL that adjusts the DCO, so you can stabilize the (otherwise not very precise) DCO to a multiple of 32768Hz. The crystal is way more precise than the internal REFO.

    The 'unified clock system' chapter of the 5x family users guide is the reference documentation for the MSP 5x families clock system.

  • Hey guys, thanks for the inputs. 

    I was able to increase the MClk speed of my micro to around 33 MHz. However, I have another question - 

    I want to toggle a GPIO (say P1.0) as close to 20MHz as possible. the code I use for toggling is - 

    while (1)  {

    P1OUT ^= BIT0;                          

    }

    One of the previous posts say that the while condition and the toggle statement will take around 12 to 15 cycles to execute so the max. toggle frequency I am looking at is 33/15 = around 2 MHz. 

    I know this is a limitation of the micro, but is there any other way of increasing the P1.0 toggle frequency to bring it upto 20 MHz? I know I can use the MClk set at 20MHz and bring it out on a pin, but I need to use a GPIO line because I also need to do some calculations on the toggle frequency etc.  Also, is 50MHz the max. MClk freq for the MSP430F5529?

    Do let me know ...

    Thanks ...

  • zubin kumar said:
    I was able to increase the MClk speed of my micro to around 33 MHz.

    That's definitely outside the specs. But I guess you have still the default /2 divider on the DCO (running MCLK from DCODIV, whic is the default), so you only have 16.5MHz which is in the valid range.

    zubin kumar said:
    is there any other way of increasing the P1.0 toggle frequency to bring it upto 20 MHz?

    No, not 20MHz. You can use a timer and clock it with 20MHz and set the CCR units in a way so that the pin is set/reset with every clock pulse, resulting in 10Mhz output frequency (12.5 max on 25MHz system clock). Then you can tune the frequency down from 25/2 to 25/3, /4 etc.
    But the only way to get 20MHz output on this MSP is directly outputting (S)MCLK.

    The MSP430F5173 has teo TImerD modules which have an internal clock multiplier and run with up to 256MHz timer clock speed. This would allow setting up their CCR for a frequency of 20MHz easily, including finer adjustments. E.g. 240Mhz timer clock-> /12 = 20MHz, /13=18.46MHz, /14 = 17.14MHz etc.

    However, all these timer tricks won't allow you full software control over the output pin. You can just program the output frequency, you cannot change it on every cycle.

    The MCU instruction that reads the ucrrent port state, alters it and writes it back requires 3 MCLK cycles at best, (if it is bit 0 to 3. Bit 4-7 take one cycle more)
    The highest frequency you can produce if a duty cycle of 25% is okay is MCLK/4, if the pin is one of the lower 4 pins of a port and the other port pins are don't care.

    loop:
    MOV #1,P1OUT
    MOV #0, P1OUT
    JMP loop

    Of course this does nothing else, just looping and switching the pin on and off. No calculations. No exit. No interrupts, just loop forever.

**Attention** This is a public forum