Watchdog timer - STOP while debugging

The following is the suggested code for stopping the WDT while HALTED in debug mode

    DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_IWDG_STOP;
    iwdg_prescaler preScale = IWDG_PRE_256;
     // 1.5 minutes to boot  (I set it very long to allow me to debug, while the halt is not working)
    iwdg_init(preScale, 12000);

However the compiler complains that
DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_IWDG_STOP;

Neither APB1FZ is a member of DBGMCU, nor does it find the DBGMCU_APB1_FZ_DBG_IWDG_STOP to set the register.

Anyone have any success with the IWDG and halting during debug, by some other method?

You probably need to #include some watchdog code header.

The watchdog code - without the DBGMCU line works OK

DBGMCU_APB1_FZ_DBG_IWDG_STOP - this does not appear anywhere in the 3.3.0 board manager directory

I decided to try the HAL method (there is an IWDG1 and a 2 depending on the core)

#include "stm32h7xx_hal.h"

    __HAL_DBGMCU_FREEZE_IWDG1(); 

This compiled OK. Will test to see if it actually works during debug a little later.

Okay, the code you posted might belong to the low level (ll) library. Not sure. But the HAL might be an improvement anyway.

Forgot to update the post - I can confirm that the WDT works. Here is the code

void loop() {
// put your main code here, to run repeatedly:
#ifdef ALLOW_WDT
  iwdg_feed();
#endif
  rtos::ThisThread::sleep_for(mbed::chrono::milliseconds_u32((uint32_t)2000L));
}

in setup or elsewhere
#ifdef ALLOW_WDT
  //DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_IWDG_STOP;
  __HAL_DBGMCU_FREEZE_IWDG1();
  iwdg_prescaler preScale = IWDG_PRE_256;  // 1.5 minutes to boot - can adjust
  iwdg_init(preScale, 12000);                              //       can adjust
#endif
1 Like