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.

RTOS/MSP430F5529: TI-RTOS : UART Baud set 115200 can’t work when my smclk is 24Mhz

Part Number: MSP430F5529
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

hi everyone,

ccsv7 for msp430;

TI-RTOS for msp43X  2.20.0.06

I run an example of TI-RTOS UART in the MSP-EXP5529LP development board, and I configure the SMCLK and MCLK clocks to 24MHZ in the Board_initGeneral() function (4M XT2 doubling via DCO)

#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTUSCIA.h>

UARTUSCIA_Object uartUSCIAObjects[MSP_EXP430F5529LP_UARTCOUNT];

const UARTUSCIA_BaudrateConfig uartUSCIABaudrates[] = {
    /* {baudrate, input clock, prescalar, UCBRFx, UCBRSx, oversampling} */
    {   //my add
        .outputBaudrate = 115200,
        .inputClockFreq = 24000000,
        .prescalar = 13,
        .hwRegUCBRFx = 0,
        .hwRegUCBRSx = 0,
        .oversampling = 1
    },
    {
        .outputBaudrate = 115200,
        .inputClockFreq = 8192000,
        .prescalar = 4,
        .hwRegUCBRFx = 7,
        .hwRegUCBRSx = 0,
        .oversampling = 1
    },
    {9600,    32768,            3,         0,      3,      0},
};


const UARTUSCIA_HWAttrs uartUSCIAHWAttrs[MSP_EXP430F5529LP_UARTCOUNT] = {
    {
        .baseAddr       = USCI_A1_BASE,
        .clockSource    = USCI_A_UART_CLOCKSOURCE_MCLK, //#####MCLK = 24000000#####

.bitOrder = USCI_A_UART_LSB_FIRST, .numBaudrateEntries = sizeof(uartUSCIABaudrates)/sizeof(UARTUSCIA_BaudrateConfig), .baudrateLUT = uartUSCIABaudrates }, }; const UART_Config UART_config[] = { { .fxnTablePtr = &UARTUSCIA_fxnTable, .object = &uartUSCIAObjects[0], .hwAttrs = &uartUSCIAHWAttrs[0] }, {NULL, NULL, NULL} };
void uartFxn(UArg arg0, UArg arg1)
{
    UART_Handle uart;
    UART_Params uartParams;
    const char echoPrompt[] = "\fEchoing characters:\r\n";
    // Create a UART with data processing off.
    UART_Params_init(&uartParams);
    uartParams.writeDataMode    = UART_DATA_BINARY;
    uartParams.readDataMode     = UART_DATA_BINARY;
    uartParams.readReturnMode   = UART_RETURN_FULL;
    uartParams.readEcho         = UART_ECHO_OFF;
    uartParams.baudRate         = 115200;
    uart = UART_open(Board_UART0, &uartParams);
    if (uart == NULL) {
        System_abort("Error opening the UART");
    }

    UART_write(uart, echoPrompt, sizeof(echoPrompt));

    /* Loop forever echoing */
    while (1) {
        UART_write(uart, echoPrompt, sizeof(echoPrompt));
        Task_sleep((unsigned int)arg0);
    }

}

int main(void)
{
    /* Call board init functions */
    Board_initGeneral();
    Board_initGPIO();
    Board_initUART();
	
    Task_Params taskParams;
    Task_Params_init(&taskParams);
    taskParams.arg0         = 1000;
    taskParams.stackSize    = TASKSTACKSIZE;
    taskParams.stack        = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)uartFxn, &taskParams, NULL);
	
    /* Start BIOS */
    BIOS_start();

    return (0);	
}

  

when I remove the const UARTUSCIA_BaudrateConfig uartUSCIABaudrates []

    {
        .outputBaudrate = 115200,
        .inputClockFreq = 8192000,
        .prescalar = 4,
        .hwRegUCBRFx = 7,
        .hwRegUCBRSx = 0,
        .oversampling = 1
    },

and I find UART_OPEN()  return ERR.  I don't know why?   

 

 Similarly, when I configure MCLK to 24MHZ, I must configure my cpufrq to be a multiple of 32768 in the .CFG file to work at the UART 9600 baud rate.  Someone explains why?



/* ================ Kernel (SYS/BIOS) configuration ================ */
var BIOS = xdc.useModule('ti.sysbios.BIOS');

BIOS.assertsEnabled = false;

BIOS.heapSize = 512;

BIOS.includeXdcRuntime = false;

BIOS.libType = BIOS.LibType_Custom;

BIOS.runtimeCreatesEnabled = true;

BIOS.logsEnabled = false;

BIOS.cpuFreq.hi = 0;
BIOS.cpuFreq.lo = 23986176;//32768*732

thank you!

  • I don't know why the default SMCLK clock for TI-RTOS system is 8192000, and the baud rates of 115200 and 9600 are normal under the default clock.
  • Hello XC.MO,

    Its seems you are using USCIA1, which is the back-channel UART for the MSP430F5529LP. The back-channel UART on the Launchpad is limited to 9600 baud due to the eZ-FET Lite HW on the Launchpad (the debugger at the top of the board). If you want to use baud rates higher than 9600 baud, then you will need to use the other UART on board the Launchpad with a separate path to the PC if that is your intent.
  • Hi JH
    Thank you for your reply. you say said it was due to the eZ-FET Lite HW limited to 9600 baud, I don't think so. I do three tests.

    1. When TI-RTOS uses the default clock SMCLK (8192000) , the 115200 baud had exists the UARTUSCIA_BaudrateConfig[] list by default and works ok. In addition. 115200 baud is ok when I use drivelib API to configure the UART in TI-RTOS.
    --------------------------------------------------

    //default table list
    * const UARTUSCIA_BaudrateConfig uartUSCIABaudrates[] = {
    * // Baudrate, input clock (Hz), Prescalar, UCBRFx, UCBRSx, oversampling
    * {
    * .outputBaudrate = 115200,
    * .inputClockFreq = 8192000,
    * .prescalar = 4,
    * .hwRegUCBRFx = 7,
    * .hwRegUCBRSx = 0,
    * .oversampling = 1
    * },
    * {9600, 8192000, 53, 5, 0, 1},
    * {9600, 32768, 3, 0, 3, 0},
    * };


    --------------------------------------------------
    2. I modified UART to use USCIA0, and I used my own configuration clock SMCLK( 240000000), and I found that CRT was still printing garbled code.
    --------------------------------------------------

    //my
    const UARTUSCIA_BaudrateConfig uartUSCIABaudrates[] = {
    /* {baudrate, input clock, prescalar, UCBRFx, UCBRSx, oversampling} */
    {
    .outputBaudrate = 115200,
    .inputClockFreq = 24000000,
    .prescalar = 13,
    .hwRegUCBRFx = 0,
    .hwRegUCBRSx = 0,
    .oversampling = 1
    },
    {
    .outputBaudrate = 115200,
    .inputClockFreq = 8192000,
    .prescalar = 4,
    .hwRegUCBRFx = 7,
    .hwRegUCBRSx = 0,
    .oversampling = 1
    },
    {9600, 32768, 3, 0, 3, 0},
    };
    
    
    const UARTUSCIA_HWAttrs uartUSCIAHWAttrs[MSP_EXP430F5529LP_UARTCOUNT] = {
    {
    .baseAddr = USCI_A0_BASE,
    .clockSource = USCI_A_UART_CLOCKSOURCE_SMCLK,//24M
    .bitOrder = USCI_A_UART_LSB_FIRST,
    .numBaudrateEntries = sizeof(uartUSCIABaudrates)/sizeof(UARTUSCIA_BaudrateConfig),
    .baudrateLUT = uartUSCIABaudrates
    },
    };


    -----------------------------------------------
    3.I tried to modify cfg to close the default DCOs and found that UART_OPEN() always returns ERR. I don't know if it's because of TI-RTOS's UART module, and I don't know how to get ti-rios uart_module src.
    -----------------------------------------------

    //my cfg
    var Boot = xdc.useModule('ti.catalog.msp430.init.Boot');
    Boot.configureDCO = false; //disable 8192000hz DCO
    
    ------
    
    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    BIOS.cpuFreq.hi = 0;
    BIOS.cpuFreq.lo = 24000000;//23986176;//32768*732


    -----------------------------------------------

    Regards,

    mo

  • Mo,

    Regardless of issues with TI-RTOS, your baud rate will be limited to 9600 baud on USCI A1 on the launchpad. So I suggest moving your tests tot he other UART in order to get rid of that issue as well.

    For the TI-RTOS questions, I am looping in our TI-RTOS expert.

    Also, when posting code, please remember to use the code editor so its easier to read. I've modified your previous post to reflect that.
  • We've opened a Jira ticket to look at this for future TI-RTOS for MSP430 releases. For now, I'd follow Jace's guidance.

    Todd
  • hi JH
    Thank you for your guidance. I've found the problem. I used this community for the first time, so I ignore some of the details of submitting the problem. Now I'll talk about how I can solve the problem.

    1.I find the UART_open() will call UARTUSCIA_open(UART_Handle handle, UART_Params *params) as follows
    ------------------------------------------------
    UART_Handle UARTUSCIA_open(UART_Handle handle, UART_Params *params)
    {
    ......
    /* Get the SPI clock input frequency */
    switch (hwAttrs->clockSource) {
    case USCI_A_UART_CLOCKSOURCE_ACLK:
    clockFreq = ClockFreqs_getFrequency(ClockFreqs_Clock_ACLK);
    Log_print1(Diags_USER1, "ClockFreqs_getFrequency ACLK: %d", clockFreq);
    break;

    case USCI_A_UART_CLOCKSOURCE_SMCLK:
    clockFreq = ClockFreqs_getFrequency(ClockFreqs_Clock_SMCLK);

    ........
    ------------------------------------------------

    and the problem is the clock frequency ,I find ClockFreqs_getFrequency(ClockFreqs_Clock_SMCLK) always return 819200, so when we use other baud with oscillator frequency ,we much modifed the ClockFreqs.SMCLK and ClockFreqs.ACLK in .cfg file or use api to dynamically modify before UART_open(), and my modified as follows
    ------------------------------------------------
    var ClockFreqs = xdc.useModule('ti.sysbios.family.msp430.ClockFreqs');
    ClockFreqs.ACLK = 32768;
    ClockFreqs.SMCLK = 24000000;

    ------------------------------------------------


    Thank you all. I'm sorry for my expression.

**Attention** This is a public forum