Unable to disable UART at runtime NCS v2.2.0

Hi,

I have the following minimal example:

main.c

#include ...

#define LOG_MODULE_NAME hci_uart
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

#if defined(CONFIG_SERIAL)
static const struct device *hci_uart_dev =
    DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_c2h_uart));
#endif

static const struct device *led;

#define LED_NODE_ID DT_INST(0, gpio_leds)
#define LED_DEV_NAME DEVICE_DT_NAME(LED_NODE_ID)

void main(void) {
  led = device_get_binding(LED_DEV_NAME);

#if defined(CONFIG_SERIAL)
  int err=0;
  //err = pm_device_action_run(hci_uart_dev, PM_DEVICE_ACTION_SUSPEND);
  if (err) {
    led_on(led, 1);
  }
#endif

  int blink_status = 0;
  while (1) {
    if ((++blink_status) % 2) {
      led_on(led, 0);
    } else {
      led_off(led, 0);
    }

    k_sleep(K_SECONDS(1));
  }
}

proj.conf:

CONFIG_CONSOLE=n

CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_LED=y
CONFIG_LED_GPIO=y

CONFIG_PM=y
CONFIG_PM_DEVICE=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512

Now, when setting CONFIG_SERIAL=n my nRF52840DK drains about 3-4 µA, when setting CONFIG_SERIAL=y it drains about 520 µA. That seems reasonable. Now I want to disable the UART at runtime, therefore I remove the comments in line 21. But this has no effect regarding the current. The return value is 0, so no error is reported. I read almost every thread regarding "disable UART" here in devzone, but no solution solved my problem. Any hints or ideas what I am missing?

What is confusing me is that the same appears to happen in the system_off sample. Maybe just my assumption is wrong that disabling the UART at runtime should lead to the same current consumption as CONFIG_SERIAL=n?

Regards,
Oliver

Related