NRFX UARTE TX failure (using nRF connect SDK v2.1.0)

I am trying to implement a simple uart echo test using nRF21540 DB board, but I always get NRFX_ERROR_FORBIDDEN when trying to transmit.

This is the initialization code:

    nrfx_uarte_t        uarteInstance = NRFX_UARTE_INSTANCE( 1 );
    
    uarteConfig.pseltxd = nRF52Host_TX_DBG;
    uarteConfig.pselrxd = nRF52Host_RX_DBG;
    uarteConfig.pselcts = NRF_UARTE_PSEL_DISCONNECTED;
    uarteConfig.pselrts = NRF_UARTE_PSEL_DISCONNECTED;
    uarteConfig.p_context = NULL;
    uarteConfig.baudrate = NRF_UARTE_BAUDRATE_9600;
    uarteConfig.interrupt_priority = NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY;
    uarteConfig.hal_cfg.hwfc = NRF_UARTE_HWFC_DISABLED;
    uarteConfig.hal_cfg.parity = NRF_UARTE_PARITY_EXCLUDED;
    uarteConfig.hal_cfg.stop = NRF_UARTE_STOP_ONE;
    uarteConfig.skip_gpio_cfg = false;
    uarteConfig.skip_psel_cfg = false;
    
    if (nrfx_uarte_init(&uarteInstance, &uarteConfig, NULL) == NRFX_SUCCESS)
    {
        printf("success\r\n");
    }

then trying to transmit using this call, is always returning error:

    static uint8_t test_bytes[4] = {0xA5, 0xA6, 0xA7, 0xA8};

    nrfx_uarte_tx(&uarteInstance, test_bytes, 4);

Is there some configuration I am missing?

  • Hello,

    Could you please show the entire log where you receive the error code?
    I notice that the nrfx_uarte_tx call does not check its return value. Is this the exact section of the code that returns the error, or could it be returned elsewhere?
    What other peripherals are you using concurrently in your project, are there any other serial interfaces enabled when this happens? If so, which, and which instances are they running on?

    Best regards,
    Karl

  • Hi, thanks for your answer

    This is the log where I get the error code:

    Function: nrfx_uarte_tx, error code: NRFX_ERROR_FORBIDDEN.failed!

    I am checking the error code returned by nrfx_uarte_tx, that´s where I get the error.

    I am using QSPI, SPI and a couple of GPIOs. Then zephyr shell uart is enabled, using UART0.

  • Hello again,

    Hugo.Dev said:
    thanks for your answer

    No problem, I am happy to help! :) 

    Hugo.Dev said:

    This is the log where I get the error code:

    Function: nrfx_uarte_tx, error code: NRFX_ERROR_FORBIDDEN.failed!

    I am checking the error code returned by nrfx_uarte_tx, that´s where I get the error.

    I am using QSPI, SPI and a couple of GPIOs. Then zephyr shell uart is enabled, using UART0.

    Thank you for elaborating.
    Which instances are you using for the QSPI/SPI?
    The call to nrfx_uarte_tx fails with NRFX_ERROR_FORBIDDEN when you have not provided a handler to your UARTE peripheral during initialization, which means you are using it in blocking mode, and then triggering a TXSTOP task before the call to TX has completed.
    Are you triggering this manually elsewhere in the code, perhaps to reduce power consumption?
    If not, does this happen every time you attempt to call nrfx_uarte_tx? Does the call to nrf_uarte_event_check always return true when you debug this issue?

    Best regards,
    Karl

  • Hi.

    I am trying to use it in blocking mode. But tried providing handler too and it is failing in a different way.

    Talking about blocking mode, I am not triggering TXSTOP. And yes, it happens every time, the call to nrf_uarte_event_check(p_instance->p_reg, NRF_UARTE_EVENT_TXSTOPPED) returns always true.

    I am using SPI0 and QSPI (afaik there is only one, just enabling it with CONFIG_NRFX_QSPI=y)

  • Hugo.Dev said:
    I am trying to use it in blocking mode. But tried providing handler too and it is failing in a different way.

    Could you elaborate on how it fails in this case?

    Hugo.Dev said:
    Talking about blocking mode, I am not triggering TXSTOP. And yes, it happens every time, the call to nrf_uarte_event_check(p_instance->p_reg, NRF_UARTE_EVENT_TXSTOPPED) returns always true

    Are you using the power manager in your application?

    Best regards,
    Karl

Related