/*-----------------------------------------------
名称:看门狗溢出实验 按键不停喂狗
内容:通过按键喂狗防止溢出复位 看门狗演示程序
在16383个机器周期内必须至少喂狗一次
------------------------------------------------*/
#include <reg52.h>
sfr WDTRST = 0xA6;
sbit K1 = P3^0;
sbit K2 = P3^1;
sbit LED1=P1^1;
sbit LED2=P1^2;
void DelayUs2x(unsigned char t);//us级延时函数声明
void DelayMs(unsigned char t); //ms级延时
/*------------------------------------------------
主函数
------------------------------------------------*/
main()
{
LED1=0;
DelayMs(100);
LED1=1;
DelayMs(100);
TMOD=0x01;
TH0=0xc6; //定时16ms
TL0=0x66;
EA=1;
ET0=1;
WDTRST=0x1e; //在程序初始化中激活看门狗。
WDTRST=0xe1; //先