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

How to enable UARTE in nRF52840

Hi,

I need to use two uarts for the project requirement. UART0 is enabled and working successfully. And I am trying to initialize UARTE, but I am not getting any output on the pins if I probe. Here is my code:

        #define U_RXD ((1 << 5) | (3 & 0x1F))   //P1.03
        #define U_TXD ((1 << 5) | (4 & 0x1F))   //P1.04

        const  uint8_t buffer[4] = {0x41,0x42,0x43,0x44};
         NRF_UARTE_Type * u_reg;

         nrf_gpio_cfg_input(U_RXD,NRF_GPIO_PIN_NOPULL);
         nrf_gpio_cfg_output(U_TXD);
         nrf_gpio_pin_set(U_TXD);

        u_reg->CONFIG = NRF_UARTE_PARITY_EXCLUDED |  NRF_UARTE_HWFC_DISABLED;
        u_reg->PSEL.TXD = U_TXD;
        u_reg->PSEL.RXD = U_RXD;

   u_reg->BAUDRATE = NRF_UARTE_BAUDRATE_115200;
   u_reg->ENABLE = UARTE_ENABLE_ENABLE_Enabled;

    u_reg->TXD.PTR    = (uint32_t)buffer;
    u_reg->TXD.MAXCNT = 4;

     nrf_uarte_task_trigger(u_reg, NRF_UARTE_TASK_STARTTX);
      while(!nrf_uarte_event_check(u_reg, NRF_UARTE_EVENT_ENDTX) );

Help me if the configuration is wrong. Is it possible to use both UART0 and UARTE at a time?

Parents Reply Children
  • Looks like app_uart_fifo only supports running one of the UART instances at the same time. I.e. it will always use the APP_UART_DRIVER_INSTANCE that is configured in sdk_config.h

    code snippet from app_uart_fifo.c:

    static nrf_drv_uart_t app_uart_inst = NRF_DRV_UART_INSTANCE(APP_UART_DRIVER_INSTANCE);
    

    The underlying driver(nrf_drv_uart) supports multiple UART instances at the same time, but app_uart_fifo will need some modification to support running both UART instances at the same time.

  • Note that we have added a new library called serial that solves this problem.

    From release notes:

    Serial port library: Module for handling UART communication. It supports multibyte transfers, time-outs, and buffering of data. The module is a replacement for app_uart. See the usage example in examples/peripheral/serial

Related