事例代码:
代码
//配置硬件看门狗
void IWDG_Configuration(void)
{
//喂狗标记
extern u8 isReloadIWDG;
//将看门狗的复位实现设置为 3276.8 ms
/* Enable write access to IWDG_PR and IWDG_RLR registers */
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
/* IWDG counter clock: 40KHz(LSI) / 32 = 1.25 KHz */
IWDG_SetPrescaler(IWDG_Prescaler_32);
/* Set counter reload value to 0x0fff */
IWDG_SetReload(0x0fff);
/* Reload IWDG counter */
IWDG_ReloadCounter();
/* Enable IWDG (the LSI oscillator will be enabled by hardware) */
IWDG_Enable();
//喂狗标记
isReloadIWDG=0x08;
}
void IWDG_Configuration(void)
{
//喂狗标记
extern u8 isReloadIWDG;
//将看门狗的复位实现设置为 3276.8 ms
/* Enable write access to IWDG_PR and IWDG_RLR registers */
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
/* IWDG counter clock: 40KHz(LSI) / 32 = 1.25 KHz */
IWDG_SetPrescaler(IWDG_Prescaler_32);
/* Set counter reload value to 0x0fff */
IWDG_SetReload(0x0fff);
/* Reload IWDG counter */
IWDG_ReloadCounter();
/* Enable IWDG (the LSI oscillator will be enabled by hardware) */
IWDG_Enable();
//喂狗标记
isReloadIWDG=0x08;
}