2022-12-14 07:52 AM
This isn't a question - I just spent a LONG time finding this so I figured I'd post my solution in case anyone else runs into it.
The STM32U5 seems largely backward compatible with STM32L4 source code, but in order to have certain low power peripherals wake the CPU from STOP2 mode there is one extra step I had to take - and it wasn't completely obvious to me and took a long time to stumble across.
By default the RTC will NOT wake the CPU from STOP2 - although the RTC will continue to run, and it will generate interrupts - which can be seen in the NVIC ISPR. I couldn't figure out why the RTC was running and generating a pending interrupt (not masked by PRIMASK) and yet it did not wake the CPU from STOP2.
I found the solution is to set the RTCAPBAMEN: bit in RCC_SRDAMR (section 11.8.45 in RM0456). There's a macro to do this: `__HAL_RCC_RTCAPB_CLKAM_ENABLE();`. There are corresponding macros for LPUART, I2C3 etc.
If LP peripherals are not waking the CPU from STOP mode check to see if you should be setting bits in RCC !
2022-12-19 10:19 AM
Hi @Community member ,
Good to hear you made it work and thanks for sharing your solution in our forum, it may be very helpful for Community users. :thumbs_up:
Imen
2023-05-17 08:57 AM
Thanks for sharing, this helped me port from stm32L5 to stm32u5. Was having a really hard time getting a low power timer to wake up the MCU from STOP2 mode
This is my questions: https://community.st.com/s/question/0D53W00002GYwT0SAL/lptim-interrupt-cant-wake-stm32u5-from-stop-low-power-mode