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

nrf52840 uart rx problem

hi, i've been trying to use uart in non-blocking mode (events available). Configuretion is the following: i have specify RX buffer (128 bytes) in init function, and in order to get to NRF_DRV_UART_EVT_RX_DONE every 10ms call  nrf_drv_uart_rx_abort(&uart_inst). In event: check the number of bytes (event->data.rxtx.bytes),copy the contest of rx buffer (that i specified earlier) and agan specify the same rx buffer. The problem is the following: periodically i trapped in NRF_DRV_UART_EVT_ERROR event and check event->data.error.error_mask, the value is 4, which i suppose to mean framing error. How to fix this, please any help. Uart baudrate is 115200. Is it save approach to call nrf_drv_uart_rx_abort() to stop uart receive process? The abort function can be called any time during receiving process, even when the current byte doesn't completely received, am i right?

  • I suggest you look into the experimental libuarte library as it has already implemented similar functionality, but double/triple buffered. See sdk15.3\components\libraries\experimental_libuarte.

    You can call nrf_drv_uart_rx_abort whenever you like, but you might get framing errors. The only way to deal with framing errors is to uninitialize and re-intialize the uart driver. 

Related