9 years, 7 months ago.

sleep() and deepsleep() documentation

Where are sleep() and deepsleep() documented? How do you know what power mode they enable for a particular target (e.g. KL25Z)?

1 Answer

9 years, 7 months ago.

Since it is target specific, and each manufacturer uses different names, there isn't a single overall name for which modes are used. Generally speaking sleep disables the ARM core, but keeps clock to peripherals running (and tbh doesn't do that much for power consumption), while deepsleep also disables clock to peripherals, only keeping SRAM powered to maintain the current state.

Now it wouldn't hurt if a handbook page had a nice table with which states + how much current consumption there is for different targets. So you have to check source code, for the KL25Z: http://mbed.org/users/mbed_official/code/mbed-src/file/1f0269907d8b/targets/hal/TARGET_Freescale/TARGET_KLXX/sleep.c. In other words, WAIT mode for sleep, VLPS for deepsleep. Dunno exactly how much power sleep uses, but deepsleep should be around 3uA.

Accepted Answer

Thanks. It would be great in the compiler if you could right click on a function and then bring up the source code. For the handbook functions you can bring up the documentation page which is great. Of course, code completion would also be nice.

posted by Tom Russell 01 Sep 2014

The normal mbed lib is precompiled, so it wouldn't be able to go to the implementation, but with mbed-src that would indeed be nice. And code completion would definately be nice :).

posted by Erik - 01 Sep 2014

I couldn't see mention of sleep() or deepsleep() in the API documentation.

Precisely because it *is* target specific is all the more reason why it *needs* to be documented!

At least to the point of, "Generally speaking sleep disables the ARM core, but keeps clock to peripherals running (and tbh doesn't do that much for power consumption), while deepsleep also disables clock to peripherals, only keeping SRAM powered to maintain the current state"

See also: https://developer.mbed.org/questions/69167/sleep-and-deepsleep/

posted by Andrew Neil 03 Jul 2017