Part Number: CC2640
Tool/software: Code Composer Studio
i have a simple code to read from Uart on CC2640 MCU sdk 2.20.00.49
in Main.c
UART_init(); uartParams.readTimeout=100*1000 / Clock_tickPeriod; UART_Params_init(&uartParams); uart_handle= UART_open( Board_UART0, &uartParams );
in task thread (the thread created by main.c)
uint8_t rxbuf;
int count_rx=0,read=0;
while(1)
{
read=UART_read(uart_handle,&rxbuf,1);
Log_info0("\r\n buffer ch");
while(read)
{
Log_info3("\r\n buffer ch is %c and %d and %d ",rxbuf,count_rx,read);
dbgUartRxBuf[count_rx]=rxbuf;
count_rx++;
read=UART_read(uart_handle,&rxbuf,1);
}
count_rx=0;
//do next tasks
I do expect that if there is no new coming in uart buffer after 100ms, program will escape from while(read) and do next task with data and I used terminal on PC to test and when sending "START" to MCU and I got
[32;1mINFO: [30;1m(system_task.c:350) [0m
buffer ch is S and 0 and 1
[32;1mINFO: [30;1m(system_task.c:350) [0m
buffer ch is T and 1 and 1
[32;1mINFO: [30;1m(system_task.c:350) [0m
buffer ch is A and 2 and 1
[32;1mINFO: [30;1m(system_task.c:350) [0m
buffer ch is R and 3 and 1
[32;1mINFO: [30;1m(system_task.c:350) [0m
buffer ch is T and 4 and 1
then I waited a moment (minute) and sent a "q" , I got
q[32;1mINFO: [30;1m(system_task.c:350) [0m
buffer ch is q and 5 and 1
it means that loop while (read) still not is escaped and also the uart_read did not return (if return, it should print a lot of "buffer ch is") while the readtimeout is set to a specific value, not forever.
what is my mistake?