AnsweredAssumed Answered

Change IWDG timeout at runtime

Question asked by peter.hug on Jan 22, 2014
Hi

I'm porting a software from STM32F101/STM32F103 to STM32F0x family of uC. I need to change the watchdog timeout during runtime. On the F101/F103 this worked. On F0x it seems to fail. For me it looks as if after an attemp to change the timeout a reload of the watchdog does not work any more. Therefore the watchdog counter reaches zero. And for shure the uC resets after a while.

The ST document AN4088 "Migrating from STM32F1 to STM32F0" states in chapter 4.16 that all mentioned families complies to the same specification. The only enhancement in STM32F0 is that it contains a window feature that I am not going to use.

I use the following code:
void WatchdogDriver::setWatchdogTimeoutMs(const uint16_t timeoutMs) {
     uint8_t prescaler = 0;
     uint16_t reloadValue = 0;
     // Calculate prescaler and reload from the desired timeout.
     calculatePrescalerAndReload(timeoutMs, prescaler, reloadValue);
     IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
     // Set clock prescaler
     (void)IWDG_SetPrescaler(prescaler);
     // Set reload value
     (void)IWDG_SetReload(reloadValue);
     IWDG_WriteAccessCmd(IWDG_WriteAccess_Disable);
     if (IWDG_IsEnabled()) {  
          // IWDG_Enable has been called once before.
          // Overtake new settings.
          IWDG_Enable();
          while ((IWDG_GetFlagStatus(IWDG_FLAG_PVU) == SET) || (IWDG_GetFlagStatus(IWDG_FLAG_RVU) == SET)) {
               // Wait until hardware is ready for configuration.
          }
          IWDG_ReloadCounter();
     }
}

Any idea why the change of the watchdog timeout does not work on STM32F0x? Thanks for all advices.

Outcomes