This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART hits communication error

[nRF52840 + SDK13]

On the hardware that I have, the UART driver is hitting a communication error because the RX line is low. This only happens when the UART lines are disconnected from my computer. When there is a connection, everything works fine. This is when using UART for logging and CLI.

Is there a way to have the RX line be pulled up by default?

I see that the function apply_config() in nrf_drv_uart.c is configuring it to NOPULL: nrf_gpio_cfg_input(p_config->pselrxd, NRF_GPIO_PIN_NOPULL);

I tried changing this to NRF_GPIO_PIN_PULLUP but that didn't help. Should I be able to configure a UART RX pin to be pulled up?

The error that is hit leads to this code executing with APP_UART_COMMUNICATION_ERROR evt_type:

static void uart_error_handle(app_uart_evt_t * p_event)
{
    if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_communication);
    }
    else if (p_event->evt_type == APP_UART_FIFO_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_code);
    }
}
  • Hi,

    You can disconnect the RX pin from the UART module completely by setting the RX pin number to 0xFFFFFFFF. UART PSEL documentation.

    When you init the UART you can do it like this:

    const app_uart_comm_params_t comm_params =
      {
          UART_PIN_DISCONNECTED, // <- 0xFFFFFFFF
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          APP_UART_FLOW_CONTROL_DISABLED,
          false,
          UART_BAUDRATE_BAUDRATE_Baud115200
      };
    
    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);
    
  • I retried the pull-up option and it worked.

    Changed the pull option in apply_config():

    nrf_gpio_cfg_input(p_config->pselrxd, NRF_GPIO_PIN_PULLUP);

  • Thanks Martin. But if I do that, I won't be able to communicate with the device when the UART lines are physically connected. The problem I was seeing only appears when the UART lines are not physically connected.

    I retried the pull-up option and it worked.

Related