Skip to main content
Andy.kim
Associate
June 28, 2022
Solved

Sometimes, WWDG was not working and CPU hang

  • June 28, 2022
  • 2 replies
  • 1381 views

My company uses the STM32G0071CB chip. but I faced some issue.

whenever I need to reboot main board, I have to reset the STM32G0071CB as wells.

so I used the WWDG for resetting the chip.

But sometimes, chip was not reset and CPU hang.(once a 400 times or randomly happen it)

I used the below code for initializing and resetting.

I didn't find anything wrong in my code.

Could you please give me any guide?

Thank you for your support in advanced.

= Code =

void Init_WWDG(void)
 
{ 
 /* Enable the peripheral clock WWDG */
 LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_WWDG);
 LL_WWDG_SetPrescaler(WWDG,LL_WWDG_PRESCALER_8); /* (1) */
 LL_WWDG_SetWindow(WWDG,0x7E); /* (2) */
 LL_WWDG_SetCounter(WWDG, 0x7E); /* (3) */
}
 
void Reset(void)
{
 SCB->VTOR = 0x0; // Reset the Vector Table back to the bootloader 
 FLASH->CR |= FLASH_CR_LOCK_Msk;
 LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_WWDG); 
 LL_WWDG_SetPrescaler(WWDG, LL_WWDG_PRESCALER_8);
 LL_WWDG_SetCounter(WWDG, 1);
 LL_WWDG_Enable(WWDG);
}

This topic has been closed for replies.
Best answer by Pavel A.

What if interrupt hits after line 13? Does some interrupt handler in your bootloader kick the WWDG?

Try to disable interrupts before line 13 (IMHO it isn't needed at all).

2 replies

Andrew Neil
Super User
June 28, 2022

0693W000008xsqBQAQ.png

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Pavel A.
Pavel A.Best answer
Super User
June 28, 2022

What if interrupt hits after line 13? Does some interrupt handler in your bootloader kick the WWDG?

Try to disable interrupts before line 13 (IMHO it isn't needed at all).

Andy.kim
Andy.kimAuthor
Associate
June 29, 2022

Hi @Pavel A.​ ,

Thank you so much. your right. The reset vector table is different bootloader and app.

so After setting the address of vector table to '0', If systick interrupt is happen, It cause the unhandled exception error.

If I disable the all irq before line 13, It is working fine.

Thank you for your support again:thumbs_up: