2022-05-19 01:01 AM
I have a STM32L431CCT6 uC configured with CubeMX (project attached): RTC connected to LSE 32.768 kHz, auto wake up enabled. In my code, I perform the following calls:
HAL_GPIO_WritePin(LED2_RESET_ESP32_GPIO_Port, LED2_RESET_ESP32_Pin, GPIO_PinState::GPIO_PIN_RESET);
HAL_PWREx_EnableInternalWakeUpLine();
result = HAL_RTCEx_SetWakeUpTimer(&hrtc, 0x0000FFFF, RTC_WAKEUPCLOCK_RTCCLK_DIV2);
if(result == HAL_OK)
{
HAL_PWR_EnterSTANDBYMode();
}
The uC enters correctly the standby mode, it should wake up after 4 seconds, ma it never does. I tried to check if wake up interrupt is launched, removing the HAL_PWR_EnterSTANDBYMode() call, but handler code is never executed (no breakpoint hit, no led blinked).
Solved! Go to Solution.
2022-05-19 05:45 AM
That was the problem, the WUTIE bit were not set, because HAL_RTCEx_SetWakeUpTimer just set up the timer but not the interrupt. If you need to set also the interrupt, HAL_RTCEx_SetWakeUpTimer_IT must be used.
2022-05-19 01:08 AM
> handler code is never executed
Then it's not standby-mode related, is it?
Read out and check/post content of RTC, EXTI, NVIC, and any other registers which may be related to wakeup.
JW
2022-05-19 01:16 AM
Yes, it looks like it's about the RTC wake up event. Accordingly also to AN4759, chapter 2.4, I can't find if there is anything wrong in my configuration.
RTC, NVIC and EXTI registers look ok.
2022-05-19 04:09 AM
> RTC, NVIC and EXTI registers look ok.
Post them.
JW
2022-05-19 04:22 AM
2022-05-19 04:23 AM
2022-05-19 04:50 AM
Why are EXTI and RTC registers content not visible in the "before standby" file?
In the other file, RTC_CR is 0x403, i.e. WUTE is enabled but WUTIE is not. Quoting from RM:
> When the periodic wakeup interrupt is enabled by setting the WUTIE bit in the RTC_CR
> register, it can exit the device from low-power modes.
JW
2022-05-19 05:45 AM
That was the problem, the WUTIE bit were not set, because HAL_RTCEx_SetWakeUpTimer just set up the timer but not the interrupt. If you need to set also the interrupt, HAL_RTCEx_SetWakeUpTimer_IT must be used.
2022-06-08 12:34 AM
STM32L431CCU6
can you please provide the schematics
2022-06-08 01:36 AM
Please start a new thread and post clearly your question there.
JW