cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS app wakes up earlier than RTC requested from standby

Hi,

I have developed an application for the STM32C562RET microcontroller that wakes up the MCU from standby mode, initially based on an example provided by ST. The non-FreeRTOS version of this application works fine; it wakes up the MCU from standby using the RTC in 3 seconds. Subsequently, I created a FreeRTOS version of the same application that starts a task. When the user presses a button, the MCU enters the standby low power state using the code below.

HAL_RTC_WAKEUP_Start(HAL_RTC_WAKEUP_IT_ENABLE);

HAL_PWR_CleanPreviousSystemPowerMode();

LL_PWR_ClearFlag_SB();

HAL_SuspendTick();
HAL_PWR_EnterStandbyMode();

The MCU does wake up, but not at the specified time interval (3 seconds) specified in the ioc2 file in the RTC wakeup configuration. The wakeup time is less than or equal to the time specified in the configuration (between 0 and 3 seconds), seemingly at random.

Do you have any suggestions on how to make the MCU wake up after the specified RTC wakeup time interval?

Thanks,

-Gil

 

2 REPLIES 2

The problem was caused by the improper initialization of the RTC upon coming out of standby mode. 

mx_rtc_init() in mx_rtc.c was modified as follows:

  /* Exit init mode */
  if (HAL_RTC_ExitInitMode() != HAL_OK)
  {
    return SYSTEM_PERIPHERAL_ERROR;
  }

  // ---- Added code BEGIN
  if (LL_PWR_IsActiveFlag_SB() == 1U) {
    HAL_RTC_WAKEUP_Stop();
  }
  // ---- Added code END

  /* 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;
  }

 The MCU comes out of standby mode after the specified RTC wakeup time every time.

 

Hello @gil_dobjanschi 

Thank you for bringing this issue to our attention.

I reported this internally.

Internal ticket number: CDM0063074 (This is an internal tracking number and is not accessible or usable by customers).

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om