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

NRF UART Error at Higher Baud Rate

My requirement is to send from Controller Device to NRF Ble Device through UART of 40Bytes at the rate of less than 1ms. Currently I am using ble_app_uart example as a reference.  

According to Nordic forum UART/UARTE Not able to handle data well at higher Baud Rate. The Overrun Error occurs because of the Byte by Byte data receiving mechanism.

Nordic SDK: 17.0.2

So My question as follows:

1. By using UART/UARTE Can i achieve 921600 or higher baud rate.  

2. If not why? Please send me a reason.

3. If Yes. Please send me a reference.

By Referring the Nordic Forum i get to know by using libuarte-advanced UARTE driver I can achieve higher baud rate. Is this Correct.

So My question as follows:

1. Is 921600 baud rate achievable.

2.  Please send me a Integration Guide with BLE Peripheral Examples(eg,. ble_app_uart).

 3. If there send me a ble peripheral example with libuarte for my refernce.

Parents
  • Hi Susheel,

    First thanks for immediate response.

    UART Configuration:

    app_uart_comm_params_t const comm_params =
    {
    .rx_pin_no = RX_PIN_NUMBER,
    .tx_pin_no = TX_PIN_NUMBER,
    .rts_pin_no = RTS_PIN_NUMBER,
    .cts_pin_no = CTS_PIN_NUMBER,
    .flow_control = APP_UART_FLOW_CONTROL_ENABLED,
    .use_parity = false,
    .baud_rate = NRF_UART_BAUDRATE_921600 //NRF_UART_BAUDRATE_115200
    };

    FiFO Priority: APP_IRQ_PRIORITY_LOWEST

    My Application Used Softdevice to transfer the received data to Windows Application.

    Our Main Intention is to receive the data from Controller through UART to BLE and update to Windows APP using Services.

    This process need to done in less than 1ms. At every 1ms i am sending data from Controller and Update to APP continuously. 

    At 115200 Works good on thing is for 40bytes transfer uart consumes around 3-4ms.

    At 921600 we can transmit 40bytes within 200-400us.

    But Our Application is based on real time. We have to transmit data from controller to BLE in less than 1 milli sec.

    By using app_uart FIFO Mechanism it is not possible. As i mention earlier UART overflow occurs or data loss. As i seen this while testing.

    But By go through Nordic Forum i get to know UART higher speed we can achieve using libuarte. Because it gives Chunk of data instead of byte by byte. 

    I think implementing (libuarte)  in our application we can achieve Higher Speed.

    If  by using app_uart FIFO mechanism if we can achieve Higher Speed it will be good to go. Please Specify if there are any settings.

    Because i am facing a problem integrating or merge "libuarte" with "ble_app_uart". As i tested libuarte standalone with our controller it look works fine based on our requirement. 

    Our Application Main Intension is to achieve UART High Speed. 

    I would appreciate any suggestions to achieve fast result.

    Thanks,

    Pavan

Reply
  • Hi Susheel,

    First thanks for immediate response.

    UART Configuration:

    app_uart_comm_params_t const comm_params =
    {
    .rx_pin_no = RX_PIN_NUMBER,
    .tx_pin_no = TX_PIN_NUMBER,
    .rts_pin_no = RTS_PIN_NUMBER,
    .cts_pin_no = CTS_PIN_NUMBER,
    .flow_control = APP_UART_FLOW_CONTROL_ENABLED,
    .use_parity = false,
    .baud_rate = NRF_UART_BAUDRATE_921600 //NRF_UART_BAUDRATE_115200
    };

    FiFO Priority: APP_IRQ_PRIORITY_LOWEST

    My Application Used Softdevice to transfer the received data to Windows Application.

    Our Main Intention is to receive the data from Controller through UART to BLE and update to Windows APP using Services.

    This process need to done in less than 1ms. At every 1ms i am sending data from Controller and Update to APP continuously. 

    At 115200 Works good on thing is for 40bytes transfer uart consumes around 3-4ms.

    At 921600 we can transmit 40bytes within 200-400us.

    But Our Application is based on real time. We have to transmit data from controller to BLE in less than 1 milli sec.

    By using app_uart FIFO Mechanism it is not possible. As i mention earlier UART overflow occurs or data loss. As i seen this while testing.

    But By go through Nordic Forum i get to know UART higher speed we can achieve using libuarte. Because it gives Chunk of data instead of byte by byte. 

    I think implementing (libuarte)  in our application we can achieve Higher Speed.

    If  by using app_uart FIFO mechanism if we can achieve Higher Speed it will be good to go. Please Specify if there are any settings.

    Because i am facing a problem integrating or merge "libuarte" with "ble_app_uart". As i tested libuarte standalone with our controller it look works fine based on our requirement. 

    Our Application Main Intension is to achieve UART High Speed. 

    I would appreciate any suggestions to achieve fast result.

    Thanks,

    Pavan

Children
  • Pavan Kote said:
    This process need to done in less than 1ms. At every 1ms i am sending data from Controller and Update to APP continuously. 

    The minimum connection interval you can achieve on BLE is 7.5ms on a connection. So when you say that you are sending UART data from a controller through UART, i am assuming that you are assembling the data received into one packet before sending the data on the BLE connection?

    .  

    Pavan Kote said:
    By using app_uart FIFO Mechanism it is not possible. As i mention earlier UART overflow occurs or data loss. As i seen this while testing.

     Your BLE throughput depends a lot on 

    1. connection interval
    2. MTU size
    3. and your application pre and post-processing latencies of each packet. If you do a lot of pre and post processing of each packet you receive, you would eventually make the buffers full (since your application takes more time to process each packet) making the BLE controller to wait until application pulls data and frees the buffer.

    I do not think we have done any benchmarks on which library (app_fifo or libuarte) has less latency per transaction transfer. app_fifo might add more latency as it uses an addition fifo library to operate on the buffer.

    In the end, i think your throughput goals are a bit ambitious, if you really want to attain them you need to do a lot of architectural considerations on how you can minimize per uart transaction latencies. You need to decide if maybe using NRFX_UART driver directly instead of using a library makes it better in terms of reducing pre and post processing of  uart transaction..

  • Hi Susheel,

    Sorry for the late reply. I will try to make use of NRFX_UART driver.

    Thanks

    Pavan Kote

  • Hi Susheel,

    As you suggested I used "nrf_drv_uart" driver directly without using any library. Only relief i get is working with softdevice at higher baudrate.

    UART Callback Handler:

    void uart_event_handler(nrf_drv_uart_event_t * p_event, void* p_context)
    {
    uint32_t err_code;

    switch (p_event->type)
    {
    case NRF_DRV_UART_EVT_RX_DONE:
    //Copied the RX data to buffer and process in Main Function
    break;

    case NRF_DRV_UART_EVT_ERROR:

    break;

    case NRF_DRV_UART_EVT_TX_DONE:

    break;

    default:
    break;
    }
    }

    UART Settings:

    static void uart_init(void)
    {
    uint32_t err_code;
    nrf_drv_uart_config_t config = NRF_DRV_UART_DEFAULT_CONFIG;
    config.baudrate = NRF_UART_BAUDRATE_460800; //NRF_UART_BAUDRATE_921600;
    config.hwfc = NRF_UART_HWFC_ENABLED;
    config.interrupt_priority = 2; //6
    config.parity = NRF_UART_PARITY_EXCLUDED;
    config.pselcts = CTS_PIN_NUMBER;
    config.pselrts = RTS_PIN_NUMBER;
    config.pselrxd = RX_PIN_NUMBER;
    config.pseltxd = TX_PIN_NUMBER;

    err_code = nrf_drv_uart_init(&app_uart_inst, &config, uart_event_handler);
    VERIFY_SUCCESS(err_code);


    // Turn on receiver if RX pin is connected
    if (RX_PIN_NUMBER != UART_PIN_DISCONNECTED)
    {
    return nrf_drv_uart_rx(&app_uart_inst, uart_rx_buffer, 1);
    }else
    {
    return NRF_SUCCESS;
    }
    }

    Queries:
    1. When i send the 40 Bytes data every 1msec Baud Rate: 460800.
    1.1. As i can seen with still there is a overrun error sometimes.

    2. When i send the 40 Bytes data every 1msec Baud Rate: 921600.
    1.1. As i can seen with half of the data is missing with overrun error.

    3. Our Requirement is UART Data Received from every 1msec of 40bytes let us say with softdevice. After Send Data to BLE using Notification.
    4. May be the delay is related to processing. How we can resolve this issue.
    5. I tried with Different Priorities. Still Not getting 100% data.
    6. How to use EasyDMA with double buffering with "nrf_drv_uart" driver or "NRFX_UART" driver .
    7. Is it possible to integrate "libuarte" with softdevice. In forum lot of members say with this library we can achieve higher baud rate. 

    Please suggest me the  better solution as i struck in between on development phase. It's urgent.

    Thanks & Regards

    Pavan Kote

  • Hi Pavan, 

    Do you know the configuration of the peer UART device? Does it have the HWFC enabled? If not, that could one of your issues here.

    If you see overrun errors even with the HWFC enabled  o both ends then it seems that the peer UART is sending data too fast. By the the time nRF UART can toggle the CTS pin, the peer UART is already sending few bytes overruning the FIFO in the uart. This depends on many factors and the speed with with your application is pulling data from the RX FIFO plays a major role in it.

     

    Pavan Kote said:
    6. How to use EasyDMA with double buffering with "nrf_drv_uart" driver or "NRFX_UART" driver .

     you need to enable UARTE in your config file and the test in the source file is done as below, so you need to enable atleast NRF_UARTE_ENABLED and one of the NRFX_UARTEX_ENABLED

    #if NRFX_CHECK(NRFX_UARTE_ENABLED)
    
    #if !(NRFX_CHECK(NRFX_UARTE0_ENABLED) || \
          NRFX_CHECK(NRFX_UARTE1_ENABLED) || \
          NRFX_CHECK(NRFX_UARTE2_ENABLED) || \
          NRFX_CHECK(NRFX_UARTE3_ENABLED))
    #error "No enabled UARTE instances. Check <nrfx_config.h>."
    #endif

  • Hi Susheel,

    The HWFC Enabled in Peer UART Device.

     

Related