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
  • Hello,

    I have run your sample on nRF52840 DK. UART1 was also enabled (which you can find from zephyr.dts file from build folder). After disabling the UART1, it shows expected output current (average 3.52uA). 

    you need to create an overlay file (nrf52840dk_nrf52840.overlay) with the following content and build the program again. You should get the expected current now.

    &uart1 {  
         status = "disabled";
        };

    Thanks.

    Best Regards,

    Kazi Afroza Sultana

Reply
  • Hello,

    I have run your sample on nRF52840 DK. UART1 was also enabled (which you can find from zephyr.dts file from build folder). After disabling the UART1, it shows expected output current (average 3.52uA). 

    you need to create an overlay file (nrf52840dk_nrf52840.overlay) with the following content and build the program again. You should get the expected current now.

    &uart1 {  
         status = "disabled";
        };

    Thanks.

    Best Regards,

    Kazi Afroza Sultana

Children
No Data
Related