Huh, dunno, maybe this helps you. I use it to start the watchdog with max timeout (about half a minute at 64 MHz).
static void watchdog_init() { if (RCC_GetFlagStatus(RCC_FLAG_IWDGRST)) printf(''there was a watchdog reset\n''); /* lets not ClearFlag, because rtc init does it for us */ IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); /* 0xfff*256/(30..60)khz -> 17-35s */ IWDG_SetPrescaler(IWDG_Prescaler_256); IWDG_SetReload(0xfff); IWDG_ReloadCounter(); IWDG_Enable(); /* stop watchdog when core is stopped (debugging) */ DBGMCU_Config(DBGMCU_IWDG_STOP, ENABLE); }
the register CR of DBGMCU is at 0, so the bit DBG_IWDG_STOP is at 0 (0: The watchdog counter clock continues even if the core is halted, based on the datasheet). I had also tried to remove the debugger but without any success. By looking at the interrupt vector in the datasheet, I can see that there are the Non Maskable Interrupt, the IWDG interrupt, Hardfault Interrupt, and all the maskable interrupts with configurable priorities. My question is, if there is a non maskable interrupt, can we say that the IWDG is a maskable interrupt ? and if so, where can I enable this interrupt ? Regards
I experienced the exact same symptoms and it turned out that the watchdog could not reset the STM32 because an external power monitor chip was forcing the reset pin high. I disconnected the power monitor chip so that the only thing tied to the micro's reset pin was a 10K pull-up resistor, and the watchdog was suddenly able to reset the processor exactly as expected. As a side note, forcing the reset pin high was also preventing software resets from working correctly. Hope this saves someone the pain I went through, Brian
As a side note, forcing the reset pin high was also preventing software resets from working correctly.
Yeah, seen that before, hope you didn't waste too much time. Usually someone driving a -RESET pin with a push-pull driver rather than an open-collector/drain one.
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..