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

Conditions under which NRF_SERIAL_EVENT_RX_DATA is sent?

OK, a bit of confusion somebody can clear up for me, I hope;

Does NRF_SERIAL_EVENT_RX_DATA get sent when there is ANY data in the RX buffer, or only when the RX buffer is full?

And if the later, does the FIFO keep receiving data during any processing dead time in handling that event?

What I want to do is several reads of differing length as I have a Start of Frame followed by a length, and I would ideally read two characters, extract the length, and then read the rest of them.  However, if I have to take one event per character, the processor is fast enough to manage.  I just need to know which situation I have to expect.

Thanks in advance!!

-Ben Burch

BTR Controls, Inc.

  • Hello Ben,

    if you look in nrf_serial.c, you can see the uart_event_handler(). NRF_DRV_UART_EVT_RX_DONE is issued on every UART byte. The rest of the logic is in the source code.

    I haven't used nrf_serial too much, but it doesn't look like it fits your needs. If you want events only on UART timeout, or when an RX buffer is full, you should look into the example:

    SDK16\examples\peripheral\libuarte.

    This one has a buffer that is filling up, and only sends the RX complete event to the main application when either it hasn't received a byte for a while, or when the RX buffer is full. Like in this example, it is possible to study the source code for the libraries to see how this is done.

    Best regards,

    Edvin

  • Well, if nrf_serial does call on each byte then this works for me.  HOWEVER, I am now in the situation that though I can send data out the UART, no input is ever seen.  I do not ever get events at NRF_DRV_UART_EVT_RX_DATA though I do get them at the TX_DONE branch when my initial send completes.  Any thoughts on this?  The nrf_serial_init succeeded, obviously, or we would never emit the start string.  How can I determine what is up with the RX side of things?

  • If I implement a uarte read using a blocking mode, does this block starve the softdevice?

  • If you want a simple uart example with the softdevice, I suggest that you check out the ble_app_uart example. 

    What HW do you use? Is it an nRF52840 DK, or a custom board? Are you able to debug the application, or do you have access to the log? In that case, do you use the correct baudrate?

    Try the ble_app_uart example. Follow the instructions in the description for the example. Do you not get any RX events here either?

    Best regards,

    Edvin

  • OK, I Set up the BLE UART example.  I connected P1.05 and P1.06 to the ttl/serial module I am testing with.  I remapped those pins like so;

    #define RX_PIN_NUMBER NRF_GPIO_PIN_MAP(1,5)
    #define TX_PIN_NUMBER NRF_GPIO_PIN_MAP(1,6)

    I start the example and see "UART Started." printed to my terminal.

    I enter the number sequence in the read function, and the 0123456789 is
    printed.

    I then try typing on the terminal and I get no notify detection. Is there some
    magic to using the USB COM device here? The use case is we connect that UART
    to another processor on the same board.

    As for which device; This is a Rigado BMD-340 eval board, which I treat as a
    00056 type device.

    Thanks!!
Related