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

nRF52 `app_uart_fifo` not using hardware? Overflow errors.

Hi,

I posted recently about having used the app_uart driver and having problems with an overflow breaking uart receive (devzone.nordicsemi.com/.../)

I decided to try with app_uart_fifo and see if that was any better, but I'm still getting 'overflow' problems.

In fact, looking at the code, app_uart_fifo calls nrf_drv_uart_rx(..., rx_buffer, 1) - so it seems that even if I've allocated a 256 byte buffer for my fifo, and uarte is enabled, the hardware itself won't be used and I'll still get hardware overflow errors if an IRQ occurs at the wrong time at higher baud rates.

Is this the case? I'm using SDK12.3 but it looks to be the same in SDK14 as well.

Are there any examples/libraries available that use the UARTE hardware with a circular buffer, so I can be sure that I won't get overflows - or is there a hardware problem which means it can't be done? It seems odd that Nordic's own libraries don't use it.

thanks!

Parents
  • Hi,

    It is very hard to prevent overflow without using flow control lins. You can use the ENDRX_STARTRX shortcut to create a circular buffer. The backside of this, is that you will overwrite the buffer if you are not handling the first values in the buffer before the buffer is filled. Typically the user cannot accept data loss, and this circular buffer is therefore not a good solution.

    The UART driver support RX double buffering, by calling nrf_drv_uart_rx() two times. This allows you to process one buffer, while the other is filled. Have you tried this approach?

    Best regards,

    Jørgen

Reply
  • Hi,

    It is very hard to prevent overflow without using flow control lins. You can use the ENDRX_STARTRX shortcut to create a circular buffer. The backside of this, is that you will overwrite the buffer if you are not handling the first values in the buffer before the buffer is filled. Typically the user cannot accept data loss, and this circular buffer is therefore not a good solution.

    The UART driver support RX double buffering, by calling nrf_drv_uart_rx() two times. This allows you to process one buffer, while the other is filled. Have you tried this approach?

    Best regards,

    Jørgen

Children
Related