Hello Team Nordic,
I have a strange problem with the UART:
I am using nRF52840 with two UARTs: UART1 for Debug-Terminal and UART0 for communication with a GPS-Module.
Since the GPS Module is always sending data. but the CPU is normally sleeping and UART0 disabled. It may happen, that the CPU gets invalid charcaters during initialisation, which the UART handlers get as "NRF_SERIAL_EVENT_DRV_ERR".
In the "NRFX_UARTE.C" driver this error should be cleared. However, after the first Error, no more characters are received, even if format/baudrate is correct
- Is this a known issue?
- How can I clear an UART error?
// Recover from Errors (Problem? Does not work) void stu_clear_error_state(void){ ret_code_t ret; stu_stat.error_state=0; ret=nrf_serial_rx_drain(&std_uart); APP_ERROR_CHECK(ret); } // IRQ-handler is in 'nrfx_uarte.c' ca. Line 640, UART0 void std_uart_handler(struct nrf_serial_s const *p_serial, nrf_serial_event_t event){ switch(event){ case NRF_SERIAL_EVENT_DRV_ERR: stu_stat.error_state|=STU_STATE_EVTDRV_ERROR; #ifdef DEBUG stu_stat.drv_error_cnt++; #endif break; case NRF_SERIAL_EVENT_FIFO_ERR: stu_stat.error_state|=STU_STATE_FIFO_ERROR; #ifdef DEBUG stu_stat.fifo_error_cnt++; #endif break; case NRF_SERIAL_EVENT_RX_DATA: #ifdef DEBUG stu_stat.rx_data_cnt++; #endif break; case NRF_SERIAL_EVENT_TX_DONE: // Can be used for Manual HW-Flow #ifdef DEBUG stu_stat.tx_done_cnt++; #endif break; default: break; } }
This is from the NRFX_UART.C - Driver, ca. line 550:
static void uarte_irq_handler(NRF_UARTE_Type * p_uarte, uarte_control_block_t * p_cb) { if (nrf_uarte_event_check(p_uarte, NRF_UARTE_EVENT_ERROR)) { nrfx_uarte_event_t event; nrf_uarte_event_clear(p_uarte, NRF_UARTE_EVENT_ERROR); //**CLEAR ERROR?* event.type = NRFX_UARTE_EVT_ERROR; event.data.error.error_mask = nrf_uarte_errorsrc_get_and_clear(p_uarte); ...
Thanks for your help!
Best regards,
Jo