This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART 1 cannot init

Hi

nrf52833 SDK16

The following code works fine on UART 0 but not on UART 1

    
    
    nrf_drv_uart_t SER_UART = NRF_DRV_UART_INSTANCE(1);

    nrf_drv_uart_config_t config = NRF_DRV_UART_DEFAULT_CONFIG;
    config.baudrate = 1200;
    config.hwfc = NRF_UART_HWFC_DISABLED;
    config.interrupt_priority = APP_IRQ_PRIORITY_HIGH;
    config.parity = NRF_UART_PARITY_EXCLUDED;
    config.pselrxd = IO_UART_RX;
    config.pseltxd = IO_UART_TX;


    APP_ERROR_CHECK(nrf_drv_uart_init(&SER_UART, &config, SER_UART_Interrupt));

The problem seems to come from nrfx_uart.c

#if NRFX_CHECK(NRFX_PRS_ENABLED)
    static nrfx_irq_handler_t const irq_handlers[NRFX_UART_ENABLED_COUNT] = {
        #if NRFX_CHECK(NRFX_UART0_ENABLED)
        nrfx_uart_0_irq_handler,
        #endif
    };
    if (nrfx_prs_acquire(p_instance->p_reg,
            irq_handlers[p_instance->drv_inst_idx]) != NRFX_SUCCESS)
    {
        err_code = NRFX_ERROR_BUSY;
        NRFX_LOG_WARNING("Function: %s, error code: %s.",
                         __func__,
                         NRFX_LOG_ERROR_STRING_GET(err_code));
        return err_code;
    }
#endif // NRFX_CHECK(NRFX_PRS_ENABLED)

There is no support for a UART1, so nrf_prs_acquire() will fail on the

NRFX_ASSERT(p_base_addr);

Also nrf_uart.c lacks support for uart 1 in the irq_handler section:

#if NRFX_CHECK(NRFX_UART0_ENABLED)
void nrfx_uart_0_irq_handler(void)
{
    uart_irq_handler(NRF_UART0, &m_cb[NRFX_UART0_INST_IDX]);
}
#endif

How am I meant to get two uarts working with this part? id nrfx a bad option?

Many thanks

Parents
  • Hi,

    There is no legacy UART for instance 1 (UART1), only UART0 support legacy UART. In order to use the second UART instance, you need to use UARTE1, UART with EasyDMA support.

    You can either use nrfx_uarte, or it should also be possible to use the legacy UART driver (nrf_drv_uart) if it is configured correctly. If you do not need both legacy and EasyDMA support, you can disable to PRS for UART (set NRFX_PRS_BOX_4_ENABLED to 0 in sdk_config.h), and then remove legacy UART driver from the project (nrfx_uart.c) and disable legacy support in legacy UART driver in sdk_config.h by setting UART_LEGACY_SUPPORT to 0.

    Best regards,
    Jørgen

Reply
  • Hi,

    There is no legacy UART for instance 1 (UART1), only UART0 support legacy UART. In order to use the second UART instance, you need to use UARTE1, UART with EasyDMA support.

    You can either use nrfx_uarte, or it should also be possible to use the legacy UART driver (nrf_drv_uart) if it is configured correctly. If you do not need both legacy and EasyDMA support, you can disable to PRS for UART (set NRFX_PRS_BOX_4_ENABLED to 0 in sdk_config.h), and then remove legacy UART driver from the project (nrfx_uart.c) and disable legacy support in legacy UART driver in sdk_config.h by setting UART_LEGACY_SUPPORT to 0.

    Best regards,
    Jørgen

Children
No Data
Related