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

Fast ble_app_uart_c using nRF52 DK.

Hi all,

I'm using nRF52 DK.

I'm developing a program based on 'ble_app_uart_c' example with custom UUID.

When I type command using UART, central device send signal to peripheral.

Then, peripheral device starts to send data to central device continuously. (For 1 transmission, uint8_t array with data_len=243 is sent)

BLE data transmission rate is 80kbps.

My purpose is to save those data in PC real-time.

That's why I'm using this example.

While nRF52-DK prints data, my custom python program will read data, plot data, and save data in real-time.

By the way, I want to know how to transport received data to PC rapidly using serial port.

Now, I'm using NRF_LOG_INFO. Below is the modified function: ble_nus_chars_received_uart_print.

static void ble_nus_chars_received_uart_print(uint8_t * p_data, uint16_t data_len)
{
    //ret_code_t ret_val;
    NRF_LOG_HEXDUMP_DEBUG(p_data, data_len);
    //printf("%d\r\n", data_len);    //data_len == 243

   int i = 0;
   for (i = 1; i < data_len-1; i=i+2)
   {    
    NRF_LOG_RAW_INFO("%02x%02x", p_data[i], p_data[i-1]);   
    }   
    NRF_LOG_RAW_INFO("%02x\r\n", p_data[i-1]);

}

However, I saw that this makes error often: I guess the reason of this is it cannot print all data before the next BLE packet comes.

So, I want to ask the best way to print fast.

All solutions are welcome.

Thanks!!

Parents
  • Hello,

    I assume you have managed to get a decent throughput since the bottlenect is the UART. UART isn't particularly known for being a high speed protocol, but you can of course try to increase the baudrate. By the way, do you use the UART backend or the RTT backend for your NRF_LOG? I guess the question is, how do you see the log data? Do you use Segger RTT Viewer, Segger Embedded Studio debug session or a UART terminal? The reason I ask is that you are using the ble_app_uart_c, and this doesn't have the UART backend for NRF_LOG by default. Did you add it?

    Which of these are defined as 1 in your sdk_config.h:

    NRF_LOG_BACKEND_UART_ENABLED
    NRF_LOG_BACKEND_RTT_ENABLED

    If you use RTT, then there is no way to speed it up. If you are using UART you can try to increase the baudrate by setting NRF_LOG_BACKEND_UART_BAUDRATE to 268435456 (corresponding to 1000000 baud).

    If that is still too slow, I guess I wold try to skip the logger module, and use the UART directly to skip the overhead.

  • thanks for reply.

    Actually, I'm struggling with that problem.

    I set baudrate 1M, but RTT_ENABLED is set as 1.

    I add UART_ENABLED as 1 and erased RTT_ENABLED, but it made an error. I remember that it has occured in app_uart_fifo.

    So to see my log, I used this 2 ways:

    1. use nrf_log_info and use debugger in segger_embedded_studio.

    2. use printf and use putty (in this case, I set baudrate 1M and could see data, but they were not enough.)

    Can I ask how to do the last solution?: skip the logger module and use UART directly.

    Any method is OK if it can send data through serial with enough speed.

    Thanks!!

Reply
  • thanks for reply.

    Actually, I'm struggling with that problem.

    I set baudrate 1M, but RTT_ENABLED is set as 1.

    I add UART_ENABLED as 1 and erased RTT_ENABLED, but it made an error. I remember that it has occured in app_uart_fifo.

    So to see my log, I used this 2 ways:

    1. use nrf_log_info and use debugger in segger_embedded_studio.

    2. use printf and use putty (in this case, I set baudrate 1M and could see data, but they were not enough.)

    Can I ask how to do the last solution?: skip the logger module and use UART directly.

    Any method is OK if it can send data through serial with enough speed.

    Thanks!!

Children
  • the 1M doesn't matter if you are using RTT. The baudrate is only for UART. 

    If you are printing too much, the logger will not be able to print everything either way. You can try to turn off deferred logging by setting NRF_LOG_DEFERRED to 0.

    If that still doesn't work, then you must look into using UART directly, or consider another transport, such as SPI/USB (the nRF52832 doesn't have USB, and most computers don't have SPI).

    Deferred logging makes the logger print at the moment that you call NRF_LOG_... but if you are receiving data too fast, you will still not be able to log everything. It all comes down to how fast you can transfer each byte.

    BR,

    Edvin

Related