2022-03-16 12:00 PM
I am using an LPTIM1 with a 64 Prescaler and a count of 15360 which, with an external 32.768kHz watch crystal, gives a 30 second period. With an IWDG with a Prescaler of 256 and a 32kHz gives 32 seconds. The device should go into STOP2, wake up from the LPTIM1 and reset the watchdog. But for some reason, the watchdog gets tripped repeatedly. I can give more details if required, but I am a bit stumped on how to proceed. Thanks.
2022-03-16 05:19 PM
Be aware that the tolerance on IWDG period is very large. Disable the watchdog and verify your LPTIM interrupt is triggering at an appropriate interval. Then enable IWDG and see how often it resets.
2022-03-17 03:51 AM
The LPTIM interrupt appears to be working fine until the PVD threshold is crossed, then on the first STOP2 sleep after that the timer is never triggered so the IWDG is tripped. I have the PVD threshold set to 2.6v (Level 4) which is well within the operating conditions of the chip, could this be the reason that STOP2 is faulting?
2022-03-17 06:48 AM
Maybe, depending on how you handle PVD. Why isn't your voltage steady? How do you know it isn't dropping even further?
2022-03-17 06:57 AM
The system will eventually be running off a LiFePO4 cell with a solar panel, but for now im running it off of a bench supply for testing. I know it still has enough power as when I ground the reset pin the board restarts and outputs data to the UART. Although after a reset at a voltage lower than the PVD it board never enters low power mode. I have also tried increasing the threshold to its max (2.9v) and the exact same behavior occurs at the boundary.
I am using the PVD interrupt handler like this:
void PVD_PVM_IRQHandler( void ){
...
if (PVD_callback != NULL) PVD_callback(1);
if (PWR->SR1 & PWR_SR1_WPVDF) PWR->SCR |= PWR_SCR_CWPVDF; //Clear PVD Wakeup Flag
if (EXTI->PR1 & EXTI_PR1_PIF16) EXTI->PR1 |= EXTI_PR1_PIF16; //Clear EXTI Pending bit
...
}
This then causes a in the main loop the "WaitForCharge()" function to run which checks the "PWR->SR2 & PWR_SR2_PVDO" to see if the supply has reached the threshold again, otherwise it will enter STOP2 and should be woken up by the LPTIM to go through this function again.