Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

UARTE RX abort

Hi,

I'm currently developing an application that uses UARTE. I use the nRF5_SDK_17.1.0_ddde560 version and I've observed a possible bug when using the NRFX UARTE API. 

My target was to create a timeout for the UART communication, triggered by Timer. Simply request nrfx_uarte_rx() and after a timeout, abort this request by nrfx_uarte_rx_abort(), clear my buffers, etc. and start again. 

I've found out, that if you call nrfx_uarte_rx_abort() and later request nrfx_uarte_rx() again, it was failing, because the return of the nrfx_uarte_rx() was NRF_ERROR_BUSY.

Simplified code:

(nrfx_uarte_rx() was returning NRF_SUCCESS always 2 times since it uses dual buffering)

After some debugging, I found the issue. After adding 600 us delay, the issue has been resolved.

Therefore, there is a certain time needed between nrfx_uarte_rx_abort() and calling the nrfx_uarte_rx(). 
Unfortunately, it's not just a few us, which I would understand. But by decreasing the delay from 600us to 500us, the issue was still present:

I'm not sure if this behavior is normal or not, but 600 us delay, that is needed between aborting and requesting RX from the UARTE periphery, seems to be a lot to me.

Now knowing this issue, it's quite easy to solve (either delay or polling till UARTE is not busy), but this can be tricky with time-critical applications.

Writing this topic, so if somebody else faces the same issue, so they know the root of the cause. 

Kind Regards,

Milan

Related