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.

TI-RTOS bug(?) in setting proper baud rate in UART_open() ???

Other Parts Discussed in Thread: MSP430F5259

Hi, 

I had a great deal of pain setting up UART baud rate.

After deep diving into TI-RTOS code I think there I found a bug - 

UART_open() is eventually calling UARTUSCIA_open() [uartuscia,c] which in turn calls ClockFreqs_getFrequency() (line 350)

HOWEVER, ClockFreqs_getFrequency() does always return 8192000 regardless of the actual SMCLK !!!

I also verified it by putting the 'true' UARTUSCIA_BaudrateConfig values that relate to SMCLK=1024KHz into a line with 8192KHz  'prefix'. see below.

This time it worked perfectly.

/*
 * The baudrate dividers were determined by using the MSP430 baudrate
 * calculator
 * http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430BaudRateConverter/index.html
 */
const UARTUSCIA_BaudrateConfig uartUSCIABaudrates[] = {
    /* baudrate, input clock, prescalar, UCBRFx, UCBRSx, oversampling */
    {115200, 8192000, 8,  0, 7, 0},	// <<<< Original 8192KHz vals are: 4,  7, 0, 1},
	{115200, 1024000, 8,  0, 7, 0},	/* Actual SMCLK = 1.024MHz*/
    {9600,   8192000,53,  5, 0, 1},
	{9600,   1024000, 6,  9, 2, 1}, /* Actual SMCLK = 1.024MHz*/
    {9600,   32768,   3,   0, 3, 0},
};


I'll appreciate if someone at TI could check this out and issue a patch ASAP if proven right.

Thanks

  • Hi EL55,

    Which version of TI-RTOS are you using?

    Is your application setting the frequency values for ACLK and SMCLK via the ClockFreqs module?

    Note that these values must be set in the application.  The ClockFreqs API is then just used to get the frequency that was set (in the configuration) during run time.

    Please refer to the ClockFreqs  module in the SYS/BIOS API guide (under ti/sys/bios/family/msp430/ClockFreqs)

    Steve

  • Hi,

    I'm using 2.12 which I understand is the latest.

    The platform is MSP430F5259

    My application does the following:

    CS_initClockSignal(UCS_FLLREF, UCS_REFOCLK_SELECT, UCS_CLOCK_DIVIDER_1);
    
    UCS_initFLLSettle(MCLK_DESIRED_FREQUENCY_IN_KHZ, MCLK_FLLREF_RATIO);  // params are 8192KHz, 250 (div) [since by the default sub 16MHz MCLK is driven by DCOCLKDIV which is half of teh DCO]
    // Leave MCLK/SMCLK in default values
    
    UCS_turnOnSMCLK(); System_printf("MCLK=%ld [Hz]\n",UCS_getMCLK()); // Prints 8192000 System_printf("SMCLK=%ld [Hz]\n",UCS_getSMCLK()); // Prints 8192000 System_flush();


    So, If I understand correctly, ClockFreqs module need to be included... but than, since its static I can not set the frequency in run time. right ???

  • Correct.  The ClockFreqs module only supports getting the frequency at run time.

    Steve