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

    sorry for the late reply.
    Thank you for your response.
    I tried to set UART_TX_BUF_SIZE and UART_RX_BUF_SIZE 4096 but did not get better.
    The IRQ priority set by UART_INIT did not want to change the priority.
    (APP_IRQ_PRIORITY_HIGHEST, APP_IRQ_PRIORITY_HIGH, APP_IRQ_PRIORITY_MID did not work:Hanged)

    Eliminate CR / LF reception from the condition that sends to BLE, add it
    By setting MIN_CONN_INTERVAL to 8 and MAX_CONN_INTERVAL
    UART The missing data missing is not zero but improved.

    It is likely to reply because it works on this work,
    I will try if I can improve a little more.


    Before correction:

    void uart_event_handle(app_uart_evt_t * p_event)
    {
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint8_t index = 0;
    uint32_t err_code;

    switch (p_event->evt_type)
    {
    case APP_UART_DATA_READY:
    UNUSED_VARIABLE(app_uart_get(&data_array[index]));
    index++;

    if ((data_array[index - 1] == '\n') || // <- Remove
    (data_array[index - 1] == '\r') || // <- Remove
    (index >= m_ble_nus_max_data_len))
    {
    if (index > 1)
    {
    NRF_LOG_DEBUG("Ready to send data over BLE NUS");
    NRF_LOG_HEXDUMP_DEBUG(data_array, index);

    do
    {
    uint16_t length = (uint16_t)index;
    err_code = ble_nus_data_send(&m_nus, data_array, &length, m_conn_handle);


    Revised:

    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++;

    regards
    Matsumiya
  • Hi,

    Have you disabled APP_UART_COMMUNICATION_ERROR and APP_UART_FIFO_ERROR in uart_event_handle()? The application should assert if the FIFO gets full. On a second thought, can you use uart flow control in your project?

    regards

    Jared 

Reply Children
No Data
Related