Skip to main content
Visitor II
December 4, 2023
Solved

STM32H7 dual core -- watchdog not firing?

  • December 4, 2023
  • 3 replies
  • 1886 views

So, this is a weird one. We're attempting to bring up watchdog timers on both cores of our product.

We're not seeing the CM4 WWDG watchdog fire when we intentionally lock the CM4 in a while loop with no refreshes to the watchdog timer. (I haven't tried the CM7 core yet with similar code).

I understand that each core has a watchdog timer (well, two, the WWDG and the IWDG). Right now to begin with we are enabling the watchdog on only a single core, the CM4 core, like so:

__HAL_RCC_WWDG1_CLK_ENABLE();
 
/* Clear reset flags in any case */
__HAL_RCC_CLEAR_RESET_FLAGS();
 
/* Enable system wide reset */
HAL_RCCEx_WWDGxSysResetConfig(RCC_WWDG1);
 
// These numbers result in a timeout of about 300ms
g_watchDogHandle.Instance = WWDG1;
g_watchDogHandle.Init.Prescaler = WWDG_PRESCALER_128;
    g_watchDogHandle.Init.Counter = 0x7F;
    g_watchDogHandle.Init.Window = 0x7F;
g_watchDogHandle.Init.EWIMode = WWDG_EWI_DISABLE;
 
#ifdef DEBUG
//return;
#endif
 
HAL_WWDG_Init(&g_watchDogHandle);
 

We enter the while loop on one screen of our application, using just a 

while (true) {}

 

I've verified with the debugger that we're both entering the watchdog initialization code, as well as the while loop, and let let it sit for well over ten minutes.

On a lark, I enabled the EWIMode and put a breakpoint in  WWDG_IRQHandler(), and don't see that entered either.

This seems very, very weird. Am I missing something?

    This topic has been closed for replies.
    Best answer by Ray, KF6GPE

    Thanks to both of you for the suggestions!

    It was actually a much dumber mistake on my part --- I was trying to enable the CM7 watchdog on the CM4 core. For the next person on the internet who runs into this, here's some code that works:

    	__HAL_RCC_WWDG2_CLK_ENABLE();
    
    	/* Clear reset flags in any case */
    	__HAL_RCC_CLEAR_RESET_FLAGS();
    
    	/* Enable system wide reset */
    	HAL_RCCEx_WWDGxSysResetConfig(RCC_WWDG2);
    
    	// These numbers result in a timeout of about 300ms
    	g_watchDogHandle.Instance		= WWDG2;
    	g_watchDogHandle.Init.Prescaler	= WWDG_PRESCALER_128;
     g_watchDogHandle.Init.Counter	= 0x7F;
     g_watchDogHandle.Init.Window	= 0x7F;
    	g_watchDogHandle.Init.EWIMode	= WWDG_EWI_DISABLE;
    
    #ifdef DEBUG
    	return;
    #endif
    
    	HAL_WWDG_Init(&g_watchDogHandle);  

     

    3 replies

    Super User
    December 4, 2023

    Does the WWDG_CR register indicate that it's active? Is the counter counting down?

    Graduate II
    December 4, 2023

    What are you doing with the NRST pin?

    What's it connected too? Driven High, or driven by some other device or circuit?

    Ray, KF6GPEAuthorAnswer
    Visitor II
    December 4, 2023

    Thanks to both of you for the suggestions!

    It was actually a much dumber mistake on my part --- I was trying to enable the CM7 watchdog on the CM4 core. For the next person on the internet who runs into this, here's some code that works:

    	__HAL_RCC_WWDG2_CLK_ENABLE();
    
    	/* Clear reset flags in any case */
    	__HAL_RCC_CLEAR_RESET_FLAGS();
    
    	/* Enable system wide reset */
    	HAL_RCCEx_WWDGxSysResetConfig(RCC_WWDG2);
    
    	// These numbers result in a timeout of about 300ms
    	g_watchDogHandle.Instance		= WWDG2;
    	g_watchDogHandle.Init.Prescaler	= WWDG_PRESCALER_128;
     g_watchDogHandle.Init.Counter	= 0x7F;
     g_watchDogHandle.Init.Window	= 0x7F;
    	g_watchDogHandle.Init.EWIMode	= WWDG_EWI_DISABLE;
    
    #ifdef DEBUG
    	return;
    #endif
    
    	HAL_WWDG_Init(&g_watchDogHandle);