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

  • 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.

     

  • Then try reducing the baudrate as it seems your application is not able to handle reception at that high speeds.  Overrun error can still happen at these high baudrate when the peer is still sending data during the time when nRF is still pulling the CTS high.

Reply Children
  • Till 250K Baud rate it's ok. I am receiving data nicely.

    But according to our requirement we have to send data from Controller UART to BLE Module UART and send data through BLE within a span of 1msec.

    If we configured our UART 1M it will send 40 bytes of data in 200 microsec. the BLE send process will took around 600 micro sec.

    I change the UART Interrupt priority also.

    Is it radio priority and interrupt priority clashes or While radio event or within the time of connection interval(7.5ms) is it blocking UART interrupt.  

  • What is the MTU size? that decides on many bytes are sent in one connection event. (X bytes/7.5ms)

    how much processing time is spent before and sending data (Y us)

    Application+uart driver latency on every byte transaction on UART (Z us). How many bytes per transaction best suites for your application when using EasyDMA?

    It is the architect of your software who needs to consider /benchmark and fine tune these perameters and these are different for every application. It is not possible from us at the techsupport to give you a general answer on this.

     

    Pavan Kote said:
    If we configured our UART 1M it will send 40 bytes of data in 200 microsec. the BLE send process will took around 600 micro sec.

    Here it looks like BLE overhead to process and send 40 btyes of data is 200+600 = 800us.

    If you can also benchmark the UART bytes overhead (by commenting out the BLE part, or even better disable the softdevice just for benchmarking UART purpose) then you can clearly get some numbers on maximum throughput you can achieve combinging UART and BLE for your usecase.

    The RADIO interrupt will be highest priority when using softdevice.

  • Hi susheel,

    BLE Configuration:
    Notification Data Payload : 37
    ATT_MTU: 40
    GAP Data Length: 44

    Connection Interval: 7.5ms
    Gap Event Length: 400(500ms) and 6(7.5)
    hvn_tx_queue_size: 6/12

    what is the default size of HVN TX QUEUE SIZE.

    So My query:
    If i set ATT MTU 247 and Gap Data Length 251
    How many packets will send in one connection interval(7.5ms) on 1m distance as well as 12m distance with worst condition. Is characteristic value data payload and (ATT_MTU-3) & (GAP Data length = ATT_MTU+4)should be same.


    If i set ATT MTU 40 and Gap Data Length 44
    How many packets will send in one connection interval(7.5ms) on 1m distance as well as 12m distance with worst condition.


    what is the maximum time required to send one packet of 40bytes. is it varies according to environment surrounding.

    According to softdevice s132 document(S132_SDS_v7.1.pdf) what do you mean by application can configure tndist on page 54. If so, how we can do that?

    Instead of sending 1ms if i send 111bytes every 3ms can i achieve constant throughput till 11m on worst condition.

    Please suggest the best possible configuration need to send data 37bytes in 1ms , 74bytes in 2ms or 111bytes in 3ms.

  • Pavan,

    Pavan Kote said:
    If i set ATT MTU 247 and Gap Data Length 251
    How many packets will send in one connection interval(7.5ms) on 1m distance as well as 12m distance with worst condition. Is characteristic value data payload and (ATT_MTU-3) & (GAP Data length = ATT_MTU+4)should be same.

     For a 1M PHY, if you have 247 ATT MTU size then

    The total BLE packet size will be (1 + 4 + 2 + (4 + 247) + 3) = 261 bytes = 2088 bits.

    On a 1 MPHY this will take just over 2ms to transmit one packet and i think the best case is you can transmit two such packets within a connection interval of 7.3ms.

    We cannot say the average values per given conditions but there are some benchmark numbers that we have done which can be found here.

  • Hi Susheel,

    I want the benchmarks results according to worst case.

    I would like to transmit the data via the BLE continuously(real time 1ms) using notification. Is it possible. Is there any alternate options available for fast real time data transmission using BLE.

     

    As i seen in some forums as the data should be prepared or queued to hvn tx buffer previously before connection interval starts right. It means we cannot able to send real time data on real world condition. Is it right.

    For ex if i capture ADC value of 1000 samples per second i want to send 1000 samples per second. How can we send the data. Is there any solution for this kind of requirement using ble.

Related