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
  • Hi,

    The nRF52840 have 2 UART Peripherals. The first one can be configured to be used either with or without EasyDMA(either as UARTE0 or UART0), while the second one can only be configured with EasyDMA (UARTE1).


    I would strongly recommend you to you use the UART drivers in the SDK. You can find an example on how to use it in the folder SDK_folder\examples\peripheral\uart\. Remember to enable both UART instances in sdk_config.h if you want to use both peripherals. The latest SDK version can be downloaded from here.

Reply
  • Hi,

    The nRF52840 have 2 UART Peripherals. The first one can be configured to be used either with or without EasyDMA(either as UARTE0 or UART0), while the second one can only be configured with EasyDMA (UARTE1).


    I would strongly recommend you to you use the UART drivers in the SDK. You can find an example on how to use it in the folder SDK_folder\examples\peripheral\uart\. Remember to enable both UART instances in sdk_config.h if you want to use both peripherals. The latest SDK version can be downloaded from here.

Children
No Data
Related