Unexpected consumption using System OFF Sample & nRF52840DK

Greetings,

I have been measuring the current consumption of our custom FW in our custom board using PPK2 and found some unexpected spikes in the current consumption curve.

I decided to look deeper into this so programmed our custom FW to the nRF52840 DK and the behavior remained the same.

Finally I decide to test some samples with absolutely no changes on the nRF52840DK to confirm the normal behavior of the current curves I should see when the system is Active, in Sleep (system ON Idle) & finally System OFF(which is irrelevant for my application).

It seems that flashing the nRF System OFF sample (unchanged, as it was in the NCS) to the nRF52840 DK produces the same current curve. As mentioned in other tickets ( I have searched and read all of the relevant ones in existence) the current curve in System Sleep (with UART off) should be a few tens of microamps but I am consistently getting the current curve shown below.

Connection diagram (PPK2 in Ampere mode) 
I have also measured with the SW6 to the DEFAULT and nRF ONLY positions but the results were the same.

!!!Below you can see the current curve for the nRF52840DK flashed with the nRF System OFF sample and focus on the duration that corresponds to the System Sleep (System ON Idle) part of the duration ( the sample enters the SYstem Sleep state for two seconds, this what is shown below)

System Sleep (System ON Idle)

System Sleep (System ON Idle) the curve shown above ZOOMED IN ( to be able to distinguish the spikes)

The whole current curve for the System OFF sample

I have tried all different methods of measurement using the PPK2 (Ampere mode & Source mode by providing the external supply from the PPK2) but in all instances, I am getting the same current curve(shown above).

I have also tried the beacon sample (with no changes/modification, as is) and gotten the same curve in Idle mode (apart from when the device wakes up to advertise), between the advertising events I get the same spikes up to 3mA with the current never falling bellow 100's of microamps.

Beacon sample

Beacon sample ZOOMED IN

Even more ZOOMED IN

According to other tickets as well as this one that contains current curves for the Beacon sample this is not at all the Normal curve I should see for this sample

(this is what the people in the ticket mentioned report as the normal current curves for this sample)

which is completely different from my curves.

What could be the cause for the behavior and current curves I am observing when loading the nRF System OFF & Beacon samples to the nRF52840DK and measuring using the PPK2?

Please get back to me for any further information needed, I can also provide the data for the curves shown above.

I look forward to hearing from you.

Best regards,

Stavros

  • How did you turn off the UART? When UART reception is enabled in sleep mode, the HF clock remains active to allow data reception. This means the sleep current will be around .5 to 1 mA in System ON.

    You can disable the UART before entering sleep using the pm_device_* APIs as shown in the code snippet I posted here:  RE: How to put the UART to sleep (low power mode) 

  • I used the nrf/system_off sample without any modifications. I did not set this up, it is provided with the nRF Connect SDK v2.1.0 in samples folder.

    I am pasting the code of the sample below (only has two files a main.c and a retained.c which is not used as the config option for this is disabled)

    main.c (FYI CONFIG_APP_RETENTION is disabled)

    /*
     * Copyright (c) 2019 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <stdio.h>
    #include <zephyr/zephyr.h>
    #include <zephyr/device.h>
    #include <zephyr/init.h>
    #include <zephyr/pm/pm.h>
    #include <zephyr/pm/device.h>
    #include <zephyr/pm/policy.h>
    #include <soc.h>
    #include "retained.h"
    #include <hal/nrf_gpio.h>
    
    #define BUSY_WAIT_S 2U
    #define SLEEP_S 2U
    
    /* Prevent deep sleep (system off) from being entered on long timeouts
     * or `K_FOREVER` due to the default residency policy.
     *
     * This has to be done before anything tries to sleep, which means
     * before the threading system starts up between PRE_KERNEL_2 and
     * POST_KERNEL.  Do it at the start of PRE_KERNEL_2.
     */
    static int disable_ds_1(const struct device *dev)
    {
    	ARG_UNUSED(dev);
    
    	pm_policy_state_lock_get(PM_STATE_SOFT_OFF, PM_ALL_SUBSTATES);
    	return 0;
    }
    
    SYS_INIT(disable_ds_1, PRE_KERNEL_2, 0);
    
    void main(void)
    {
    	int rc;
    	const struct device *cons = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
    
    	if (!device_is_ready(cons)) {
    		printk("%s: device not ready.\n", cons->name);
    		return;
    	}
    
    	printk("\n%s system off demo\n", CONFIG_BOARD);
    
    	if (IS_ENABLED(CONFIG_APP_RETENTION)) {
    		bool retained_ok = retained_validate();
    
    		/* Increment for this boot attempt and update. */
    		retained.boots += 1;
    		retained_update();
    
    		printk("Retained data: %s\n", retained_ok ? "valid" : "INVALID");
    		printk("Boot count: %u\n", retained.boots);
    		printk("Off count: %u\n", retained.off_count);
    		printk("Active Ticks: %" PRIu64 "\n", retained.uptime_sum);
    	} else {
    		printk("Retained data not supported\n");
    	}
    
    	/* Configure to generate PORT event (wakeup) on button 1 press. */
    	nrf_gpio_cfg_input(NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(sw0), gpios),
    			   NRF_GPIO_PIN_PULLUP);
    	nrf_gpio_cfg_sense_set(NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(sw0), gpios),
    			       NRF_GPIO_PIN_SENSE_LOW);
    
    	printk("Busy-wait %u s\n", BUSY_WAIT_S);
    	k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
    
    	printk("Busy-wait %u s with UART off\n", BUSY_WAIT_S);
    	rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
    	k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
    	rc = pm_device_action_run(cons, PM_DEVICE_ACTION_RESUME);
    
    	printk("Sleep %u s\n", SLEEP_S);
    	k_sleep(K_SECONDS(SLEEP_S));
    
    	printk("Sleep %u s with UART off\n", SLEEP_S);
    	rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
    	k_sleep(K_SECONDS(SLEEP_S));
    	rc = pm_device_action_run(cons, PM_DEVICE_ACTION_RESUME);
    
    	printk("Entering system off; press BUTTON1 to restart\n");
    
    	if (IS_ENABLED(CONFIG_APP_RETENTION)) {
    		/* Update the retained state */
    		retained.off_count += 1;
    		retained_update();
    	}
    
    	/* Above we disabled entry to deep sleep based on duration of
    	 * controlled delay.  Here we need to override that, then
    	 * force entry to deep sleep on any delay.
    	 */
    	pm_state_force(0u, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0});
    
    	/* Now we need to go sleep. This will let the idle thread runs and
    	 * the pm subsystem will use the forced state. To confirm that the
    	 * forced state is used, lets set the same timeout used previously.
    	 */
    	k_sleep(K_SECONDS(SLEEP_S));
    
    	printk("ERROR: System off failed\n");
    	while (true) {
    		/* spin to avoid fall-off behavior */
    	}
    }

    This sample can be found in ..\v2.1.0\zephyr\samples\boards\nrf\system_off

  • I tried the 'system OFF' sample just now and got similar results. The problem is that the sample does not suspend the UART before entering 'System OFF', causing the UART pin states to be retained during sleep. This leads to current leakage. I will report this as a bug internally. You can comment the  'rc = pm_device_action_run(cons, PM_DEVICE_ACTION_RESUME);' at line 85 for now.

    Edit: this was fixed by this commit: https://github.com/nrfconnect/sdk-zephyr/commit/2cbc452d1d0dcf9dc6bc9c6081b4bc54f6a04e89 

  • The commit you mentioned removed the previous 4 states (Busy Wait 2 seconds, Busy Wait UART off 2 seconds, System Sleep, System Sleep UART off) and only put the device in System Off mode. The state I am interested in measuring the consumption for is the 4th state (System Sleep aka System ON Idle or Idle current) not the System OFF ( I do not use the System Off mode in my application at all so it totally irrelevant to me).

    Also I tried commenting out line 85 and I get the same current curves as the ones shown above (no change).

    I also tried commenting out lines 85, 83 & 77 but I get the same result again.

    I also tried commenting out lines 85, 83, 77 & 75 and adding the UART suspend in the beginning as shown in the code below but also got the same results as my previous post.

    /*
     * Copyright (c) 2019 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <stdio.h>
    #include <zephyr/zephyr.h>
    #include <zephyr/device.h>
    #include <zephyr/init.h>
    #include <zephyr/pm/pm.h>
    #include <zephyr/pm/device.h>
    #include <zephyr/pm/policy.h>
    #include <soc.h>
    #include "retained.h"
    #include <hal/nrf_gpio.h>
    
    #define BUSY_WAIT_S 2U
    #define SLEEP_S 2U
    
    /* Prevent deep sleep (system off) from being entered on long timeouts
     * or `K_FOREVER` due to the default residency policy.
     *
     * This has to be done before anything tries to sleep, which means
     * before the threading system starts up between PRE_KERNEL_2 and
     * POST_KERNEL.  Do it at the start of PRE_KERNEL_2.
     */
    static int disable_ds_1(const struct device *dev)
    {
    	ARG_UNUSED(dev);
    
    	pm_policy_state_lock_get(PM_STATE_SOFT_OFF, PM_ALL_SUBSTATES);
    	return 0;
    }
    
    SYS_INIT(disable_ds_1, PRE_KERNEL_2, 0);
    
    void main(void)
    {
    	int rc;
    	const struct device *cons = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
    
    	if (!device_is_ready(cons)) {
    		printk("%s: device not ready.\n", cons->name);
    		return;
    	}
    
    	rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
    
    	printk("\n%s system off demo\n", CONFIG_BOARD);
    
    	if (IS_ENABLED(CONFIG_APP_RETENTION)) {
    		bool retained_ok = retained_validate();
    
    		/* Increment for this boot attempt and update. */
    		retained.boots += 1;
    		retained_update();
    
    		printk("Retained data: %s\n", retained_ok ? "valid" : "INVALID");
    		printk("Boot count: %u\n", retained.boots);
    		printk("Off count: %u\n", retained.off_count);
    		printk("Active Ticks: %" PRIu64 "\n", retained.uptime_sum);
    	} else {
    		printk("Retained data not supported\n");
    	}
    
    	/* Configure to generate PORT event (wakeup) on button 1 press. */
    	nrf_gpio_cfg_input(NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(sw0), gpios),
    			   NRF_GPIO_PIN_PULLUP);
    	nrf_gpio_cfg_sense_set(NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(sw0), gpios),
    			       NRF_GPIO_PIN_SENSE_LOW);
    
    	printk("Busy-wait %u s\n", BUSY_WAIT_S);
    	k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
    
    	printk("Busy-wait %u s with UART off\n", BUSY_WAIT_S);
    	// rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
    	k_busy_wait(BUSY_WAIT_S * USEC_PER_SEC);
    	// rc = pm_device_action_run(cons, PM_DEVICE_ACTION_RESUME);
    
    	printk("Sleep %u s\n", SLEEP_S);
    	k_sleep(K_SECONDS(SLEEP_S));
    
    	printk("Sleep %u s with UART off\n", SLEEP_S);
    	// rc = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
    	k_sleep(K_SECONDS(SLEEP_S));
    	// rc = pm_device_action_run(cons, PM_DEVICE_ACTION_RESUME);
    
    	printk("Entering system off; press BUTTON1 to restart\n");
    
    	if (IS_ENABLED(CONFIG_APP_RETENTION)) {
    		/* Update the retained state */
    		retained.off_count += 1;
    		retained_update();
    	}
    
    	/* Above we disabled entry to deep sleep based on duration of
    	 * controlled delay.  Here we need to override that, then
    	 * force entry to deep sleep on any delay.
    	 */
    	pm_state_force(0u, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0});
    
    	/* Now we need to go sleep. This will let the idle thread runs and
    	 * the pm subsystem will use the forced state. To confirm that the
    	 * forced state is used, lets set the same timeout used previously.
    	 */
    	k_sleep(K_SECONDS(SLEEP_S));
    
    	printk("ERROR: System off failed\n");
    	while (true) {
    		/* spin to avoid fall-off behavior */
    	}
    }
    

    nrf_system_off_uart_modified.hex

    I have included both the code and the FW image.

    Could you please provide a way to properly suspend the UART and avoid the current leakage so I can properly measure the current consumption for the System ON Idle aka System Sleep (Idle current) (no the System Off current as it is irrelevant for my application). I need to know how to properly suspend the UART this way (during runtime) as this is exactly what I need to do in my custom application ( I cannot disable it during build time using CONFIG_SERIAL=n).

  • Please try to build the sample against a newer SDK version and see if you still experience the high idle current after suspending the UART. For example, v2.5.1.

Related