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

overrun error when receiving data from UARTE

Hi, 

I have problem with using nrf_serial.h, I am receiving data from Ublox GPS, baud rate = 9600, no flow control as we dont have enough IO pins.

Device is nrf52840 with SDK 16.0. I am using SERIAL_MODE_DMA, SERIAL_BUFF_RX_SIZE = 128, SERIAL_FIFO_RX_SIZE = 4096.

I am constantly getting NRF_SERIAL_EVENT_DRV_ERR events (overrun) even if fifo is empty (see picture below). If i get NRF_SERIAL_EVENT_RX_DATA event I set a flag and call nrf_serial_read in task as i dont want to spend too much time in IRQ.

Parents
  • Hi 

    In general I would strongly recommend switching to the nrf_libuarte library, in particular if you're using UART without flow control. 

    This library is the most feature rich and well tested for UART in the nRF5 SDK, and has an async version for applications where you don't know when you might received data over the UART, or how much data you might receive. 

    Best regards
    Torbjørn

  • Hi,

    thanks for quick reply, but I have one further question:

    We have 2 devices connected with uarte, one without flow control (GPS), and one with flow control and 115200 baud rate. Is that possible with nrf_libuarte library ?

    Best regards,

    Luka

  • Hi Luka

    Yes. The nrf_libuarte library uses instances, which means you can configure the library for each UART interface in the device and use different settings for each one. 

    On a device such as the nRF52840, which has 2 UARTE interfaces, you can then run one without flow control and one with flow control if you want. 

    Best regards
    Torbjørn

  • Hi,

    I implemented libUARTE_async. Everything works fine until first buffer is filled, then my program goes in fault (see attached screenshot). Only thing I do in event handler on RX done is to print one random string, if I remove printf and do nothing in event handler I don't get a fault. I checked with debugger and buffer gets overfilled (my buffer is 200bytes long but there are 205 bytes written, so I suspect that causes a fault.

    Do you have any idea where problem could be?

    Best regards,

    Luka

  • Hi Luka

    Do you print the random string on the same interface that you receive data on?

    Are you able to share the event handler implementation from your code?

    Best regards
    Torbjørn

  • Hi,

    No I print string on USB (similar to USB cdc acm example). Event handler is very simple, I would send received data to queue which is processed by task, but there is same problem if I just print random string.

    Best regards

    Luka

    void uart_event_handler_modem(void * context, nrf_libuarte_async_evt_t * p_evt)
    {
        ret_code_t ret;
    
        switch (p_evt->type)
        {
            case NRF_LIBUARTE_ASYNC_EVT_ERROR:
                {
                  
                }
    
                break;
            case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
                {
    
                    console("random string\n");    
                    nrf_libuarte_async_rx_free(&libuarte2, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
    
                }
                break;
            case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
                {
    
                }
                break;
            case NRF_LIBUARTE_ASYNC_EVT_OVERRUN_ERROR:
                {
                  
                }
            break;
            default:
                break;
        }
    }

  • Hi 

    And how is the console(..) function implemented?

    Could you try to set a flag in the event handler and call console(..) from the main context instead, and see if this works better?

    Best regards
    Torbjørn 

Reply Children
Related