nrfx_uarte tx_rx_non_blocking not work (nRF5340)

I'm just trying this sample: nrfx_uarte tx_rx_non_blocking, but this is what I can see in the terminal. Why those errors?

[00:00:00.253,479] <inf> NRFX_EXAMPLE: Starting nrfx_uarte non-blocking example.

[00:00:00.261,322] <inf> NRFX_EXAMPLE: Content of TX buffer: Nordic Semiconductor

[00:00:00.261,352] <inf> NRFX_EXAMPLE: Content of RX buffer:

[00:00:00.275,421] <inf> NRFX_EXAMPLE: UARTE event: 3

ASSERTION FAIL [p_cb->state == NRFX_DRV_STATE_INITIALIZED] @ WEST_TOPDIR/modules/hal/nordic/nrfx/drivers/src/nrfx_uarte.c:1628

[00:00:00.275,970] <err> os: r0/a1:  0x00000004  r1/a2:  0x0000065c  r2/a3:  0x00000002

[00:00:00.275,970] <err> os: r3/a4:  0x00000000 r12/ip:  0x00000014 r14/lr:  0x000077d1

[00:00:00.276,000] <err> os:  xpsr:  0x69000000

[00:00:00.276,000] <err> os: Faulting instruction address (r15/pc): 0x0000ade2

[00:00:00.276,031] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0

[00:00:00.276,062] <err> os: Current thread: 0x20000860 (unknown)

Parents
  • Hello,

    I ran a short debugging session and found that nrfx_uarte_uninit() is called before NRFX_UARTE_EVT_RX_BUF_REQUEST which leads to the Assertion fail and Fatal error.

    I got the sample to work by moving the uninitialization function in uarte_handler() to the NRFX_UARTE_EVT_TX_DONE if statement, but I haven't verified if this is a proper solution. It is a potential workaround for now though.

    This is the edited uarte_handler():

    static void uarte_handler(nrfx_uarte_event_t const * p_event, void * p_context)
    {
        nrfx_uarte_t * p_inst = p_context;
        if (p_event->type == NRFX_UARTE_EVT_TX_DONE)
        {
            NRFX_LOG_INFO("--> UARTE event: TX done");
            NRFX_LOG_INFO("Content of TX buffer: %s", m_tx_buffer);
            NRFX_LOG_INFO("Content of RX buffer: %s", m_rx_buffer);
            nrfx_uarte_uninit(p_inst);
        }
        else
        {
            NRFX_LOG_INFO("UARTE event: %d", p_event->type);
        }
    }

    Best regards,

    Maria

Reply
  • Hello,

    I ran a short debugging session and found that nrfx_uarte_uninit() is called before NRFX_UARTE_EVT_RX_BUF_REQUEST which leads to the Assertion fail and Fatal error.

    I got the sample to work by moving the uninitialization function in uarte_handler() to the NRFX_UARTE_EVT_TX_DONE if statement, but I haven't verified if this is a proper solution. It is a potential workaround for now though.

    This is the edited uarte_handler():

    static void uarte_handler(nrfx_uarte_event_t const * p_event, void * p_context)
    {
        nrfx_uarte_t * p_inst = p_context;
        if (p_event->type == NRFX_UARTE_EVT_TX_DONE)
        {
            NRFX_LOG_INFO("--> UARTE event: TX done");
            NRFX_LOG_INFO("Content of TX buffer: %s", m_tx_buffer);
            NRFX_LOG_INFO("Content of RX buffer: %s", m_rx_buffer);
            nrfx_uarte_uninit(p_inst);
        }
        else
        {
            NRFX_LOG_INFO("UARTE event: %d", p_event->type);
        }
    }

    Best regards,

    Maria

Children
No Data
Related