Skip to main content
Graduate
September 13, 2024
Question

Detect internal wake from RTC

  • September 13, 2024
  • 0 replies
  • 422 views

Hello,

I am using RTC internal wake [10 sec] using the following code:

void go_to_sleep(void)
{
	HAL_SuspendTick();
	HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 10, RTC_WAKEUPCLOCK_CK_SPRE_16BITS);

	HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
	HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
	SystemClock_Config();
	HAL_ResumeTick();
}

 

After that use following code to detect the source of the wake:

__HAL_RCC_PWR_CLK_ENABLE();

	 /* Check and Clear the Wakeup flag */
	 if(__HAL_PWR_GET_FLAG(PWR_FLAG_WUFI) != RESET)
	 {
		 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUFI);
		 printf("RTC Wake Up flag set\n\r");
	 }

	 /* Clear source Reset Flag */
	 __HAL_RCC_CLEAR_RESET_FLAGS();

 

The device wakes up every 10 seconds and toggles the LED but WUFI is not detected/ set. The RTC is set to WakeUp through Internal WakeUp so I believe WUFI should be set.

Please suggest what could be wrong.

 

Thanks

 

 

    This topic has been closed for replies.