WFI issue (solved)

aro_72
Mon Dec 12, 2016 2:40 pm
Hi all,
I am experiencing an issue with wait for interrupt (WFI) using Nucleo-L476.
It seems my board does not enter WFI or most probably exit immediately WFI.
In order to make it simple, I used the Blink sketch and added WFI when changing the LED state.
I expect then the STM32 to enter WFI and stay here until an interrupt is fired (that should never come on this basic example) and therefore the LED should not blink anymore
What I observe : LED continues to blink normally.
I use the __WFI() funtion of CMSIS.
Is there anything special to do to get WFI working properly ?
Thanks in advance.

RogerClark
Mon Dec 12, 2016 8:28 pm
Which core are you using? STMs or GrumpyOldPizza’s core

aro_72
Mon Dec 12, 2016 9:31 pm
Nucleo-L476 is a STM32 board, based on STM32L476RG (low power version, Cortex-M4)

RogerClark
Mon Dec 12, 2016 9:49 pm
aro_72 wrote:Nucleo-L476 is a STM32 board, based on STM32L476RG (low power version, Cortex-M4)

aro_72
Mon Dec 12, 2016 10:14 pm
Sorry I didn’t understand the question.
I use the boards manager package on www.github.com/stm32duino

mailhouse
Tue Dec 13, 2016 12:27 am
shut the gpio clock off and it wont keep waking to toggle the gpio pin. i have not yet explored how to configure the clocks to stop during standby/stop mode.

see also AN4746, AN4621

remember to watch your power usage because when the chip is in standby or stop modes, the voltage regulator is too


aro_72
Tue Dec 13, 2016 2:10 pm
Not sure to catch the point. Normally WFI only affects CPU core by clock gating most of its logic (keeping only interrupt detection enabled).
I don’t expect to stop any peripheral clock to enable WFI.
I’d rather imagine an interrupt (that could be configured automatically in the sketch as I don’t enable any interrupt explicitly) occurs preventing to stay in WFI.
Anyway, I will give it a try by clock gating GPIO blocks in RCC_AHB2EN register and will report the result.

danieleff
Tue Dec 13, 2016 4:59 pm
The HAL code for `HAL_PWR_EnterSLEEPMode` does `CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));` right before `__WFI();`, so maybe try that. (I never used WFI.)

aro_72
Wed Dec 14, 2016 8:18 am
Results of my tests using Arduino IDE:
– test1: using HAL to enter WFI does not improve
– test2: clock gating all GPIO blocks and calling __WFI() allows to enter and stay in WFI
– test3: clock gating all GPIO blocks and calling HAL_PWR_EnterSLEEPMode allows to enter and stay in WFI
I also have CubeMX and Eclipse IDE and made similar test:
– test4: keeping clocks on GPIO blocks and calling __WFI() work fine

Conclusion:
– As I expected, test4 confirms that clock gating GPIOs is not necessary to enter WFI
– test1/2/3 shows that by default the basic blink sketch configures something with GPIO that triggers an interrupt preventing to stay in WFI.
When I will have a bit more time, I will investigate which interrupt is enabled.
Thanks for your support that allowed me to get WFI functional.


ahull
Wed Dec 14, 2016 10:20 am
aro_72 wrote:Results of my tests using Arduino IDE:
– test1: using HAL to enter WFI does not improve
– test2: clock gating all GPIO blocks and calling __WFI() allows to enter and stay in WFI
– test3: clock gating all GPIO blocks and calling HAL_PWR_EnterSLEEPMode allows to enter and stay in WFI
I also have CubeMX and Eclipse IDE and made similar test:
– test4: keeping clocks on GPIO blocks and calling __WFI() work fine

Conclusion:
– As I expected, test4 confirms that clock gating GPIOs is not necessary to enter WFI
– test1/2/3 shows that by default the basic blink sketch configures something with GPIO that triggers an interrupt preventing to stay in WFI.
When I will have a bit more time, I will investigate which interrupt is enabled.
Thanks for your support that allowed me to get WFI functional.


GrumpyOldPizza
Wed Dec 14, 2016 1:02 pm
ahull wrote:aro_72 wrote:Results of my tests using Arduino IDE:
– test1: using HAL to enter WFI does not improve
– test2: clock gating all GPIO blocks and calling __WFI() allows to enter and stay in WFI
– test3: clock gating all GPIO blocks and calling HAL_PWR_EnterSLEEPMode allows to enter and stay in WFI
I also have CubeMX and Eclipse IDE and made similar test:
– test4: keeping clocks on GPIO blocks and calling __WFI() work fine

Conclusion:
– As I expected, test4 confirms that clock gating GPIOs is not necessary to enter WFI
– test1/2/3 shows that by default the basic blink sketch configures something with GPIO that triggers an interrupt preventing to stay in WFI.
When I will have a bit more time, I will investigate which interrupt is enabled.
Thanks for your support that allowed me to get WFI functional.


Leave a Reply

Your email address will not be published. Required fields are marked *