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