STM32U5 Standby Mode and IWDG issue
Hello, I am seeing an issue with an STM32U5 battery powered system in the field. I use IWDG to reset the device in the occurrence of a software issue, and put the device into standby mode to sleep for periods of time before being woken up by either RTC or a wakeup pin. I was seeing cases where the devices weren't going to sleep after calling HAL_PWR_EnterSTANDBYMode, and they would proceed to drop into a while loop, and eventually reset with the IWDG. To attempt to rectify that, I attempted to continuously try to put the device into standby mode with the following code:
while (1)
{
for (int i = WWDG_IRQn; i <= DCACHE2_IRQn; i++)
{
NVIC_ClearPendingIRQ(i);
}
__HAL_PWR_CLEAR_FLAG(PWR_WAKEUP_FLAG1);
HAL_PWR_EnterSTANDBYMode();
}
My thought was that one of the interrupts or a race condition with the wakeup pin was occurring while trying to enter standby mode, preventing it from doing so. Unfortunately, I'm now seeing devices constantly stuck in this while loop, not going into standby mode, and the IWDG is no longer triggering. Is there any reason why this could be happening? I've read through the TRM, datasheet, erratas, etc. and haven't been able to find an answer. My theories are as follows:
1. Does clearing the IWDG interrupt somehow refresh the IWDG?
2. Does attempting to enter standby mode too quickly cause it to fail for some reason?
3. Are there other things preventing standby mode from being entered? Interrupts, power conditions, clocks, etc.
Any help or insight would be greatly appreciated.
