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.
I use the boards manager package on www.github.com/stm32duino
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
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.
– 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.
– 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.
– 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.