cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Wake-Up from Stop3 on STM32U545RE

TNaum
Associate II

I would like to use the Stop3 low-power mode on an STM32U545RE (NUCLEO-U545RE-Q board) and to wake-up the device by the RTC. I have a working example for Stop2 mode for which I largely used the inspiration from the stm32u5 workshop. But when I replace the HAL_PWREx_EnterSTOP2Mode call(s) with HAL_PWREx_EnterSTOP3Mode, the device does not wake up from the stop mode anymore. At least the current consumption drops down to 3uA so I am confident that the Stop3 mode itself is working.

The code parts of my main function which I believe are relevant look as follows:

HAL_Init();
SystemClock_Config();
SystemPower_Config();

MX_GPIO_Init();
MX_ICACHE_Init();
MX_RTC_Init();

/* The SMPS regulator supplies the Vcore Power Domains */
HAL_PWREx_ConfigSupply(PWR_SMPS_SUPPLY);

/* Enable ultra low power mode */
HAL_PWREx_EnableUltraLowPowerMode();

/* Enable the Autonomous Mode for the RTC Stop0/1/2 */
__HAL_RCC_RTCAPB_CLKAM_ENABLE();

/* Set RTC wakeup timer for 2s */
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 2, RTC_WAKEUPCLOCK_CK_SPRE_16BITS, 0);

/* Enter in Stop 3 mode */
HAL_PWREx_EnterSTOP3Mode(PWR_STOPENTRY_WFI);

 

Is there anything missing to make the RTC (interrupt) work in Stop3 mode? In the reference manual, I found that the RTC should be able to run and to wake up the CPU from Stop3 mode but I guess some configuration is missing here. Thanks in advanve for any helpful advice.

18 REPLIES 18
STea
ST Employee

Hello @TNaum ,

this is quite the expected behavior because there is a sequence which should be respected when entering and exiting from stop 3 this sequence is described in section 10.7.9 (Stop 3 mode) of RM0456.
you can see a working implementation provided in cube firmware U5 detailing entering and exiting from all stop modes using RTC.STM32CubeU5/Projects/NUCLEO-U575ZI-Q/Examples/PWR/PWR_LPMODE_RTC at main · STMicroelectronics/STM32CubeU5 (github.com).
see the sequence in main.c:

 

 

  /* STOP3 wake up global interrupt configuration */
  HAL_NVIC_SetPriority(PWR_S3WU_IRQn, 7, 7);
  HAL_NVIC_EnableIRQ(PWR_S3WU_IRQn);

 

 


Regards

In order 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.
TNaum
Associate II

Actually, I can not find this sequence or any reference to the PWR_S3WU interrupt in that reference manual section 10.7.9.

Anyways, this enables/configures another interrupt which is used to exit from stop3. Just adding these lines does not fix my issue and my device still does not wake up from stop3.

Comparing my project with the example project in CubeMX reveals that the example project has PB15 configured as PWR_WKUP7 ("Wakeup from standby and shutdown configuration"). This configuration enables the aforementioned PWR_S3WU ("PWR wake up from Stop3 interrupt") interrupt in the NVIC page. Is this somehow related to my problem?

Hello @TNaum 

You need to suspend the SysTick interrupt before entering STOP mode and resume it afterward.

Please find attached a simple project that demonstrates how to enter STOP3 mode and wake up using the RTC wakeup timer interrupt.

I have attached the IOC file, as well as the main.c and stm32u5xx_it.c files.

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

I have tried two different approaches, neither has worked.

1. I have added the HAL_SuspendTick and HAL_ResumeTick calls to my project. Still, the device does not wake up from stop3 mode.

2. I have used your ioc file and generated the corresponding project. When CubeMX warned me ("SMPS must be enabled to reach the best consumption figure. SMPS can be enabled from the Pinout tab under PWR. Do you still want to generate the code?"), I chose 'Yes'. Then, I have replaced the main.c and stm32u5xx_it.c files with the files you have supplied. The device immediately goes to stop3 mode (verified by measuring around 3uA on the IDD jumper JP4) but it does not wake up after the 20 seconds which you have configured in the code.

Have you verified your example code by running it on an actual board? If so, I am really confused here. Could you supply your full project then, maybe?

Hello @TNaum 

How do you know that it doesn't wake up??

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

The current consumption stays at 3uA and the HAL_PWREx_EnterSTOP3Mode call is not inside the infinite loop, it happens just once. So after waking up, the MCU should stay in run mode and consume a lot more.

Haifa_BEN_HSOUNA
ST Employee

Hello TNaum,

To wake-up the system from Stop 3 low-power mode, it is mandatory to redefine PWR_S3WU_IRQHandler (From NVIC table) to handle the interrupt request, then clearing wake-up flags.

The following code describes the function which must added to "stm32u5xx_it.c", and please don't forget to add its prototype into the header file "stm32u5xx_it.h":

 

void PWR_S3WU_IRQHandler(void)
{
  HAL_PWREx_S3WU_IRQHandler(PWR_WAKEUP_PIN1 | PWR_WAKEUP_PIN2 | PWR_WAKEUP_PIN3 |\
                            PWR_WAKEUP_PIN4 | PWR_WAKEUP_PIN5 | PWR_WAKEUP_PIN6 |\
                            PWR_WAKEUP_PIN7 | PWR_WAKEUP_PIN8);
}

 

I wish this helps you.

Best regards,

Haifa BEN HSOUNA.

Unfortunately, my board still stays at 3uA all the time.

Since this seems to be a rather simple problem, could you possibly supply a full (tested) example project for the NUCLEO-U545RE-Q which just goes to stop3 mode and wakes up again after a short amount of time?

TNaum
Associate II

@STea @Saket_Om @Haifa_BEN_HSOUNA Do you have any more ideas what we could try?