STMicroelectronics / STM32CubeL0

STM32Cube MCU Full Package for the STM32L0 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
103 stars 57 forks source link

HAL_PWR_EnterSLEEPMode() HAL_PWR_EnterSTOPMode() and WFI instructions #18

Closed apiesse closed 3 years ago

apiesse commented 3 years ago

Was pyaling around with low poer modes on a STM32L071KZ and I did found out that both HAL_PWR_EnterSLEEPMode() and HAL_PWR_EnterSTOPMode() use what looks like to be a wrong WFI sequence.

The functions have the following code (which is not working, uC not going into Sleep/Stop mode) if(STOPEntry == PWR_STOPENTRY_WFI) { /* Request Wait For Interrupt */ __WFI(); }

Changing to this code solved my issue: if(STOPEntry == PWR_STOPENTRY_WFI) { /* Request Wait For Interrupt */ __DSB(); __WFI(); __ISB(); }

ALABSTM commented 3 years ago

Hi @apiesse,

Thank you for your report. From what I can notice, __DSB(); and __ISB(); instructions are only used in the drivers of the STM32F7 and STM32H7 series. As for other series, they are not. Do you confirm this issue you are facing with your STM32L071KZ µC is systematically reproducible? Thank you.

With regards,

apiesse commented 3 years ago

Hi @ALABSTM, I did checked the code again and found other issues which actually caused the initial problem entering STOP mode. As you mentioned, __DSB() and __ISB() and not needed. I was misleaded by the FreeRTOS tickless implementation and some comments found on the web.

For what I can tell, the issue can be closed.

ALABSTM commented 3 years ago

Hi @apiesse,

Glad to hear you could overcome the problem. I will close the issue.

With regards,