2 years, 9 months ago.

Power consumption profile


I running the very simple blinky sample program

#include "mbed.h"

DigitalOut led1(LED1);

// main() runs in its own thread in the OS
int main() {
    mbed_error_status_t status = MBED_SUCCESS;
    while (true) {
        led1 = !led1;

and I am trying to understand the power consumption profile. The program is running on a nRF51/52 platform and I am using the nRF6707 power profiler kit for measuring the consumption.

When I run the same program using the nRF sdk, I can measure as expected a consumption peak in mA every 0.5 sec and a very low consumption (microA) in between the peaks. When the same board is loaded with the code above compiled with the online compiler for the nRF platform, I get a profile as shown in the attached picture. I added the NDEBUG and __ASSERT_MSG compile macros (but the results are the same with or without the macros). I don't understand what the small power consumption peaks (still above 1 mA) in between the higher peaks are ?

Is there a way to get the expected behavior ?


1 Answer

2 years, 9 months ago.

Hi Serge,

Your screen capture didn't make it through - could you please attach that for us?

We suspect that the problem is that you are using wait() instead of Thread::wait(). The former will prevent the OS from entering deep sleep (for the greatest power savings) while the latter won't. Could you try replacing wait() with Thread::wait()?


Ralph, Team Mbed

Hi Ralph,

Thank you for your suggestion. It does solve the problem. However, I would like to ask two more questions:

- How would I be able to understand the proposed solution from the documentation. I read it again (for both wait() and Thread::wait()) and was not able to come to the same explanation. And it solves the problem. So what part of the documentation am I missing to get to a better understanding ?

- Is there a way to implement a busy wait, using noop instructions, directly from the mbed API. It is for instance possible when using the nRF sdk directly. This is mainly for explaining the difference in power consumption when waiting but not sleeping.

Thank you again for your help,



posted by Serge Ayer 03 Oct 2018