Skip to main content
gil_dobjanschi
Senior
May 22, 2026
Question

Wakeup from standby with RTC on STM32C5

  • May 22, 2026
  • 1 reply
  • 140 views

Hello,

 

I am using the RTC wakeup from the power standby example provided in the STM32C5 repository. The example starts the RTC wake-up timer and places the device in standby mode. The device does go to standby, and it does wake up due to the RTC wakeup interrupt; however, the RTC initialization fails after wakeup. It is worth mentioning that the only way I can get rid of this error is to power cycle the board.

The failure happens in HAL_RTC_WAKEUP_SetConfig due to RTC_WaitSyncrhroWUTW() returning an error due to  RTC_CR_WUTE being set.

static hal_status_t RTC_WaitSynchro_WUTW(void)
{
 uint32_t tickstart;

 if (LL_RTC_IsActiveFlag_INIT() == 0U)
 {
 if (LL_RTC_WAKEUP_IsEnabled() == 1U)
 {
 return HAL_ERROR; // Code returns this error
 }
 tickstart = HAL_GetTick();

 while (LL_RTC_IsActiveFlag_WUTW() == 0U)
 {
 if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
 {
 if (LL_RTC_IsActiveFlag_WUTW() == 0U)
 {
 return HAL_ERROR;
 }
 }
 }
 }

 return HAL_OK;
}

To make the example work, I had to add a call to HAL_RTC_WAKEUP_Stop() before HAL_RTC_WAKEUP_SetConfig in mx_rtc.c.

 HAL_RTC_WAKEUP_Stop(); // Added line of code
 /* Configure wake-up timer */
 hal_rtc_wakeup_config_t wakeup_config;
 wakeup_config.clock = HAL_RTC_WAKEUP_TIMER_CLOCK_RTCCLK_DIV16;
 if (HAL_RTC_WAKEUP_SetConfig(&wakeup_config) != HAL_OK)
 {
 return SYSTEM_PERIPHERAL_ERROR;
 }

 

This does not seem to be the proper solution. Do you have any suggestions of how to address this issue?

I attached the .io2 file. The project runs on Nucleo-C562RE.

 

Thank you,

-Gil

 

1 reply

EXUE.2
ST Employee
June 10, 2026

Hi,

as the reference manual of STM32C5, the steps to initial RTC wake-up timer as below:

Programming the wake-up timer
The following sequence is required to configure or change the wake-up timer auto-reload
value (WUT[15:0] in RTC_WUTR):
1. Clear WUTE in RTC_CR to disable the wake-up timer.
2. Poll WUTWF until it is set in RTC_ICSR to make sure the access to wake-up autoreload
……

it is right for you to use ‘HAL_RTC_WAKEUP_Stop()’ to clear ‘WUTE’ bit.