Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_serial_read() stops receiving data after some time.

Hi,

I am using nrf52840 dk. Also, I am using nrf_serial library with DMA mode for uart communication. I have a continuous loop running in main and there i read data using nrf_serial_read() with timeout set to 0. I have to read continuous polling message and then response. For sometime the data is received perfectly but then it suddenly stops to receive data giving read count passed to nrf_serial_read() zero. Moreover, after I stop receiving data I checked if event is generated at uart_event_handler() in nrf_serial.c, but no rx_done event is encountered in uart_event_handler().

  • Hi,

    The framing error is encountered only when I read uart data continuously in main loop. In another sample code created using serial example, reading uart data in event handler, this error is not encountered for same rx data.  All other things are same. In serial example, I have just removed the while loop and read data in event handler. Moreover due to framing error, on nrf_serial_drv_err event i need to re initialize serial ( uart) and the error is quite frequent so it causes a high percentage of packet loss. All other configurations are same, also the setup is same. What could be the possible reason for this? Also, is there an alternative to handle this error?

    Thanks and Regards,

    Prerit Choksi

  • Hi

    I would recommend reading your data from an event handler, as using rx_read in your main() is ineffective. Also, what is your ERRORSRC register value? I am having trouble understanding what is wrong here as well.

    Best regards,

    Simon

  • Hi,

    I have read ERRORSRC on each nrf_drv_uart_evt_error and it reads out 4 (framing error). Also, what I found is, on read event (NRF_DRV_UART_EVT_RX_DONE) the uart_event_handler in nrf_serial.c reads data and puts it in queue and then generates serial rx event (NRF_SERIAL_EVENT_RX_DATA). So this already is a kind of polling. Moreover, I am pretty sure my data is not going to overflow this queue before i read it continuously in main(). So I guess directly using nrf_serial_rx in main() will make it more efficient and decrease some complexity for me.

    Thanks and Regards,

    Prerit Choksi

Related