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

Safe UART line idle detection with DMA

Hi, 

We've circled back to this problem, now that we've increased speed.

We're using UART to communicate between the nRF52832 and an STM32. 

Recently we increased the speed to 1M and to do so, have to switch to DMA transfer. We had made some attempts 2 years ago, but gave up, and reverted to byte-by-byte interrupt based uart after not finding a 100% solution in this thread back then:

https://devzone.nordicsemi.com/f/nordic-q-a/29197/uarte-receive-timeout-rxto

To be able to use DMA, we're padding our (variable length) packets to the size of our DMA Blocks. Most of the time this seems to be working. 

However, when an error occurs, and a single byte is dropped, we start getting into trouble, and without idle line detection, cannot recover.

So we're now adding idle line detection as suggested in the above thread: "A solution is to connect GPIOTE IN event to the UARTE RX pin and reset a timer when there is any activity on the pin. If the timer reaches a certain timeout, you know that there have been no data received for that time and you can flush the DMA buffer."

However, as mentioned in the last comment in the above thread:  "there is a possibility that bytes can be received in the timeout period after triggering STOPRX task". 

We're wondering if there's a way to avoid the timeout of STOPRX.

ie: could we simply call FLUSHRX without calling STOPRX? We don't want to stop reception, we just want DMA give us the (incomplete) data and move onto the next DMA block without ever stopping RX. We can handle the "hole" in our data in the higher levels of our protocol.

Thanks to double-buffering, the RXD.PTR would already be moved, and FLUSHRX would cause EasyDMA to copy all the data, then call ENDRX, which in turn would immediately start STARTRX again, so in effect, never actually stop reception.

Or is there an even better solution? 

Parents Reply Children
No Data
Related