This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UARTE missed ISR ENDRX or generated excess ISR RXSTARTED

[Environment]

nrf52833 chip, NCS 1.6.0

using uarte 1 with async API, baudrate 1Mbps, CONFIG_UART_1_NRF_HW_ASYNC=y and CONFIG_UART_1_NRF_HW_ASYNC_TIMER=2.

using ring buffer put in user callback.

Relate page but not answered: devzone.nordicsemi.com/f/nordic-q-a/78419/zephyr-uarte-library-missing-uart_rx_buf_released-events

[CASE]

set rx dma buffer size 20 bytes, timeout 5ms. (PS: small value to catch CASE easiler, lager value can reduce the probability of CASE but still happen.)

sent plenty of bytes to uarte1 rx, minutes later we catched a case:

6748 ENDRX events generated and handled.

6750 RXSTARTED events generated and 6749 were handled.

The No. 6750 RXSTARTED event was failed to handle while @uart_nrfx_uarte: uarte_nrfx_rx_buf_rsp() was called an return with error -16 (-EBUSY), whtich means rx_next_buf is not empty.

In other words, UARTE1 generated an excess RXSTARTED event or missed an ENDRX event.

  • Here is a scene appeared quiet easy:

    [CASE]

    16535 ENDRX events and 16536 RXSTARTED events were handled.

    an error was generated while NO.16537 RXSTARTED event was handling.

      

    [call stacks]

    _isr_wrapper -> uarte_nrfx_isr_async -> rx_started_isr -> uart_event_handler -> uarte_nrfx_rx_buf_rsp err: -EBUSY.

      

    [reg tables]

    @before NO.16535 ENDRX event was handled:

    EVENT_ENDRX = 1, EVENT_RXSTARTED = 1, SHORTS = 0x20, INTEN = 0x4A0210, INTENSET = 0x4A0210, INTENCLR = 0x4A0210, RXD.PTR=0x200082D4

    @after NO.16535 ENDRX event was handled:

    EVENT_ENDRX = 0, EVENT_RXSTARTED = 1, SHORTS = 0, INTEN = 0x4A0210, INTENSET = 0x4A0210, INTENCLR = 0x4A0210, RXD.PTR=0x200082D4

      

    @before NO.16536 RXSTARTED event was handled:

    EVENT_ENDRX = 0, EVENT_RXSTARTED = 1, SHORTS = 0, INTEN = 0x4A0210, INTENSET = 0x4A0210, INTENCLR = 0x4A0210, RXD.PTR=0x200082D4

    @after NO.16536 RXSTARTED event was handled:

    EVENT_ENDRX = 0, EVENT_RXSTARTED = 0, SHORTS = 0x20, INTEN = 0x4A0210, INTENSET = 0x4A0210, INTENCLR = 0x4A0210, RXD.PTR=0x200082C0

      

    @before NO.16537 RXSTARTED event was handled:

    EVENT_ENDRX = 1, EVENT_RXSTARTED = 1, SHORTS = 0x20, INTEN = 0x4A0210, INTENSET = 0x4A0210, INTENCLR = 0x4A0210, RXD.PTR=0x200082C0

    Here is a  doubt:

    After Rx is enabled, in most cases ENDRX generated first and RXSTARTED generated right behind ENDRX.

    But now RXSTARTED event generated before ENDRX, and ENDRX generated right behind RXSTARTED.

    Thus ISR missed to handling ENDRX, just went to handle RXSTARTED first.

    @after NO.16536 RXSTARTED event was handling with  [CASE]:

    EVENT_ENDRX = 1, EVENT_RXSTARTED = 0, SHORTS = 0x20, INTEN = 0x4A0210, INTENSET = 0x4A0210, INTENCLR = 0x4A0210, RXD.PTR=0x200082C0

     

  • I reproduced the [CASE] in the NCS 1.6.0 sample: nrd/samples/bluetooth/peripheral_uart.

    Here are the environment:

    1. modify *.overlay:

        set uart1 baudrate 1Mbps for data tx/rx, and uart0 921600 for logging.

    2. modify prj.conf:

        CONFIG_NRFX_UARTE1=y, CONFIG_UART_1_NRF_HW_ASYNC=y, CONFIG_UART_1_NRF_HW_ASYNC_TIMER=2.

        CONFIG_HEAP_MEM_POOL_SIZE=4096

        CONFIG_USE_SEGGER_RTT=n, CONFIG_LOG_BACKEND_RTT=n, CONFIG_LOG_BACKEND_UART=n.

    3. modify nrf/samples/bluetooth/peripheral/src/main.c:

        comment out ble related function call in main().

        set uart_init() binding to uart1.

        set UART_BUF_SIZE=20U and UART_WAIT_FOR_RX=5U;

        create thread rx_task() to count total recv bytes and release buffer.

        create thread tx_task() to send bytes as 20Byte 20Hz and count send bytes.

        check the return value of uart_rx_buf_rsp() function.

    4. run this sample on DK board.

    5. send 267 bytes string to uarte1 rx in 100Hz.

    6. Minutes later, An error return from uart_rx_buf_rsp() and them uarte1 rx always missed bytes in recving string.

  • Enlarge UART_BUF_SIZE and UART_WAIT_FOR_RX  value could reduce the probability of [CASE] happening.

    But it always happens.

  • I think this issue was fixed in this commit and is available in v1.7.0. Can you please use this version to see if you still have this issue?

Related