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.

How to set CPU CLK, MCLK on MSP430 using xdctools

Other Parts Discussed in Thread: MSP430F5438A, SYSBIOS

Hello everyone!

MSP430f5438A

sys/bios 2.00.02.36

xdctools 3.30.01.25

I am having issues to configure the system clock using cfg file. In cfg file I set the CPU clock frequency to 25MHz under plateform Settings but clock frequency doesn't change and it remains 8192000Hz. 

Can anyone please help me out. 

cfg file is also attached with the post5265.tiRTOS.cfg

Thanks!

Arslan

  • Hi Arslan,

    I see the setting for CPU frequency in your config file:

    BIOS.cpuFreq.lo = 25000000;

    How are you checking the effect of this change (that's allowing you to conclude that the clock speed is at 8192000 Hz)?

    Can you try using the following API in one of your Tasks?  And print out the values or look at them in the debugger?

    Void BIOS_getCpuFreq(Types_FreqHz *freq);

    Steve

  • Hi Steve

    Thank you for your reply!

    I tried this function Void BIOS_getCpuFreq(Types_FreqHz *freq); and it returns freq.lo = 25000000 and I measured the frequency on pin P11.1 using oscilloscope and it showed 8.192 MHz.

    Then I added this code before the BIOS_start(), which sets the MCLK and SMCLK to 25MHz and I also measured 25MHz on the pins using oscilloscope.

            PMM_setVCore(
                PMM_CORE_LEVEL_3
                );

        /* Set DCO FLL reference = REFO */
            UCS_clockSignalInit(
                UCS_FLLREF,
                UCS_REFOCLK_SELECT,
                UCS_CLOCK_DIVIDER_1
                );
        /* Set ACLK = REFO */
            UCS_clockSignalInit(
                UCS_ACLK,
                UCS_REFOCLK_SELECT,
                UCS_CLOCK_DIVIDER_1
                );

        /* Set Ratio and Desired MCLK Frequency  and initialize DCO */
            UCS_initFLLSettle(
                25000,
                762
                );

        /* Enable global oscillator fault flag */
            SFR_clearInterrupt(
                SFR_OSCILLATOR_FAULT_INTERRUPT
                );
            SFR_enableInterrupt(
                SFR_OSCILLATOR_FAULT_INTERRUPT
                );

        /* Enable global interrupt */
            __bis_SR_register(GIE);

    But now the issue is that it doesn't set the I2C bus frequency correctly. Here are the register values for the I2C bus and the bus is configured to operate at 400KHz but the bus frequency measured using oscilloscope is around 866KHz.

    UCB3CTLW0    0x0F80    USCI B3 Control Word Register 0 [Memory Mapped]    
    UCB3CTL0    0x0F    USCI B3 Control Register 0 [Memory Mapped]    
    UCB3CTL1    0x80    USCI B3 Control Register 1 [Memory Mapped]    
    UCB3BRW    0x0014    USCI B3 Baud Word Rate 0 [Memory Mapped]    
    UCB3BR0    0x14    USCI B3 Baud Rate 0 [Memory Mapped]    
    UCB3BR1    0x00    USCI B3 Baud Rate 1 [Memory Mapped]    
    UCB3STAT    0x00    USCI B3 Status Register [Memory Mapped]    
    UCB3RXBUF    0x08    USCI B3 Receive Buffer [Memory Mapped]    
    UCB3TXBUF    0x00    USCI B3 Transmit Buffer [Memory Mapped]    
    UCB3I2COA    0x0000    USCI B3 I2C Own Address [Memory Mapped]    
    UCB3I2CSA    0x0031    USCI B3 I2C Slave Address [Memory Mapped]    
    UCB3ICTL    0x0033    USCI B3 Interrupt Enable Register [Memory Mapped]    
    UCB3IE    0x33    USCI B3 Interrupt Enable Register [Memory Mapped]    
    UCB3IFG    0x00    USCI B3 Interrupt Flags Register [Memory Mapped]    
    UCB3IV    0x0000    USCI B3 Interrupt Vector Register [Memory Mapped]    


    Thanks!

    Arslan

  • Hi Arslan,

    My colleague gave me some info on this.  For the MSP430, your peripherals are running off of a different clock source.  You need to configure the clock frequency of the following module:

    ti.sysbios.family.msp430.ClockFreqs

    Please see the document page for 'ti.sysbios.family.msp430.ClockFreqs'.  It's in the BIOS API guide, found in your SYS/BIOS installation (e.g. I have it here: bios_6_40_01_15\docs\Bios_APIs.html).  It has a detailed explanation:

    Steve