STM32U5 Can't exit STOP2 mode with LPTIM
Hi everyone,
I'm trying to enter STOP2 mode with a STM32U575 and exit from it with a LPTIM1 compare match. LPTIM1 is clocked with LSE, so it should be still working in STOP2 mode.
Here is part of my code in the main funtion:
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_LPTIM1_Init();
lptim_single(1024); //Around 2s, checked already
/* Infinite loop */
while (1)
{
/* Enter in Stop mode */
/* Set STOP2 mode when CPU enters deep sleep */
LL_PWR_SetPowerMode(LL_PWR_STOP2_MODE);
/* Set SLEEPDEEP bit of Cortex System Control Register */
LL_LPM_EnableDeepSleep();
__WFI();
LL_GPIO_TogglePin(GPIOH, LL_GPIO_PIN_0);
}
The function lptim_single:
bool lptim_single(int32_t t)
{
/* Set prescaler */
LL_LPTIM_Enable(LPTIM1);
LL_LPTIM_SetAutoReload(LPTIM1, t);
LL_LPTIM_OC_SetCompareCH1(LPTIM1, t/2);
LL_LPTIM_EnableIT_CC1(LPTIM1);
LL_LPTIM_EnableIT_ARRM(LPTIM1);
LL_LPTIM_StartCounter(LPTIM1, LL_LPTIM_OPERATING_MODE_ONESHOT);
return true;
}
It seems to enter in STOP2 mode but then it never exit unless I suspend the esecution with the debugger. Any suggestion?
