cancel
Showing results for 
Search instead for 
Did you mean: 

Sometimes, WWDG was not working and CPU hang

Andy.kim
Associate

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);
}

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

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).

View solution in original post

3 REPLIES 3
Andrew Neil
Evangelist III

0693W000008xsqBQAQ.png

Pavel A.
Evangelist III

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).

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👍