What's causing this power spike in STM32 low power mode
I can't speak about mbed specifically, but the general idea is that sleep() causes the execution of the current process to pause for some number of seconds, or indefinitely if no argument (equivalent to an argument of 0) is given.

In a multiprocess environment, that means that it simply yields the CPU to other processes. If there are no other processes ready to run, the OS may or may not put the CPU into a low-power state while waiting for interrupts &mdash; it depends on how the idle() task is written. This would not generally be the lowest-power state available on the CPU, however, since it wants to wake quickly when interrupts occur.

In your case, it appears to be waking up once a second to handle the system timer tick.

If you really want to get into a lower-power state, there are generally platform-specific calls for that, and that's exactly the sort of thing the HAL is for. You shouldn't avoid it, you should learn it.



After a quick search, I discovered that the documentation here: APIs - power management discusses this specifically.