Is there anybody occurs such a problem: the uart will lost data or stuck after several minutes while receiving data?
I just made such a test: I transmit 200 data to the CC1310 UART through USB serial port every 1s; then I made a timer to triggle the monitor,which would detect whether the uart recevied data, if received, then printf the data length. Then I found that the uart would miss some data after several minutes, and take one or two more minutes, the uart would stuck and the system died.
The following is from my code:
#define UART_TASK_STACK_SIZE 1500
#define UART_TASK_PRIORITY 2
void UartTask_init(void) {
UartFifo_init(&Uart_ReceiveFiFo);
/* Create event used internally for state changes */
Event_Params eventParam;
Event_Params_init(&eventParam);
Event_construct(&uartEvent, &eventParam);
uartEventHandle = Event_handle(&uartEvent);
/* Create the node task */
Task_Params_init(&uartTaskParams);
uartTaskParams.stackSize = UART_TASK_STACK_SIZE;
uartTaskParams.priority = UART_TASK_PRIORITY;
uartTaskParams.stack = &uartTaskStack;
Task_construct(&uartTask, UartTaskFunction, &uartTaskParams, NULL);
}
// Callback function
void Uart_ReadCallback(UART_Handle handle, void *rxBuf, size_t size)
{
memcpy(Uart_ReceiveFiFo.Buf, (uint8_t *)rxBuf, size);
Uart_ReceiveFiFo.In += size;
UART_read(handle, Uart_RxTempBuf, 1);
}
// Callback function
void Uart_WriteCallback(UART_Handle handle, void *txBuf, size_t size)
{
// Start another read, with size the same as it was during first call to UART_read()
UART_read(handle, Uart_RxTempBuf, 1);
}
Void UartTaskFunction(UArg arg0, UArg arg1)
{
uint8_t tmp_data = 0; /* Create a UART with data processing off. */
UART_Params uartParams;
UART_Params_init(&uartParams);
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.readCallback = Uart_ReadCallback;
uartParams.writeCallback = Uart_WriteCallback;
uartParams.writeMode = UART_MODE_CALLBACK;
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartHdl = UART_open(Board_UART0, &uartParams);
if (uartHdl == NULL) {
System_abort("Error opening the UART");
}
UART_read(uartHdl, Uart_RxTempBuf, 1);
UART_write(uartHdl, "\r\nJust for a test......\r\n", 25);
/* Loop forever echoing */
while (1){
}
}
static void clk0Fxn(UArg arg0)
{
if(Uart_ReceiveFiFo.In)
{
Uart_PrintfStringDigital("\r\n cnt = ", Uart_ReceiveFiFo.In, 10);
Uart_ReceiveFiFo.In = 0;
}
}
Could you please tell what is going wrong?