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

Missing UART received data with ble_app_uart

nRF52832
nRF5 SDK V17.0.2
SoftDevice S132 V7.2.0

I am running the sample program ble_app_uart in the above environment, but sometimes I miss UART received data.
Teraterm is used for data transmission to UART of nRF52832, and self-made software (C #, Windows 10) is used for BLE communication reception.
No problem occurs when sending data by keyboard input of Teraterm, but when a text file is sent by sending a file of TeraTerm, it is missed.
The text file used contains only ASCII characters from 0 to 9 and CR.
The position where the omission occurs often occurs near the 9th to 11th lines of the text file.
The shorter the length of one line, the more frequently it occurred, but even if it was made longer, it could not be resolved.
If you set 20msec for the wait after sending one line in Teraterm settings, the omission will be resolved.
It was improved by reducing the values of MIN_CONN_INTERVAL and MAX_CONN_INTERVAL in main.c, but it could not be solved.
I changed UART_TX_BUF_SIZE and UART_RX_BUF_SIZE in main.c from 256 to 1024, but I couldn't solve it.

Please let me know if there is a good way to eliminate the omission of UART received data.

Communication log example
Received data was missed on the 10th, 11th, and 13th lines, and the number of characters in one line is no longer 80 characters.

'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(37byte) = '234569012345678901234567890123456789
'LE RxData(15byte) = '23456123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(60byte) = '23456678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789
'LE RxData(80byte) = '1234567890123456789012345678901234567890123456789012345678901234567890123456789

Parents
  • Hi.

    Have you tried increasing UART buffer size by adjusting UART_TX_BUF_SIZE and UART_RX_BUF_SIZE?

    regards
    Jared
  • Hi,Jared

    APP_UART_COMMUNICATION_ERROR

    APP_UART_FIFO_ERROR

    These events are currently ignored.
    Do I need to add processing to clear the error?
    UART flow control can not be used because the communication partner does not support.

    void uart_event_handle(app_uart_evt_t * p_event)
    {
    uint32_t err_code;

    switch (p_event->evt_type)
    {

    case APP_UART_DATA_READY:
    if( uartEventRxBlockIf0 != 0 )
    {
    UNUSED_VARIABLE(app_uart_get( &uartRxBuf[ uartRxBufIndex ]));
    uartRxBufIndex++;
    if (( uartToBleBlockIf0 != 0 ) && ( uartRxBufIndex >= m_ble_nus_max_data_len))
    {
    nrfx_rtc_cc_disable( &rtc, RTC_CH_UART_TMOUT );
    if ( 0 < uartRxBufIndex )
    {
    do
    {
    err_code = ble_nus_data_send(&m_nus, uartRxBuf, &uartRxBufIndex, m_conn_handle);
    } while (err_code == NRF_ERROR_RESOURCES);
    }
    uartRxBufIndex = 0;
    }
    else
    {
    nrfx_rtc_cc_set( &rtc, RTC_CH_UART_TMOUT, ( nrfx_rtc_counter_get( &rtc ) + RTC_CNT_UART_TMOUT ) & 0x00ffffff, true );
    }
    }
    break;

    case APP_UART_COMMUNICATION_ERROR:
    // modified from sample   APP_ERROR_HANDLER(p_event->data.error_communication);
    break;

    case APP_UART_FIFO_ERROR:
    // modified from sample    APP_ERROR_HANDLER(p_event->data.error_code);
    break;

    default:
    break;
    }
    }

    regards

    matsumiya

  • Hi,

    Most likely you are getting an error because the FIFO fills up. The application is not able to process the data in the FIFO before new data arrives. I think you have to rewrite this application for it work as you intend. You could:

    1. Define a buffer that you can use to store the data from the FIFO while it's processed. 

    2. The ble_app_uart example sends the data as soon as it receives a newline. This is not good for maximum throughput as it causes the application to send multiple ble packets without filling them completely up. The sending of data has some overhead, so preferably you would only want to do it when the ble packet is full. Try removing this check:

Reply
  • Hi,

    Most likely you are getting an error because the FIFO fills up. The application is not able to process the data in the FIFO before new data arrives. I think you have to rewrite this application for it work as you intend. You could:

    1. Define a buffer that you can use to store the data from the FIFO while it's processed. 

    2. The ble_app_uart example sends the data as soon as it receives a newline. This is not good for maximum throughput as it causes the application to send multiple ble packets without filling them completely up. The sending of data has some overhead, so preferably you would only want to do it when the ble packet is full. Try removing this check:

Children
No Data
Related