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

Use 2 UARTE with SDK15

Hello,

I'm trying to configure 2 serial ports for a custom board with nRF52840 chip, but when I try to instance the second UART "NRF_SERIAL_UART_DEF(serial_uart1, 1);" the compiler raise an error.

../../../../../../modules/nrfx/drivers/include/nrfx_uart.h:79:35: error: 'NRF_UART1' undeclared here (not in a function); did you mean 'NRF_UARTE1'?

I had this code working with SDK14.2, but with SDK15 this doesn't work.

I've compiled the example peripheral/serial changing the id instance from 0 to 1 with the same result.

I've activated UART1 and UARTE1 in sdk_config.h

Can you help me with this problem.

Thanks.

Parents
  • Hi,

    Sure!

    That's right. UART1 is not supported. Serial peripheral with number 1 is only UARTE1 in nRF52840 SoC.

    Required changes

    To make it work with small amount of work please replace lines 77 and 78 in nRF5_SDK_15.0.0_a53641a\integration\nrfx\legacy\nrf_drv_uart.h file.

    Lines to change

    WIth code:

        #define NRF_DRV_UART_CREATE_UART(id)   _NRF_DRV_UART_CREATE_UART(id)
        #define _NRF_DRV_UART_CREATE_UART(id)  NRF_DRV_UART_CREATE_UART_##id
        #define NRF_DRV_UART_CREATE_UART_0  \
            .uart = NRFX_UART_INSTANCE(0),
        #define NRF_DRV_UART_CREATE_UART_1  \
            .uart = { .p_reg = NULL },

    To achieve:

    Lines changed

    It adds support for UARTE1 in nrf_drv_uart layer. 

    How to catch the case when UARTE1 is using without easydma support

    You can also add assert in nRF5_SDK_15.0.0_a53641a\integration\nrfx\legacy\nrf_drv_uart.c in line 115 to catch the case if somewhere UARTE1 is overriden to be used without EasyDMA support:

    Please add code below:

    #ifdef NRF52840_XXAA
        if (inst_idx == 1)
        {
            ASSERT(p_config->use_easy_dma);
        }
    #endif

    to achieve:

    NRF_SERIAL with UARTE1

    Please remember to use NRF_SERIAL_MODE_DMA when create instance for UARTE1 in nrf serial using NRF_SERIAL_CONFIG_DEF.

    NRF_SERIAL_CONFIG_DEF(serial_config, NRF_SERIAL_MODE_DMA,
                          &serial_queues, &serial_buffs, NULL, sleep_handler);

    I think it should help You. In case of any problem please let me know!

Reply
  • Hi,

    Sure!

    That's right. UART1 is not supported. Serial peripheral with number 1 is only UARTE1 in nRF52840 SoC.

    Required changes

    To make it work with small amount of work please replace lines 77 and 78 in nRF5_SDK_15.0.0_a53641a\integration\nrfx\legacy\nrf_drv_uart.h file.

    Lines to change

    WIth code:

        #define NRF_DRV_UART_CREATE_UART(id)   _NRF_DRV_UART_CREATE_UART(id)
        #define _NRF_DRV_UART_CREATE_UART(id)  NRF_DRV_UART_CREATE_UART_##id
        #define NRF_DRV_UART_CREATE_UART_0  \
            .uart = NRFX_UART_INSTANCE(0),
        #define NRF_DRV_UART_CREATE_UART_1  \
            .uart = { .p_reg = NULL },

    To achieve:

    Lines changed

    It adds support for UARTE1 in nrf_drv_uart layer. 

    How to catch the case when UARTE1 is using without easydma support

    You can also add assert in nRF5_SDK_15.0.0_a53641a\integration\nrfx\legacy\nrf_drv_uart.c in line 115 to catch the case if somewhere UARTE1 is overriden to be used without EasyDMA support:

    Please add code below:

    #ifdef NRF52840_XXAA
        if (inst_idx == 1)
        {
            ASSERT(p_config->use_easy_dma);
        }
    #endif

    to achieve:

    NRF_SERIAL with UARTE1

    Please remember to use NRF_SERIAL_MODE_DMA when create instance for UARTE1 in nrf serial using NRF_SERIAL_CONFIG_DEF.

    NRF_SERIAL_CONFIG_DEF(serial_config, NRF_SERIAL_MODE_DMA,
                          &serial_queues, &serial_buffs, NULL, sleep_handler);

    I think it should help You. In case of any problem please let me know!

Children
Related