Hi:
I am working on the receive portion of a driver for the TMS320F2812 UART (SCI).
The driver is interrupt driven and uses a software FIFO (which I refer to as the "buffer") to enhance the amount of chars that can be received without loss before being read by user code. There is also the 16-byte hardware FIFO which I call the "FIFO".
In the case that there is a FIFO overrun, then I know that all of the data yet to be read in both the buffer and the FIFO is still good (no dropped chars). It would be easy to just abandon the last 16 chars received in the FIFO, and inform the user that what's in the buffer was all that was available prior to the error.
It would be somewhat more difficult to try to preserve the last 16 FIFO chars as well. Since the FIFO will continue to receive even after an overrun error, to track where the error occurred while still allowing FIFO chars to be streamed into the buffer would require some additional counter and logic.
The benefit would be allowing the user to digest all of the chars before the error occurred instead of discarding the 16 chars that were received before the error.
Since if an overrun error occurs it is likely that much of what had been sent up to the point of the error will have to be re-sent anyway, is it worth the trouble and added complexity to preserve the last 16 chars?
The only reason I can think of is that the device I'm making will have both a command interpretation mode, and a binary block transfer protocol mode. Preserving all FIFO chars might enable responding to a command like "stop" which may have been issued prior to the lost chars. Otherwise, processing this command would have to wait until the program realized the error, reset the UART, and the other side of the link realized what happened, reinitialized communications, and reissued the command.
What is typically done in UART drivers with the contents of the hw FIFO when an overrun is detected?
Thanks for input!