I have a question regarding the nrf52 UARTE driver. I have the basics setup and working, I can send and receive data using the UARTE.
What I need to do now, is find a way to receive incoming data BEFORE the rx buffer is full (if incoming data stops coming)
I start a dma reception with a rx buffer of size 10.
Then I receive 5 bytes on the uart, and nothing more. I don't want to wait (forever?) for another 5 bytes to fill up the buffer, but rather (after a certain timeout) receive the 5 bytes.
On other platforms this can be done for example by configuring a rx timeout in the driver/hw, or by letting a hw timer monitor the rx buffer and stop the reception after a certain time if no new data has arrived.
Any hints on how I can do this on the nRF52 platform?
Unfortunately, there is no way to do this only with the UARTE peripheral.
A solution is to connect GPIOTE IN event to the UARTE RX pin and reset a timer when there is any activity on the pin. If…
Newtom: There is a nrf_drv_uart_rx_abort command which does what you want, stops the reception and gives you the received bytes (in the same event as when the dma buffer is full)
yes it would be awesome to implement that soon in the SDK driver !!!!
we are planning to work in the future projects more with Nordic
A solution is to connect GPIOTE IN event to the UARTE RX pin and reset a timer when there is any activity on the pin. If the timer reaches a certain timeout, you know that there have been no data received for that time and you can flush the DMA buffer.
We are working on implementing this in the SDK driver.
Ole, I still would have two questions to your solution for the meantime. First, by flushing the DMA buffer you mean discarding the bytes in the non-full buffer or fetching them? If the latter, how to do that? Second, can you please explain (or at least give a good pointer to the documentation on) how to connect the GPIOTE IN event to the UARTE RX pin to reset a timer? Thank you!