This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UARTE framing errors on NRF52840 instead of my data

I have written a UART driver that is intended to receive data in a continuous stream.  I know it basically works as it is able to communicate with an external device at 115,200 bits/s. I am now performing more rigorous testing.

I have a very simple HW setup with the UART Tx/Rx on pins p1.10 and p1.11 of the NRF52840 DK board looped back to each other; perfect electrical conditions.  My test code is transmitting data from the UART continuously and receiving data back in an RTOS task.  My driver has a 135 ms timeout, necessary for the case where data is received in bursts, which disables the ENDRX_STARTRX short and triggers STOPRX.

My problem is that after the RXTO event occurs as a result of my timeout, the rest of my data is received back as framing errors, not actual data.  All I do in the RXTO interrupt is re-enable the ENDRX_STARTRX short and trigger the STARTRX task.  FYI I do call nrfx_clock_hfclk_start() at start of day.

So something is wrong.  Question is, what is the right way to do this, to implement continuous UART receive while dealing with the fact that there may be breaks in the received data and that cannot leave stuff lying stale in the UART Rx buffer?  Should I be re-enabling the ENDRX_STARTRX short and re-triggering the STARTRX task earlier somehow?  I have tried setting a flag when the timeout has occurred and doing the re-enabling/triggering in the ENDRX interrupt instead but that didn't seem to help.

The complete driver code can be found here: https://github.com/u-blox/cellular/blob/master/port/platform/nordic/nrf52840/src/cellular_port_uart.c.

Related