STM32F0独立看门狗简例:
//wdt:复位计数周期(ms) wdt最大值3276(ms)
void WDG_Config(uint16_t wdt)
{
if(RCC_GetFlagStatus(RCC_FLAG_IWDGRST) != RESET)
RCC_ClearFlag();
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
IWDG_SetPrescaler(IWDG_Prescaler_32); //40khz分频32
IWDG_SetReload(wdt*40/32); //设定重装载值
IWDG_ReloadCounter(); //喂狗
IWDG_Enable();
}
喂狗代码当然是:
IWDG_ReloadCounter(); //喂狗
|
|