Reputation: 111
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.
This is my deepSleep configuration
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 I know that the problem is coming from the __WFI() function. This one is called inside the HAL_PWR_EnterSTOPMode function.
Sorry I don't have enougth reputation to post images of my state machine
Does anyone have any idea ?
Maybe I need to check some deepsleep registers or something like that ?
Thank you for your help Regards Simon
Upvotes: 1
Views: 667
Reputation: 1
Probably you cleared the wrong bit. The RTC wakup is in EXTI line 20. Also, you should use the functions and macros provided by the library for setting and clearing bits. For example, you will need this for clearing the RTC wakeup bit in EXTI module:
__HAL_RTC_EXTI_CLEAR_FLAG(RTC_EXTI_LINE_WAKEUPTIMER_EVENT);
However, I have never used RTC for waking up from low-power mode but don't you need to clear the flag in RTC module as well?
Upvotes: 0
Reputation: 935
You're clearing the EXTI-PR register incorrectly.
They are rc_w1
, thus: EXTI->PR = EXTI_PR_PR15
a single write 1 suffices.
Upvotes: 2