With my STM32 I'm trying to configure a deepSleep mode and use RTC to generate interruption (actually each 30 seconds).
When my STM start, this one configure the RTC and directly go in Stop mode. After 30 seconds the board is waking up and use Serial to configure LoRa Radio module RN2483 with the Serial communication and also use I2C to read and write some datas. But for the configuration of the RN2483, we need to wait response (it take around 3 seconds).
After that the STM go in deepSleep mode again. This is a loop. If this periode between two deepsleep take too much time (due to wait or printf for example) the next deepSleep will be bad configured and the STM never wake up again and the power consumption is high.
Does anyone have any idea ?
Maybe I need to check some deepsleep registers or something like that ?
EDIT:
This is a picture of my state machine
For the DeepSleep configuration this is my script below
void STM32_DeepSleep(void){
//Clear bits
EXTI->PR &= 0xFF840000;
//Enter in stopmode
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON | PWR_CR_CWUF | PWR_CR_ULP | PWR_CR_FWU , PWR_STOPENTRY_WFI);
}
After some researches the problem is coming from __WFI() function. Due to a long time before, the __WFI() freeze. Maybe a watchdog inside the STM32 make the script freeze ?