cancel
Showing results for 
Search instead for 
Did you mean: 

Standby and Shutdown mode in stm32u585 using RTC

shivss
Associate II

Hi,

  I am on stm32u585 IOT dev board for low power modes am using RTC wakeup the sleep and stop 1,2 and 3 are working fine but standby and shutdown is not working ? my code 

 
void sleep(int mode, int seconds ) {

if (seconds <= 0) return;

 HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);

 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);

uint32_t wakeup_counter  (uint32_t)(seconds  2048);

 HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, wakeup_counter, RTC_WAKEUPCLOCK_RTCCLK_DIV16, 0);




switch (mode) {

case 0: // Sleep

 HAL_SuspendTick();

HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);

 HAL_ResumeTick();

break;

case 1: // Stop0

 HAL_SuspendTick();

 HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);

break;

case 2: // Stop1

 HAL_SuspendTick();

 HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);

break;

case 3: // Stop2

 HAL_SuspendTick();

 HAL_PWREx_EnterSTOP3Mode(PWR_STOPENTRY_WFI);

break;

case 4: // Standby

 __HAL_PWR_CLEAR_FLAG(PWR_WAKEUP_ALL_FLAG | PWR_FLAG_SBF);

 HAL_PWR_EnterSTANDBYMode();

break;

case 5; // Shutdown/DeepSleep

 __HAL_PWR_CLEAR_FLAG(PWR_WAKEUP_ALL_FLAG | PWR_FLAG_SBF);

 HAL_PWREx_EnterSHUTDOWNMode();

break;

default:

break;

 }

}

void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc) {

 HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);

 SystemClock_Config();

 HAL_ResumeTick();
}

 

10 REPLIES 10
NFern.1
Associate III

Hi @shivss @pyszny 

Could you figure out the correct configuration to wake-up from Shut-down using RTC Alarm for U5x MCUs? Please share your solution if possible. Thanks!