Can´t turn off uart0 on runtime on nRF52840-DK

Hello, we are seeing some kind of issue when trying to turn off uart0 on a nRF52840-DK but we are not able too.

We are using the following config and code:

CONFIG_PM_DEVICE=y

/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#include <zephyr/pm/device.h>

void main(void)
{
	const struct device *uart_dev = DEVICE_DT_GET(DT_NODELABEL(uart0));
	printk("Hello World! %s\n", CONFIG_BOARD);

	if (!device_is_ready(uart_dev)) {
		return;
	}

	while(1)
	{
		pm_device_action_run(uart_dev, PM_DEVICE_ACTION_SUSPEND);
		k_sleep(K_MSEC(2000));
		printk("Should not be printed, since uart0 is disabled! %s\n", CONFIG_BOARD);
		pm_device_action_run(uart_dev, PM_DEVICE_ACTION_RESUME);
		k_sleep(K_MSEC(2000));
		printk("Should be printed, since uart0 is enabled! %s\n", CONFIG_BOARD);
	}	
}

The terminal output is as expected. Every 2 seconds, when pm_device_action_run(uart_dev, PM_DEVICE_ACTION_SUSPEND); is called the following printk is not printed, 2 seconds later when pm_device_action_run(uart_dev, PM_DEVICE_ACTION_RESUME); is called, the following printk works:

But, analyzing with the PPK2, we are getting the following power profile:

Please not that every 2 seconds there is a slightly change on power consumption, but the overall power level is around 400uA.

If we do a CONFIG_SERIAL=n, we get a power level of around 4.3uA. We where expecting the same power level every two second on this sample when PM_DEVICE_ACTION_SUSPEND is called.

As a sanity check, we ran the same code on a nRF9160-DK. Please note we can see the expected low power level every two seconds:

We would like some help to figure out why this is not working on nRF52840-DK and how can we implement the real-time turning on/off of the uart0 to save power.

At a first look it appears that something is broken on the PM for the nRF52840-DK.

Please see attached code.

disable_uart_runtime.zip

Parents Reply Children
No Data
Related