sleep in idle thread

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

sleep in idle thread

Post 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 ?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: sleep in idle thread

Post 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
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

Re: sleep in idle thread

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: sleep in idle thread

Post 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
Post Reply