6 years, 1 month ago.

DeepSleep Method

I'm using Nucleo L432KC board now. and Testing low power operation of processor.

Is there only one method that is sleep() in MBED OS 5.7? I'd like to save more power my project.. so I tried deepsleep() method then compiler came out some warning

Warning: Function "deepsleep" (declared at <a href="#" onmousedown="mbed_doc_goto('/Nucleo_display_timeextras/mbed_aa5281ff4a02/platform/mbed_sleep.h', '161'); return false;">/extras/mbed_aa5281ff4a02/platform/mbed_sleep.h:161</a>) was declared "deprecated" in "main.cpp", Line: 32, Col: 10

I was tested sleep() method below code

include the mbed library with this snippet

#include "mbed.h"
#include "WakeUp.h"
DigitalOut myled(LED1);
void mycallback(void)
{
    myled = !myled;
}
int main()
{

    printf("RTC example\n");
    set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTC
    printf("Date and time are set.\n");
    WakeUp::calibrate();
    WakeUp::attach(&mycallback);

    while(1) {
        time_t seconds = time(NULL);
        printf("Time as a basic string = %s", ctime(&seconds));
        WakeUp::set_ms(2000);

        //Enter deepsleep, the program won't go beyond this point until it is woken up
        //sleep();
        //hal_sleep();
       sleep();


        wait(1);
    }
}

The Measurement result is below.

  • Sleep mode : 93.2uA
  • Callback : 13.32mA

how to use deep sleep method? and how to regularly wake up form sleep_manager_can_deep_sleep()?

Reference

https://os.mbed.com/docs/v5.6/reference/sleep-manager.html

https://os.mbed.com/users/kenjiArai/notebook/standby-mode-current-consumption-on-nucleo-f446re/

https://os.mbed.com/users/Sissors/code/WakeUp/

1 Answer

6 years, 1 month ago.

Hi,

I assume you are using Mbed OS 5 (not mbed 2). idle loop goes to sleep - if there is nothing to do, go to sleep - it can be sleep or deepsleep based on what is being active in the system (deepsleep is enabled only if tickless is implemented, otherwise your app would not wake up).

I do not know what target are you using, using mbed OS 5 5.7? Based on the example above, I would assume you are using mbed 2 (where you have while (1) loop and want to invoke sleep ). In any case, use sleep(), and it should find the best sleep mode for you. If that is not the case, please report more information and code snippet, for us to look at.

Accepted Answer

Thank you :)

posted by PARK JAICHANG 21 Mar 2018