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

BLE data transfer speed issues with nRF52840

Hi, I want to measure the data transfer speed of BLE. I  use the nRF52840 DK with the ble_app_uart example

I created a dummy string of 20 bytes (default length of one packet) and I send the string again and again in an endless loop. 

Every time the string is  transferred to the android smartphone, I invert the state of an output pin on the DK so that I can measure

the frequency (speed) with the oscilloscope.

After connecting the DK to the smartphone, data transmission starts and I can observe the data coming on my smartphone BLE uart application.

At the same time I take measurements from the inverting output pin with the oscilloscope and I have noticed a few things that I cannot explain.

BLE Settings are : MAX_CONN_INTERVAL = 20, MIN_CONN_INTERVAL = 10, PHY= 2Mbps,

1. For the period of one connection interval only a  few transmissions occur at the beginning and for the rest of the connection interval no transmission takes place until the next interval.

2. When I remove the  do{}while (err_code == NRF_ERROR_RESOURCES) check which includes the ble_nus_data_send() , then the transmissions occur for the whole length of the connection interval.

 Why this do{}while (err_code == NRF_ERROR_RESOURCES) check  occupies such a big chunk of the connection interval period?

3.The theoretical speed is 250kBps (PHY2) but I can transfer only 30kBps. Why is that? I expected  it to be much higher...

4. I read that in order to transmit more data I must enable the DLE function of BLE so that I can send up to 251 bytes in one transfer packet. How can I do that in the example?

5. Is there something else that I should take care of in order to come closer to the speed  of 250kBps?

Parents
  • 1. There is a limitation to connection event length, set in the sdk_config.h Try increasing NRF_SDH_BLE_GAP_EVENT_LENGTH

    2. The NRF_ERROR_RESOURCES error means there are no available tx buffers. If you don't wait for the buffer to be freed before you move on to the next data bulk you will not transfer all the data.

    3. You need to optimize the connection settings. More on that in other devzone cases e.g.https://devzone.nordicsemi.com/f/nordic-q-a/62363/nrf52832-throughput-test-with-nordic-uart-service

    4. This seems to be enabled by default in sdk 17.0.2. but look at sdk_config.h NRF_SDH_BLE_GATT_MAX_MTU_SIZE and also the defines in ble_nus.c

    #define BLE_NUS_MAX_RX_CHAR_LEN        BLE_NUS_MAX_DATA_LEN /**< Maximum length of the RX Characteristic (in bytes). */
    #define BLE_NUS_MAX_TX_CHAR_LEN        BLE_NUS_MAX_DATA_LEN /**< Maximum length of the TX Characteristic (in bytes). *

    5. 250 kBytes is not possible. Due to protocol timing restrictions and packet overhead the max is about 1.3 mbps. See SD guide on throughput: infocenter.nordicsemi.com/.../ble_data_throughput.html

  • Thank you for your reply.

    In image 1 as you can see, the time that data are being transferred, occupy a very small portion of the entire connection interval(each small pulse represents a transfer). The rest of the connection interval is not used for data transfer as I would expect until the buffer is free again and a new connection interval begins. This takes 90% of the connection interval so the way I see it, it is impossible to achieve higher transfer speed without removing the ( do{}while (err_code == NRF_ERROR_RESOURCES)  check.

Reply
  • Thank you for your reply.

    In image 1 as you can see, the time that data are being transferred, occupy a very small portion of the entire connection interval(each small pulse represents a transfer). The rest of the connection interval is not used for data transfer as I would expect until the buffer is free again and a new connection interval begins. This takes 90% of the connection interval so the way I see it, it is impossible to achieve higher transfer speed without removing the ( do{}while (err_code == NRF_ERROR_RESOURCES)  check.

Children
Related