Skip to main content
ThorosOfMyr
Associate II
May 19, 2022 8:01 AM UTC
Solved

Why doesn't the uC STM32L431CCT6 exit standby mode with RTC wakeup event?

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).

This topic has been closed for replies.
ThorosOfMyr
ThorosOfMyrBest answer
Associate II
May 19, 2022 12:45 PM UTC

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.

9 replies

waclawek.jan
Super User
May 19, 2022 8:08 AM UTC

> 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

ThorosOfMyr
Associate II
May 19, 2022 8:16 AM UTC

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.

waclawek.jan
Super User
May 19, 2022 11:09 AM UTC

> RTC, NVIC and EXTI registers look ok.

Post them.

JW

ThorosOfMyr
Associate II
May 19, 2022 11:22 AM UTC
ThorosOfMyr
Associate II
May 19, 2022 11:23 AM UTC
waclawek.jan
Super User
May 19, 2022 11:50 AM UTC

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

ThorosOfMyr
ThorosOfMyrAuthorBest answer
Associate II
May 19, 2022 12:45 PM UTC

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.

Tkumar.2
Visitor II
Jun 8, 2022 7:34 AM UTC

STM32L431CCU6

can you please provide the schematics

waclawek.jan
Super User
Jun 8, 2022 8:36 AM UTC

Please start a new thread and post clearly your question there.

JW