Skip to main content
Explorer II
August 15, 2024
Solved

RTC Wake-Up from Stop3 on STM32U545RE

  • August 15, 2024
  • 11 replies
  • 8631 views

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.

    This topic has been closed for replies.
    Best answer by STealthy_sneezer

    Hi @TNaum,

    I apologize for the oversight. It seems the hal_RTC.c files were unintentionally linked to my MX repository.

    I'm sending you a new project, which I have tested on another computer to ensure it works correctly. In this example code, LD2 should light up after 10 seconds when we exit STOP3 mode. You can also check the power consumption on the IDD jumper. Please let me know if you encounter any issues.

    If anything about the configuration is unclear, feel free to send us your code, and I'll be happy to take a look.

    Best regards

     

    11 replies

    ST Employee
    August 15, 2024

    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

    TNaumAuthor
    Explorer II
    August 15, 2024

    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?

    Technical Moderator
    August 16, 2024

    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.

    ST Employee
    August 19, 2024

    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.

    TNaumAuthor
    Explorer II
    August 19, 2024

    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?

    TNaumAuthor
    Explorer II
    August 23, 2024

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

    Technical Moderator
    August 23, 2024

    Hello @TNaum 

     

    Your issue has been reported internally. We will come back to you as soon as possible. 

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

    ST Employee
    August 23, 2024

    Hello @TNaum,

    I have ported an example for STM32U545RE "Stop 3 mode with RTC Timer wake-up". The applicative part is functional (Go to Stop 3 and wake-up with RTC Timer, check the IRQHandler when interrupt occurs).

    But as you mentioned, the current remains at 3µA after wake-up, which is not expected. We have reported this issue internally.

    You can find the example in the attached Zip folder.


    I hope this helps !

    ST Employee
    August 27, 2024

    Exactly, but even after removing this function from my code, the behavior remains unchanged (same current value).

    TNaumAuthor
    Explorer II
    September 4, 2024

    Hi,

    is there any progress on this issue? If not yet, can you estimate when we can expect an update?

    Best regards

    TNaumAuthor
    Explorer II
    September 27, 2024

    Hi @Saket_Om ,

    you said the issue has been reported internally. Have you seen any results on this?

    Best regards

    Technical Moderator
    September 27, 2024

    Hello @TNaum 

    We are actively working on the ticket and will provide you with an update as soon as possible.

    Visitor II
    October 16, 2024

    Hello,

    I observed the same issue with STM32U585VIT6Q. So far I noticed STOP2 + RTC 1 Hz 1 minute wakeup works fine, but the current consumptions remains in the STOP3 value range after the 1 minute and the controller remains unresponsive.

    I will investigate further and post my findings here.

    Kind regards
    Benedict

    ST Employee
    October 16, 2024

    Hi @TNaum,

    I would like to provide a quick update on your issue.

    I've ported the example code "PWR_LPMODE_RTC" from STM32U575xx to STM32U545xx. You will find the project attached to this post; please check it out.

    I managed to enter STOP3 mode and wake up from it with the RTC alarm. With the provided code, I observe a current consumption down to ~300uA in STOP3 and back to ~8.4mA in Run mode. Though it's still far from 3uA, it does prove that we repeatedly enter and leave STOP3 mode.

    Please note that PWR debug pins: PWR_CSLEEP, PWR_CDSTOP, and PWR_SRDSTOP cannot be monitored in STOP3 mode as they are generated in the core domain and are consequently not driven.

    If your values are correct, it may be worth conducting further investigation into power consumption. Please tell me what you used to measure the current (tools, setup, etc.).

    Best regards.

     

     

     

    TNaumAuthor
    Explorer II
    October 17, 2024

    Hi @STealthy_sneezer ,

    I am sorry but your project is somewhat broken:

    1. It contains hard-coded paths to your development machine (see `.cproject` file lines 47 to 53)
    2. In CubeMX, the RTC is not even enabled. So even after fixing those paths manually to the `Drivers` directory in the project, it does not build.

    Would it be possible to supply a working example which can be reproduced on another machine?

    Additionally, 300 uA just seems too much current for STOP3 mode. First, how can we be sure that the system actually is in STOP3 mode? Second, what is the point of using this if it is not achieving the lowest power consumption? Third, based on my experience with other STM32 MCUs and the STOP2 mode on exactly this MCU, I find 3uA very plausible, 300 uA seems wrong in my opinion, at least if you can not explain the extra current.

    Regarding my setup: I used the NUCLEO-U545RE-Q board and measured the current at the IDD jumper using a regular multimeter. I guess this should work because it is designed for this purpose, right?

    So I consider this issue not yet solved, please don't stop investigating. Thanks for your effort.

    Visitor II
    October 17, 2024

    One quick update:

    I found the the wakeup source selection in the manual and learned of its existance:

    initdb_0-1729153129516.png

    I also noticed that i configured the sleep duration not to 1 minute but to 30 minutes last week since i testet the sleep current. So user error on my side.

    But I have on question: is the wakeup source selection required and if yes can the wakeup pins of wkup7 be used and the rtc wakeup at the same time or are they exclusive?

    ST Employee
    October 22, 2024

    Hi @TNaum,

    I fixed the code that contained local references. I recommend opening it with CubeIDE.

    Please tell me if you have any trouble running it.

    About the power consumption, I am using a power shield on the VDD selection pin (JP5). So the measured 300uA is not just the MCU current but also the level shifter, the SMPS and basically every other peripherals that use VDD.

    Using your setup with the amperemeter at IDD JP4, I do get about 3uA in STOP3, which is the MCU power consumption.

    In fact, in Run mode I measure 720uA on JP4 and 3uA when in STOP3. After exiting, it goes back to 550uA. You can compare it with the other Low power modes with that code.

     

    Best regards

     

     

    TNaumAuthor
    Explorer II
    October 30, 2024

    Hi @STealthy_sneezer ,

    sorry to bother you again, but could you please fix the project? It is broken in the same way as before:

    1. Hard-coded paths to your development machine, in `.cproject` lines 47 to 53
    2. The RTC is still not enabled in the .ioc file. So I can not regenerate the Drivers directory.

    Could you maybe validate that it is fixed by trying it on a different machine?

    Thanks a lot and best regards

    ST Employee
    November 5, 2024

    Hi @TNaum,

    I apologize for the oversight. It seems the hal_RTC.c files were unintentionally linked to my MX repository.

    I'm sending you a new project, which I have tested on another computer to ensure it works correctly. In this example code, LD2 should light up after 10 seconds when we exit STOP3 mode. You can also check the power consumption on the IDD jumper. Please let me know if you encounter any issues.

    If anything about the configuration is unclear, feel free to send us your code, and I'll be happy to take a look.

    Best regards

     

    TNaumAuthor
    Explorer II
    December 19, 2024

    Hi @STealthy_sneezer ,

    sorry for my late response but I have been very busy the last weeks.

    This project looks good. I can verify that the STOP3 current goes down to around 3uA on the IDD jumper and I can verify the wakeup using the LED. Thanks, I will use this as a starting point for my work.

    I do not see the same current consumption before and after the STOP3 mode yet, but I guess I can figure it out myself. I will mark this as solved.

    Thanks