This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0G3507: TI UART driver can block even when data is available in the the buffer

Part Number: MSPM0G3507

The TI UART driver in the SDK in source\ti\drivers\UART.c the function UART_readBufferedMode can block even when there is data available in the ring buffer. I have variable length packets, so I need to first read the header bytes before reading the rest of the data. However each time a read is done it pends on the semaphore, so when the second read is done it will block until more data arrives which may not be right away and causes timing issues.

For example:

  • 10 bytes arrive
  • I do a 3 byte read, this clears the semaphore
  • I see I need to read 7 more bytes from the length byte but this call blocks despite all 7 bytes being available in the buffer
  • The call does not return until more data arrives on the uart to trigger the semaphore

I’ve fixed this for now by modifying the driver code but it would be cleaner if the driver was fixed officially. I did it by checking the RingBuf first for any data and if there is enough data then returning without blocking on the semaphore.

This is in driver version 2.00.01.00