MCU: TM4C1294NCPDT
TI-RTOS: v2.01.00.03
CCS: v6.0.1.0040
-
Hello,
I am using the UART driver integrated with TI-RTOS. I have connected a GPS mouse (outputting text data in its UART port) to UART1 of Tiva C MCU. I have a task, the code of which is provided below. The GPS will send a burst of some 100 to 400 bytes of UART data once every second (the exact number of bytes depends on the GPS info). When the GPS mouse is transmitting this entire data packet it takes (generally) some 200 milli Second to 500 milli Second to complete transmission of the entire data packet. By using the code provided below, I am never able to get the entire data in a single shot. Sometimes the data is broken; for example, I am getting data where a section (say 16 bytes) of the starting section of the data packet is lost. Sometimes, even sections of the end of the data packet is not received. How can I overcome this issue?
I think the parameter ".readTimeout" plays a crucial role in this issue; hence, I have tried different values but didn't get the desired result. I would prefer that the function UART_read returns when there is NO incoming data in the UART RX line for 200 milli seconds, how to achieve this?
Void gpsTaskFxn(UArg arg0, UArg arg1)
{
char rxBuffer[512];
int ret, i;
UART_Handle handle;
UART_Params params;
Task_sleep(1000);
UART_Params_init(¶ms);
params.baudRate = 9600;
params.readDataMode = UART_DATA_BINARY;
params.readReturnMode = UART_RETURN_FULL;
params.readEcho = UART_ECHO_OFF;
params.readTimeout = 800;
handle = UART_open(UART_GPS, ¶ms);
if (!handle) {
System_abort("GPS UART did not open");
}
System_printf("GPS_UART_initialised\n");
GPIO_write(GPS_PWR_CTRL_OUT, PIN_LOW); // De-activate GPS reset circuit
while(1)
{
// System_printf("-------------------------\n");
// System_printf("UART_read called.\n");
ret = UART_read(handle, rxBuffer, 500);
System_printf("UART_read returned %d bytes.\n", ret);
if(ret > 0)
{
rxBuffer[ret-1] = '\0';
}
else
{
rxBuffer[ret] = '\0';
}
System_printf("GPS:%d:%s\n", ret, rxBuffer);
}
}
-
Thanks
-
Regards
Soumyajit