UARTE

In UART async mode (CONFIG_UART_ASYNC_API=y) the UART transmit data and receive callback works fine. I've been able to set up the callback and enable the rx.

After switching to UARTE (CONFIG_NRFX_UARTE0=y), the UART transmit once, but the event handler is never called.

UARTE is set up like example from: "C:\ncs\v2.0.0\zephyr\samples\boards\nrf\nrfx_prs\src\main.c", the baudrate is set to 9600. nrfx_uarte_init() and nrfx_uarte_tx() show NRFX_SUCCESS. When nrfx_uarte_tx_in_progress() call is added, just after nrfx_uarte_tx(),  nrfx_uarte_tx_in_progress() hangs without any further (log) message.

Is it possible to implement UARTE like this on nRF9160 development board?

Do you need to enable rx on UARTE?

Is there any working sample for nRF9160?

Parents Reply Children
  • // UARTE set up
    PINCTRL_DT_DEFINE(CONSOLE_NODE);

    nrfx_err_t nrfxError;
    nrfx_uarte_config_t uarte_config = NRFX_UARTE_DEFAULT_CONFIG(NRF_UARTE_PSEL_DISCONNECTED, NRF_UARTE_PSEL_DISCONNECTED);

    uarte_config.baudrate = NRF_UARTE_BAUDRATE_9600;
    uarte_config.skip_gpio_cfg = true;
    uarte_config.skip_psel_cfg = true;

    iReturn = pinctrl_apply_state(PINCTRL_DT_DEV_CONFIG_GET(CONSOLE_NODE), PINCTRL_STATE_DEFAULT);
    if(iReturn != 0) {
    LOG_ERR("pinctrl_apply_state() failed: 0x%08x", iReturn);
    }

    nrfxError = nrfx_uarte_init(&uarte, &uarte_config, uarte_handler);
    if(nrfxError != NRFX_SUCCESS) {
    LOG_ERR("nrfx_uarte_init() failed: 0x%08x", nrfxError);
    }

    // UARTE transmit
    nrfx_err_t nrfxError;

    nrfxError = nrfx_uarte_tx(&uarte, p, u8Cnt);
    if(nrfxError == NRFX_SUCCESS) {
    if(nrfx_uarte_tx_in_progress(&uarte)) {
    bTransmitted = true;
    } else {
    LOG_ERR("nrfx_uarte_tx_in_progress(): UARTE is not transmitting");
    }
    } else {
    LOG_ERR("nrfx_uarte_tx() failed: 0x%08x", nrfxError);
    }

    // UARTE callback
    static void uarte_handler(const nrfx_uarte_event_t *p_event, void *p_context)
    {
    if (p_event->type == NRFX_UARTE_EVT_RX_DONE) {
    iReceived = p_event->data.rxtx.bytes;
    } else if (p_event->type == NRFX_UARTE_EVT_ERROR) {
    iReceived = 0;
    }
    }

  • Elbert said:
    nrfxError = nrfx_uarte_init(&uarte, &uarte_config, uarte_handler);

    How is "uarte" defined?

  • static nrfx_uarte_t     uarte   = NRFX_UARTE_INSTANCE(0);
  • Did you disable logging? Maybe you can try a different uart instance.

  • Logging was enabled and both nrfx_uarte_init() and nrfx_uarte_tx() show NRFX_SUCCESS. The problem is that the uarte_handler() is never hit and function call nrfx_uarte_tx_in_progress() hangs.

    With nrf9160-dk and standard uart0 implementation (UART API) transmit and receive data works, so I expect UARTE should also work at uart0.

    Is there a working UARTE example on nrf9160-dk available?

Related