HAL IWDG Refresh causes watchdog to immediately trip

I’m experiencing an odd issue with a Nucleo L432KC devboard from ST. When I start the IWDG using the following code:

IWDG_HandleTypeDef IwdgHandle;

IwdgHandle.Instance = IWDG;
IwdgHandle.Init.Prescaler = IWDG_PRESCALER_256;
IwdgHandle.Init.Reload    = 30 * 125; 
// 30 sec * 125 watchdog pulses per sec using the LSI frequency of ~32kHz and prescaler 256

and then try to “pet” the watchdog using the following:

  HAL_IWDG_Refresh(&IwdgHandle); // resets the IWDG counter back to 0

The device immediately resets and the RCC_FLAG_IWDGRST is set, indicating the reset was due to the watchdog timeout.

This issue using the same code worked perfectly on a Nucleo L152RE (the only difference is the dependencies now are for the L4xx series instead of L1xx)

Any ideas on why this reset is occuring?

Got it solved -

I wasn’t setting the .Window option of the IWDG, so when I tried to refresh the value in the countdown it wasn’t inside the window yet since the value of .Window defaults to 0, and thus the watchdog would trigger a reset.