Skip to main content
Associate
July 23, 2025
Question

STM32CubeMX generate MX_WWDG_Init() causes system reset forever on STM32F429IGT6 board

  • July 23, 2025
  • 1 reply
  • 224 views

void MX_WWDG_Init(void)
{

/* USER CODE BEGIN WWDG_Init 0 */

/* USER CODE END WWDG_Init 0 */

/* Peripheral clock enable */
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_WWDG);

/* USER CODE BEGIN WWDG_Init 1 */

/* USER CODE END WWDG_Init 1 */
LL_WWDG_SetCounter(WWDG, 64);
LL_WWDG_Enable(WWDG);
LL_WWDG_SetPrescaler(WWDG, LL_WWDG_PRESCALER_1);
LL_WWDG_SetWindow(WWDG, 64);
/* USER CODE BEGIN WWDG_Init 2 */

/* USER CODE END WWDG_Init 2 */

}

 

void MX_IWDG_Init(void)
{

/* USER CODE BEGIN IWDG_Init 0 */

/* USER CODE END IWDG_Init 0 */

/* USER CODE BEGIN IWDG_Init 1 */

/* USER CODE END IWDG_Init 1 */
LL_IWDG_Enable(IWDG);
LL_IWDG_EnableWriteAccess(IWDG);
LL_IWDG_SetPrescaler(IWDG, LL_IWDG_PRESCALER_4);
LL_IWDG_SetReloadCounter(IWDG, 4095);
while (LL_IWDG_IsReady(IWDG) != 1)
{
}

LL_IWDG_ReloadCounter(IWDG);
/* USER CODE BEGIN IWDG_Init 2 */

/* USER CODE END IWDG_Init 2 */

}

int main(void)
{
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 15, 0));
SystemClock_Config();
MX_GPIO_Init();
MX_DMA_Init();
MX_USART1_UART_Init();

char data[128];
static int startup_count = 0;
sprintf(data, "Startup count: %d\n", startup_count++);
UART_SendData((const uint8_t*)data, strlen(data));

MX_WWDG_Init();
MX_IWDG_Init();

while (1)
{
WWDG_Feed(); // Feed WWDG first
IWDG_Feed();
LL_mDelay(10);
sprintf(data, "Loop running, count: %d\n", startup_count++);
UART_SendData((const uint8_t*)data, strlen(data));
}
}

 

 

Cutecom shows "Startup count: 0" forever and WWDG_Feed() and IWDG_Feed() not called since system reset before entering while() loop.

 

1 reply

TDK
Super User
July 23, 2025

 

WWDG must be refreshed within a particular window. You're refreshing too early which leads to the reset.

The code you attached doesn't match the code in your post.

void MX_WWDG_Init(void)
{
 LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_WWDG);
 LL_WWDG_SetPrescaler(WWDG, LL_WWDG_PRESCALER_8); // Divide PCLK1 by 8
 LL_WWDG_SetCounter(WWDG, 127); // Start at max counter value
 LL_WWDG_SetWindow(WWDG, 80); // Allow refresh when counter is >= 80
 LL_WWDG_Enable(WWDG);
}

 Based on these settings, you must refresh the WWDG when the counter is lower than 80 and above 64 (code comments are wrong).

"If you feel a post has answered your question, please click ""Accept as Solution""."
snowuylAuthor
Associate
July 23, 2025

Thanks for your reply. Does ST provide API to check if WWDG can be refresh or how to implement it by myself?