Page 1 of 1

sleep in idle thread

Posted: Sun Dec 20, 2020 6:16 pm
by geoffrey.brown
I'm having trouble getting the idle thread to sleep. I guess I expect chThdSleepMilliseconds(...) to go to sleep. Here's the basic scenario

    * stm32l432
    * CORTEX_ENABLE_WFI_IDLE TRUE in chconf.h
    * spi enabled, but idle
    * MSI_RANGE_1M
    * Timer alarms are enabled

I'm seeing 300uA when it should be sleeping. Any thoughts on things I should be checking ?

Re: sleep in idle thread

Posted: Sun Dec 20, 2020 7:15 pm
by Giovanni
Hi,

That option just enables a WFI instruction in the idle loop, it does not enter a sleep mode unless you prepare for it before executing WFI.

Sleep, standby etc are STM32-specific things, you should not expect the RTOS to do this kind of things.

Giovanni

Re: sleep in idle thread

Posted: Sun Dec 20, 2020 7:24 pm
by geoffrey.brown
I was under the impression that the only suitable sleep mode in Chibios is the normal sleep mode which is supposed to be what happens with a wfi instruction. However, there is clearly something I am not doing to prepare because wfi is not causing the processor to sleep -- but what might that be ?

I do use standby successfully, but that forces a restart. I don't think any of the stop modes will work without some significant enabling/disabling of things.

Re: sleep in idle thread

Posted: Sun Dec 20, 2020 8:21 pm
by Giovanni
It depends on the specific STM32, exiting from stop modes requires reinitialization of clocks, entering stop mode requires setting up some registers before executing WFI, you need to search this on the STM32 manual.

Giovanni