Tool/software: TI-RTOS
Hi,
I am using MSP432E401 launchpad.
I have configured UART2 and UART3 for sending and receiving data at 9600 baud
I am able to send data and could see it on connector pin using signal analyzer.
I have then looped back RX -- TX in my connector to loop the character sent back to rx.
Again, I could see my signal analyzer showing the plot.
Here, I have enabled the interrupt for receiving any data on my UART but it does not get trigger until I call UART_read();
Isn't the interrupt expected without even calling UART_read since I have enabled it?
Attached is the code, if I comment UART_read in function "testGsmUart" it does not callback my uartDataReadCallBack function.
Is there anything wrong in I configuring the UART?
Appreciate any pointers to resolve the problem.
#include <ti/drivers/UART.h> #include <ti/sysbios/knl/Queue.h> #include <Board.h> #include "GSMModule.h" static UART_Handle gsmUARTHandle; static void uartDataReadCallBack(UART_Handle handle, void *buf, size_t count); static void uartDataWriteCallBack(UART_Handle handle, void *buf, size_t count); static void processGsmResponse(); static void initGsmModule(); Queue_Handle rxDataQ; typedef struct gsmRxDataStruct{ Queue_Elem elem; char data; }gsmRxDataStruct; gsmRxDataStruct gsmRxData; /* * ======== GSM Module thread ======== * This thread processes all the request and response from the gsm module */ void *GsmModuleThread() { initGsmModule(); //sleep(2); while (1) { processGsmResponse(); } } void initGsmModule() { rxDataQ = Queue_create(NULL, NULL); UART_init(); // Initialize UART parameters UART_Params params; UART_Params_init(¶ms); params.baudRate = 9600; //params.readMode = UART_MODE_BLOCKING; //params.writeMode = UART_MODE_BLOCKING; params.readMode = UART_MODE_CALLBACK; params.writeMode = UART_MODE_CALLBACK; params.readTimeout = UART_WAIT_FOREVER; params.writeTimeout = UART_WAIT_FOREVER; params.readEcho = UART_ECHO_OFF; params.readCallback = uartDataReadCallBack; params.writeCallback = uartDataWriteCallBack; // Open the UART gsmUARTHandle = UART_open(Board_UART2, ¶ms); //gsmUARTHandle = UART_open(Board_UART3, ¶ms); if(gsmUARTHandle == NULL) { //Failed to open UART while(1); } } void processGsmResponse() { gsmRxDataStruct *d; if(!Queue_empty(rxDataQ)) { d = Queue_get(rxDataQ); if(d) { char c = d->data; } } } void testGsmUart() { char buffer = 'A'; UART_write(gsmUARTHandle, &buffer, 1); #if 1 char* rd; /* SP_DEBUG: Needs this line else data receive interrupt is not triggering */ UART_read(gsmUARTHandle, rd, 1); #endif } void uartDataReadCallBack(UART_Handle handle, void *buf, size_t count) { char *rxBuf = (char*) buf; gsmRxDataStruct rData; rData.data = rxBuf[0]; Queue_put(rxDataQ, &(rData.elem)); } void uartDataWriteCallBack(UART_Handle handle, void *buf, size_t count) { }
My UART configuration as follows
/* UART configuration structure */ const UARTMSP432E4_HWAttrs uartMSP432E4HWAttrs[MSP_EXP432E401Y_UARTCOUNT] = { { .baseAddr = UART3_BASE, .intNum = INT_UART3, .intPriority = (~0), .flowControl = UARTMSP432E4_FLOWCTRL_NONE, .ringBufPtr = uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART3], .ringBufSize = sizeof(uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART3]), .rxPin = UARTMSP432E4_PA4_U3RX, .txPin = UARTMSP432E4_PA5_U3TX, .ctsPin = UARTMSP432E4_PIN_UNASSIGNED, .rtsPin = UARTMSP432E4_PIN_UNASSIGNED, .errorFxn = NULL }, { .baseAddr = UART2_BASE, .intNum = INT_UART2, .intPriority = (~0), .flowControl = UARTMSP432E4_FLOWCTRL_NONE, .ringBufPtr = uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART2], .ringBufSize = sizeof(uartMSP432E4RingBuffer[MSP_EXP432E401Y_UART2]), .rxPin = UARTMSP432E4_PD4_U2RX, .txPin = UARTMSP432E4_PD5_U2TX, .ctsPin = UARTMSP432E4_PIN_UNASSIGNED, .rtsPin = UARTMSP432E4_PIN_UNASSIGNED, .errorFxn = NULL } }; const UART_Config UART_config[MSP_EXP432E401Y_UARTCOUNT] = { { .fxnTablePtr = &UARTMSP432E4_fxnTable, .object = &uartMSP432E4Objects[MSP_EXP432E401Y_UART3], .hwAttrs = &uartMSP432E4HWAttrs[MSP_EXP432E401Y_UART3] }, { .fxnTablePtr = &UARTMSP432E4_fxnTable, .object = &uartMSP432E4Objects[MSP_EXP432E401Y_UART2], .hwAttrs = &uartMSP432E4HWAttrs[MSP_EXP432E401Y_UART2] } }; const uint_least8_t UART_count = MSP_EXP432E401Y_UARTCOUNT;