error codes for APP_UART_COMMUNICATION_ERROR

I'm seeing a few of these errors in my uart evt handler

I cannot seem to find where these are enumerated in app_uart_fifo.c or nnrf_drv_uart.h or nrfx_uarte.h.

Question 1 - Where can I find these?  

<error> app: APP_UART_COMMUNICATION_ERROR : 1 00
<error> app: APP_UART_COMMUNICATION_ERROR : 5 00
<error> app: APP_UART_COMMUNICATION_ERROR : 4 00

Here is the code generating that log - 

NRF_LOG_ERROR("APP_UART_COMMUNICATION_ERROR : %d %02x", p_event->data.error_code, NRF_UARTE0->ERRORSRC);
When this happens, I try to run
app_uart_flush();
app_uart_close();
APP_UART_FIFO_INIT();


Question 2 - Is there a better way to recover? 
Thanks!
Parents Reply Children
  • The double digit hex value is the ERRORSRC register in my log. 

    Thanks for pointing that out. However, it doesn't make sense that the error is 0 as the APP_UART_COMMUNICATION_ERROR event is only triggered after a "NRF_UARTE_EVENT_ERROR" event. The nrf52840 uart has 2 uarte instances, could it be that the app uart library is using the other instance in your code?

    am considering trying nrfx_uarte to see if this still happens

    I'm afraid this won't help if there really is a communication error detected by the UART hw. app uart library is also built on top of this driver already.

  • From sdk_config - 
    #define APP_UART_DRIVER_INSTANCE 0

    I'm afraid this won't help if there really is a communication error detected by the UART hw. app uart library is also built on top of this driver already.

    Does app uart use DMA? 
    Thanks Vidar
  • UARTwith easyDMA is used by default, but it only uses '1' byte RX buffers. Are you able to share a code snippet showing revelant parts of your app uart callback?

  • Yup!

    Just to note - I am seeing some overruns. Data is definitely getting lost

    <error> app: APP_UART_COMMUNICATION_ERROR : 1 01
    <error> app: APP_UART_COMMUNICATION_ERROR : 1 00

    static void uart_handler(app_uart_evt_t *p_event) {
        switch (p_event->evt_type) {
            case APP_UART_DATA_READY: {
                uint32_t ret;
                do {
                    ret = app_uart_get(&(rx_buf[rx_tail]));
                    if (NRF_SUCCESS == ret) {
                        rx_tail++;
                        rx_tail %= UART_RX_BUF_SIZE;
                    } else {
                        // NRF_LOG_ERROR("ret: %02x", ret);
                    }
                } while (ret == NRF_SUCCESS);
            
                app_sched_event_put(NULL, 0, process_data);    
                break;
            }
            case APP_UART_COMMUNICATION_ERROR:
                NRF_LOG_ERROR("APP_UART_COMMUNICATION_ERROR : %d %02x", p_event->data.error_code, NRF_UARTE0->ERRORSRC);
                app_uart_flush();
                Flush_Uart();
                uart_busy = 0;
                break;
            case APP_UART_FIFO_ERROR:
                NRF_LOG_ERROR("APP_UART_FIFO_ERROR");
                break;
            case APP_UART_TX_EMPTY:
                break;
            case APP_UART_DATA:
                NRF_LOG_ERROR("APP_UART_DATA");
                break;
            default:
                NRF_LOG_ERROR("default");
        } 
    }
    

  • Thank you. I see the problem now. So ERRORSRC register is being cleared from the nrfx_uarte.c->uarte_irq_handler() handler before it calls your uart_handler():

    So the UART and the app are basically not able to keep up with the reception speed. Is using HW flow control an option?

Related