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/MSP430F6779: TIRTOS Multiple UART initialization eror

Part Number: MSP430F6779


Tool/software: TI-RTOS

Hi,

I'm trying to use 2 UARTs on the MSP430 with the TI-RTOS UART driver. The UART_open() for both UART initialize successfully. But when i call UART_write() for second it's resetting the controller.

Initialization code and enumerators are listed below

#define Board_UART0                 MSP_EM430F67791_UARTA0

#define Board_UART1                 MSP_EM430F67791_UARTA1
 
#define Board_UART2                 MSP_EM430F67791_UARTA2

typedef enum MSP_EM430F67791_UARTName {
    MSP_EM430F67791_UARTA0 = 0,
    MSP_EM430F67791_UARTA1 ,
    MSP_EM430F67791_UARTA2 ,

    MSP_EM430F67791_UARTCOUNT
} MSP_EM430F67791_UARTName;

const UARTEUSCIA_BaudrateConfig uartEUSCIABaudrates[] = {
    /* {baudrate, input clock, prescalar, UCBRFx, UCBRSx, oversampling} */
    {
        .outputBaudrate = 9600,
        .inputClockFreq = 16777216,
        .prescalar = 109,
        .hwRegUCBRFx = 3,
        .hwRegUCBRSx = 181,
        .oversampling = 1
    },
     {9600, 16777216, 109, 3, 181, 1},
    {2400, 16777216, 436, 14, 170, 1},
    {4800,   16777216,  218, 7, 68, 1},
    {19200,   16777216,  54, 9, 238, 1},
    {38400,   16777216,  27, 4, 251, 1},
    {57600,   16777216,  18, 3, 68, 1},
    {115200,   16777216,  9, 1, 181, 1},
};

const UARTEUSCIA_HWAttrs uartEUSCIAHWAttrs[MSP_EM430F67791_UARTCOUNT] = {
    {
        .baseAddr = EUSCI_A0_BASE,
        .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
        .bitOrder = EUSCI_A_UART_LSB_FIRST,
        .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
        .baudrateLUT = uartEUSCIABaudrates
    },
    
        {
        .baseAddr = EUSCI_A1_BASE,
        .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
        .bitOrder = EUSCI_A_UART_LSB_FIRST,
        .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
        .baudrateLUT = uartEUSCIABaudrates
    },
    
        {
        .baseAddr = EUSCI_A2_BASE,
        .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
        .bitOrder = EUSCI_A_UART_LSB_FIRST,
        .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
        .baudrateLUT = uartEUSCIABaudrates
    },
    
 
};



const UART_Config UART_config[] = {
    {
        .fxnTablePtr = &UARTEUSCIA_fxnTable,
        .object = &uartEUSCIAObjects[0],
        .hwAttrs = &uartEUSCIAHWAttrs[0]
    },
    
       {
        .fxnTablePtr = &UARTEUSCIA_fxnTable,
        .object = &uartEUSCIAObjects[1],
        .hwAttrs = &uartEUSCIAHWAttrs[1]
    },
    
       {
        .fxnTablePtr = &UARTEUSCIA_fxnTable,
        .object = &uartEUSCIAObjects[2],
        .hwAttrs = &uartEUSCIAHWAttrs[2]
    },
    
    {NULL, NULL, NULL}
};

/*
 *  ======== MSP_EM430F67791_initUART ========
 */
void MSP_EM430F67791_initUART(void)
{
 
    /* P3.1,0 = EUSCI_A0 TXD/RXD */
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3,
         GPIO_PIN0);
   GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P3,
        GPIO_PIN1  );

   /* P3.5,4 = EUSCI_A0 TXD/RXD */
       GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3,
         GPIO_PIN4);
   GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P3,
        GPIO_PIN5  );
    
   /* P3.7,6 = EUSCI_A0 TXD/RXD */
   GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3,
        GPIO_PIN6 | GPIO_PIN7);
    
    /* Initialize the UART driver */
    UART_init();


}

// Inside Task

    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 = 9600;

    hdlc_uart1_handle = UART_open(Board_UART1, &uartParams);

    if (hdlc_uart1_handle == NULL) {
        System_abort("Error opening the UART");
    }
    
        hdlc_uart0_handle = UART_open(Board_UART0, &uartParams);

    if (hdlc_uart0_handle == NULL) {
        System_abort("Error opening the UART");
    }

UART_write(hdlc_uart0_handle, echoPrompt, sizeof(echoPrompt));  // Sucess

UART_write(hdlc_uart1_handle, echoPrompt, sizeof(echoPrompt)); // Fails and reset the controller

It was also noted that if I change theenum  oder in MSP_EM430F67791_UARTName like

typedef enum MSP_EM430F67791_UARTName {
    MSP_EM430F67791_UARTA2 = 0,
    MSP_EM430F67791_UARTA1 ,
    MSP_EM430F67791_UARTA0 ,

    MSP_EM430F67791_UARTCOUNT
} MSP_EM430F67791_UARTName;

then even the UART0 fails(causes reset condition)

Iam using tirtos_msp43x_2_20_00_06 and IAR 7.11.2.

Please help.

Thanks in advance.

Sreekanth MK

  • Hi Sreekanth,

    A few questions to hopefully narrow the issue down:

    • Is the second UART opened correctly? Do you see the error message thrown?
    • If you try to write to the first UART a second time (without writing to the second UART) do you still see the reset issue?

    Regards,

    Nathan

  • Hi Nathan,

    1) Yes, The second uart is opened correctly, while opening the handle is returning valid addresses.(hdlc_uart1_handle = UART_config (0xD21E) and hdlc_uart0_handle =0xD224 (UART_config + 6))  so its not throwing any errors.

    2) There is no issue with first uart in the MSP_EM430F67791_UARTName. Like if MSP_EM430F67791_UARTA0 is the first entry(0) , there wont be any issues in writing data to  first uart multiple times.  if i change MSP_EM430F67791_UARTA1 as the first entry(0) there wont be any issues with second uart, at the same time writing to first uart causes a reset condition.

    Regards

    Sreekanth MK

  • Hi, Nathan,

    in the rtos cfg file, i have added the isr for uart1(53), now the reset issue is fixed but when i call UART_write() for the second uart its hanging the system.

    CFG file static hwi instance are listed below

    var hwiParams = new halHwi.Params();

    hwiParams.arg = 0;
    halHwi.create(59, "&UARTEUSCIA_hwiIntFxn", hwiParams);

    var hwi4Params = new halHwi.Params();

    hwiParams.arg = 0;
    halHwi.create(53, "&UARTEUSCIA_hwiIntFxn", hwi4Params);

    please help.

    Thanks in advance

    Sreekanth MK

  • Hi,
    issue was with CFG file static hwi instance

    var hwiParams = new halHwi.Params();

    hwiParams.arg = 0;
    halHwi.create(59, "&UARTEUSCIA_hwiIntFxn", hwiParams);

    var hwi4Params = new halHwi.Params();

    hwi4Params.arg = 0; // error I have to change the argument to 1 hwi4Params.arg = 1; for my second instance
    halHwi.create(53, "&UARTEUSCIA_hwiIntFxn", hwi4Params);

    Regards
    Sreekanth MK

**Attention** This is a public forum