Sleep + Wakeup on STM32U575 with FreeRTOS not working as expected

Hi guys,

I need some help with implementing shutdown mode entry & wakeup by RTC/wakeup pin.
To bring some background into this - I’m moving my code from STM32L4P5 to STM32U575. On L4 MCU everything worked fine, I’ve created tasks that I’ve needed, and after completing all the work I’ve set the MCU to shutdown mode in one of the tasks. Only thing that could wake up the MCU was RTC alarm or pushing the button which was connected to one of the wakeup pins.

Now, when I moved this code to U5 MCU, the shudown mode/wakeup is not working anymore. I’ve tryied to run shudown / wakeup procedure on bare MCU without FreeRTOS and everything works as expected, so I’m assuming that the procedure is correct. The problem comes when I try to enter shutdown after vTaskStartScheduler(). After kernel starts running there is no way I can set the MCU to shutdown mode nor waking it up. Is there some extra step that I am missing ?

Shutdown procedure :


Other than setting up the SysTick timer and interrupt to create the RTOS tick interrupt, peripheral initialisation is performed by the startup code and main() before the scheduler starts.
Are you using the exact same initialisation code in the non RTOS case, which you say is working, and the RTOS case, which you say isn’t?

I tried those statements in a FreeRTOS task on STM32U585 and it appears to enter shutdown mode.

By any chance are you masking interrupts for those statements? Specifically __disable_irq(); or __asm volatile ( "cpsid i" ); etc. If you are, then any pending interrupt will prevent shutdown mode. And with FreeRTOS, there’s an interrupt coming around every millisecond (typical), so maybe that’s the issue.