req_pin_idle() in uart_nrf_sw_lpuart.c

Hi!
I am developing application for nrf52840 on nrf connect sdk 2.9.0.
I am using mcuboot with serial transport as a bootloader. In bootloader I am using uart with hwfc and in application I am using lpuart for hci communication.

The same pin is used for hwfc rts and for lpuart req pin.

I was experiencing strange behaviour of req pin when hwfc was enabled in bootloader.

I managed to fix the problem by changing:

static void req_pin_idle(struct lpuart_data *data)
{
	nrf_gpio_cfg(data->req_pin,
		     NRF_GPIO_PIN_DIR_OUTPUT,
		     NRF_GPIO_PIN_INPUT_DISCONNECT,
		     NRF_GPIO_PIN_NOPULL,
		     NRF_GPIO_PIN_S0S1,
		     NRF_GPIO_PIN_NOSENSE);
}


from uart_nrf_sw_lpuart.c to:

static void req_pin_idle(struct lpuart_data *data)
{
	nrf_gpio_cfg(data->req_pin,
		     NRF_GPIO_PIN_DIR_OUTPUT,
		     NRF_GPIO_PIN_INPUT_DISCONNECT,
		     NRF_GPIO_PIN_NOPULL,
		     NRF_GPIO_PIN_S0S1,
		     NRF_GPIO_PIN_NOSENSE);
	nrf_gpio_pin_clear(data->req_pin);
}


According to lpuart documentation, this is correct logic. I think it is a bug and should be passed to ncs developers.

Kind regards,
Piotr Radecki

Parents Reply
  • I am using custom board based on nrf52840.
    Yes, everything worked fine without using bootloader and even with flow control on req pin in bootloader.

    Please note that driver implementation prior to my modification was:

    static void req_pin_idle(struct lpuart_data *data)
    {
    	nrf_gpio_cfg(data->req_pin,
    		     NRF_GPIO_PIN_DIR_OUTPUT,
    		     NRF_GPIO_PIN_INPUT_DISCONNECT,
    		     NRF_GPIO_PIN_NOPULL,
    		     NRF_GPIO_PIN_S0S1,
    		     NRF_GPIO_PIN_NOSENSE);
    }


    which means that line is configured as output but not set low. It probably assumes that pin was set low prior to that operation which is not always true.

    Best regards,
    Piotr

Children
Related