#include "iwdg.h"
void IWDG_Init(u8 prer ,u16 rlr)//两个参数prer是预分频系数 rlr是重装栽值
{
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
IWDG_SetPrescaler(prer);
IWDG_SetReload(rlr);
IWDG_ReloadCounter();
IWDG_Enable();
}
int main(void)
{
delay_init(); //延时函数初始化
LED_Init(); //初始化与LED连接的硬件接口
KEY_Init();
BEEP_Init(); //初始化蜂鸣器IO
IWDG_Init(4,625);
delay_ms(200);
LED0=0; //先点亮红灯
while(1)
{
if(KEY_Scan(0)==KEY0_PRES)
{
IWDG_ReloadCounter();
}
}
}