Hello,
on LPC5528/LPC5526/LPC55xx, I'm using the USART driver from the SDK, see
https://github.com/nxp-mcuxpresso/mcuxsdk-core/blob/main/drivers/flexcomm/usart/fsl_usart.c#L1123
The code works properly when requesting to receive single bytes using
USART_TransferReceiveNonBlocking()
It also recovers on RX FIFO overflows by reinitiating reception.
Situation is different when using
USART_TransferReceiveNonBlocking()
with xfer->dataSize > 1. For example, the receive callback inspects the RX FIFO level and if the RX FIFO level is > 1, it calls USART_TransferReceiveNonBlocking() with the exact number of bytes of in the RX FIFO to retrieve these bytes more efficiently, say 10 bytes.
However, if the system is busy handling other interrupts, the RX FIFO might overflow. Then
void USART_TransferHandleIRQ(USART_Type *base, usart_handle_t *handle)
clears the RX FIFO overflow bit, empties the FIFO and calls the callback with kStatus_USART_RxError. All the bytes from the FIFO are therefore discarded and cannot be received any more.
However, it does not reset rxDataSize. So the callback will not be called again until the number of bytes (in the example ten bytes) have been received. Until this, the receive mechanics hangs.
How do you recover from this situation?
Resetting the dataSize by calling USART_TransferReceiveNonBlocking() with xfer->dataSize = 1does not work as the receive mechanics is still in status kUSART_RxBusy.
So I wonder what is the proper way to handle RX FIFO overflows with the SDK drivers.
Thanks.
Daniel
PS: sorry for the strange text formatting. I tried to markup code so it is easier to read but screwed up.