In the STM32F4 and STM32F1 examples, the code snippets for putting the processor into low power mode are listed as
Code: Select all
while (true){
chThdSleepSeconds(10);
/* going to anabiosis*/
chSysLock();
PWR->CR |= PWR_CR_CWUF | PWR_CR_CSBF;
PWR->CR |= PWR_CR_PDDS | PWR_CR_LPDS;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFI();
}
return 0;
So chSysLock() is called before putting the processor to sleep, but chSysUnlock() is not called after. In these examples, if I am reading it correctly the processor is going into Standby mode (lack of LPSDSR bit) which means when it gets a wakeup trigger from the RTC, the system will reset, not resume executing the while(). Is that the reason Unlock is not called? If I were only going into Stop mode, I assume it would be imperative that I called chSysUnlock() after waking up again?