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

UARTE nrf_drv_uart_rx_abort() not generating NRF_SERIAL_EVENT_RX_DATA

Hi,

I am using Uart1 on nrf52840. This is implemented using nrf_serial library. I have set buffer size to say 10, so event occurs on every 10 bytes reception. Now I want to receive last remaining data say of 3 bytes, i abort receiving using nrf_drv_uart_rx_abort() but cant get NRF_SERIAL_EVENT_RX_DATA event. However if I use uart instead of uarte i get the rx data event.

  • I understand what you intend to do, but I don't see any easy way of doing it. Once you are using the serial library, then it is not intended to use the driver directly, since that may affect the state and buffers of the library that is using the same driver. The serial library do have some limitations. But to try to look into this, how do you for instance ensure that nrf_drv_uart_rx_abort() is called after the next 3 bytes are received? Looking at the uart_event_handler() implementation I notice that the nrf_drv_uart_rx() is called after the NRF_SERIAL_EVENT_RX_DATA event is passed to the application, swapping these two lines could be interesting.

    Overall I think using the driver directly without the serial library may be a better idea if you need to control this the way you describe.

    Best regards,
    Kenneth

  • I understand what you intend to do, but I don't see any easy way of doing it. Once you are using the serial library, then it is not intended to use the driver directly, since that may affect the state and buffers of the library that is using the same driver. The serial library do have some limitations. But to try to look into this, how do you for instance ensure that nrf_drv_uart_rx_abort() is called after the next 3 bytes are received?

    Overall I think using the driver directly withtout the serial library may be a better idea if you need to control this the way you describe.

    Best regards,
    Kenneth

  • Alternatively I would recommend to try nrf_libuarte_async driver for UARTE and lossless reception without HWFC. There are experimental_cli_libuarte and experimental_libuarte example in the SDK that show usage. They are labelled experimental due to lack of documentation but it has been thoroughly tested. The stability and quality of the libuarte is very goodThe libuarte library requires one TIMER, one RTC or TIMER, couple of PPI channels (~3 if recall correctly). It is using TIMER via PPI to count exact number of bytes received without stopping uarte.

    Best regards,
    Kenneth

Related