I have written a UARTE driver, to conform to the kind of API we need, for NRF52840. It is very nearly working except that it drops single received characters and I'm trying to find out why. In summary I have:
- four buffers each of length 256 characters,
- the buffers are arranged as a circular list,
- the RXSTARTED interrupt re-programmes RXD to point to the next buffer,
- ENDRX is shorted to STARTRX,
- the ENDRX interrupt sends a notification to an RTOS task which takes all the data out of the Rx buffers that it can,
- a free-running timer expires every 130 ms and issues STOPRX to handle cases where incoming data has stopped.
So, if my understanding is correct, receive is continuous and interrupt based through use of RXSTARTED to re-programme RXD and shorting ENDRX to STARTRX. The RTOS task only has to read stuff and, in any case, if it were too slow for some reason it would be unlikely to cause single characters to drop, more likely whole chunks.
The complete code can be found here, where the initialisation function is at line #338, the interrupt handler at line #176 and the read function at line #652.
Can anyone spot my [deliberate :-)] mistake/misunderstanding?!
FYI, here is an example of the character loss. The far end sent:
_____0000:012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
_____0100:012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
_____0200:01234567890123456789012345678901234567890123456789012
I received:
_____0000:012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
_____0100:012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
_____0200:0123456789012345678901234567890123456789013456789012
------------ THE "2" IS MISSING HERE --------------^