Hi,
Currently I implemented a UART application on CC2541. Basically the application echoes what it receives from the UART Rx to the Tx pin at 115200 baud rate. But it encounters data lost.
Shown above is one instance where "abcdefghijklmnopq" is sent from a PC to CC2541, and the yellow font characters are the reponse. You can notice a randomn lost of charaters.
The following is my implementation of the echo function.
switch (*event)
{
case IO_SHIM_UART_RX_FULL:
case IO_SHIM_UART_RX_ABOUT_FULL:
case IO_SHIM_UART_RX_TIMEOUT:
holder.size=32;
avail_len=Hal_UART_RxBufLen(HAL_UART_PORT_0);
res=io_shim_recv_data(IO_SHIM_UART,&holder);
HalUARTWrite(HAL_UART_PORT_0,holder.data,avail_len);
HalLcdWriteStringValue("LEN:",holder.size,10,2);
HalLcdWriteString(holder.data,3);
break;
case IO_SHIM_UART_TX_FULL:
break;
case IO_SHIM_UART_TX_EMPTY:
break;
default:
break;
}
After a careful examination, the event processing routine is called twice. The first call echoes "abcdefghijk", and the second call echoes "mnopq". It seemed that the receiving process is interrupted somehow. I checked the input data stream, there was no gaps between data bytes that was long enough to trigger an UART_IDLE_TIMEOUT. Therefore I wonder if there is anything that interrupts the UART receiving process?
Here is my configuration procedure
uart_config.configured=false;
uart_config.baudRate=HAL_UART_BR_115200;
uart_config.flowControl=false;
uart_config.flowControlThreshold=100;
uart_config.idleTimeout=2000;
uart_config.rx.pBuffer=uart_rxbuf;
uart_config.rx.maxBufSize=128;
uart_config.tx.pBuffer=uart_txbuf;
uart_config.tx.maxBufSize=128;
uart_config.intEnable=false;
uart_config.callBackFunc=uart_cb_fp;
Here is my constant definition.
INT_HEAP_LEN=3072
HALNODEBUG
OSAL_CBTIMER_NUM_TASKS=1
xHAL_AES_DMA=TRUE
HAL_DMA=TRUE
HAL_UART=TRUE
xHAL_UART_DMA=TRUE
xHAL_UART_DMA=0
HAL_UART_ISR=0
HAL_UART_ISR_RX_MAX=128
HAL_UART_ISR_HIGH=110
xHAL_UART_DMA_RX_MAX=128
xHAL_UART_DMA_HIGH=110
OSAL_CLOCK
xPOWER_SAVING
xPLUS_BROADCASTER
HAL_LCD=TRUE
HAL_LED=TRUE
CC2541_MINIDK
DC_DC_P0_7
Thanks in advance for your input.