Disabling STM32 HAL IWDG or WWDG (watchdog) before STOP mode
11,009
The Independent watchdog can not be stopped in any processor mode. You have to wake up regularly to reload the watchdog. What you can do is change the prescaler to maximum so the watchdog is counting slowly.
IWDG will only be stopped if you disconnect the controller from the power supply.
Author by
Colateral
Updated on September 25, 2022Comments
-
Colateral almost 2 years
I using an STM32 (L0 5) HAL I need to disable IWDG or WWDG before entering in STOP mode. The below code is working fine until IWDG is resetting the MCU from STOP mode. For WWDG usage this is much faster and reset before HAL_PWR_EnterSTOPMode is called, despite HAL_WWDG_Refresh is called after each line. I tested also those scenarios also on Nucleo L05.
iwdgHandle.Instance = IWDG; iwdgHandle.Init.Prescaler = IWDG_PRESCALER_64; iwdgHandle.Init.Window = 4095; iwdgHandle.Init.Reload = 4095; if (HAL_IWDG_Init(&iwdgHandle) != HAL_OK) // almost 7secs until refresh has to be called { _Error_Handler(__FILE__, __LINE__); } HAL_PWR_EnableWakeUpPin(WakeSpi_Pin); HAL_PWREx_EnableUltraLowPower(); // Enable Ultra low power mode HAL_PWREx_EnableFastWakeUp(); // Enable the fast wake up from Ultra low power mode HAL_SuspendTick(); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
-
Colateral over 5 yearsSame behaviour seems to be also with WWDG. Does this can be disabled before going to STOP?
-
Colin over 5 years@Colateral No, with watchdogs generally once you set them going that's it. It's to prevent code from accidentally turning it off again in a fault state.
-
A.R.C. over 5 yearsI have to correct myself! In shutdown mode, all clocks except LSE are off. So, if your WDG is running for example on LSI, reloading is not necessary. See chapter Power control for an overview of sleep modes and clock behavior.
-
rel about 5 yearsNote: For debugging purposes, the Independent Watchdog (IWDG) can be stopped when the core is halted (see DBG_IWDG_STOP (in the Debug MCU freeze register) in the reference manual).
-
user3509549 almost 4 yearsFor WWDG, you can disable using __HAL_RCC_WWDG_CLK_DISABLE();
-
gg99 over 2 yearsNote that disabling it using __HAL_RCC_WWDG_CLK_DISABLE should be considered a brittle workaround and is not portable : I have used that approach on an stm32F4 but on a stm32G4 the same trick is not preventing a wwdg induced reset.