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

Need to use 2 UARTS on nrf52840

Hi everyone

The following code is initiaizing the uarts correctly,but there is unpredictable behaviour in this case.

Whenever i disable the 1 UART sensor, works fine.

but on enabling both uart sensor , one of the sensor gets stucked.

Is this code fine to use 2 uarts?

void uart_init_terra(int pin_rx,int pin_tx)
{
uint32_t err_code;

    bsp_board_init(BSP_INIT_LEDS);

    const app_uart_comm_params_t comm_params =
      {
          pin_rx,
          pin_tx,
          24,//RTS_PIN_NUMBER,
          25,//CTS_PIN_NUMBER,
          UART_HWFC,
          false,
#if defined (UART_PRESENT)
          NRF_UART_BAUDRATE_57600
#endif
      };

    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);
    if(err_code==0)
     SEGGER_RTT_printf(0,"UART ERROR CODE :%d\r\n",err_code);
     else
     SEGGER_RTT_printf(0,"UART ERROR CODE :%d\r\n",err_code);
    APP_ERROR_CHECK(err_code);
    APP_ERROR_CHECK(err_code);


}

void uart_init_terra_copy(int pin_rx,int pin_tx)
{
uint32_t err_code;

    bsp_board_init(BSP_INIT_LEDS);

    const app_uart_comm_params_t comm_params =
      {
          pin_rx,
          pin_tx,
          24,//RTS_PIN_NUMBER,
          25,//CTS_PIN_NUMBER,
          UART_HWFC,
          false,
#if defined (UART_PRESENT)
          NRF_UART_BAUDRATE_19200
#endif
      };

    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);

       if(err_code==0)
     SEGGER_RTT_printf(0,"UART ERROR CODE :%d\r\n",err_code);
     else
     SEGGER_RTT_printf(0,"UART ERROR CODE :%d\r\n",err_code);
    APP_ERROR_CHECK(err_code);
    APP_ERROR_CHECK(err_code);


}

Parents Reply Children
Related