[riot-devel] How to properly use cortexm_sleep

Kees Bakker kees at sodaq.com
Mon May 27 22:11:59 CEST 2019


Thanks Juan,

That's a lot of information to digest. It will take me a bit of time
to go through.
-- Kees

On 27-05-19 14:17, Juan Ignacio Carrano wrote:
> Hi Kees,
>
> Some observations:
>
> 1- WFI will not send you to the deepest sleep states- clocks are 
> gated, but many things remain powered.
>
> 2- If you are using the timer module and depending on you clock 
> configuration you may experience more or less frequent wake ups. 
> Whether this is acceptable is up to you.
>
> 3- Normally, if no thread is runnable (i.e. all are waiting/blocked) the
> idle thread is run and that has a loop which sends the MCU to the 
> deepest state possible (considering the currently-enabled 
> peripherals). This means that in many cases the explicit WFI is not 
> needed if in your
> "while(forever)" loop you put some call that blocks waiting for the 
> events you are interested in.
>
> The interaction between (1) and (3) means that by doing a WFI in a 
> thread it is possible that you don't sleep as deep as you could:
>
> - The current thread will be blocked on the WFI instruction until an
>   event arrives.
> - In the meantime, control will not go back to the kernel.
> - This means the idle thread will not run (from the schedulers point of
>   view, you thread is still running).
> - The pm_whatever() call in the idle thread will not run.
>
> In conclusion, try to use the default mechanism if you can.
>
> Regards,
>
> Juan.
> _______________________________________________
> devel mailing list
> devel at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel



More information about the devel mailing list