Disable UART1 of nrf52840 DK and re-configure pins as GPIOs at runtime

Hi,

we are currently using NCS 2.0.2 on nRF52840.

Is it possible to disable uart1 via pinctrl or another library during runtime and re-configure the rx/tx as gpios?

We need to set the two pins in low-state to allow another module enter its sleep mode while the nrf stays awake.

Regards,

Simon

  • Hi Simon, 
    Your question is similar to this question here.

    Our answer for now is that it's not possible. You can have a look here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/pinctrl/index.html#dynamic-pin-control

    Dynamic pin control should only be used on devices that have not been initialized. Changing pin configurations while a device is operating may lead to unexpected behavior. Since Zephyr does not support device de-initialization yet, this functionality should only be used during early boot stages.

  • Hi Hung,

    Thanks for your quick reply.

    Then I have a further question. Is it possible to set them (tx/rx) low during sleep mode?

  • Hi Simon, 
    Which sleep mode are you looking at ? 
    If you are thinking of system OFF I do think that it's possible. You can suspend UART and then use the nrf_gpio_* library to access the pins and change the state. (see system_off sample) . The main point here is that if you are entering system OFF , it's not very important how they would work after the system OFF entered. The chip will reset and start from beginning when waking up anyway. 

  • Thanks, that works!

    Even in the busy wait loop, the UART pins can be set low or high after the suspend command is called.