在这里,简单说明一下其看门狗的使用。STC单片机的看门狗一旦启动,就不能停止,其看门狗溢出时间可以利用STC单片机用户手册计算,其简单举例如下:
#i nclude //STC单片机头文件
#define uint unsigned int
#define uchar unsigned char
sbit led=P1^0;
//=================================================================
// 函数名称 :void delay (uint us)
// 函数功能 :延时
// 入口参数 :us 延时时间的长短
// 出口参数 :无
//=================================================================
void delay (uint us)
{
while(us--);
}
main()
{
WDT_CONTR=0x3c; //启动看门狗
led=1; //点亮LED
delay(100);
led=0;
delay(100); //熄灭LED
while(1)
{
WDT_CONTR=0x3c; //喂狗,若屏蔽掉该位,则看门狗溢出后复位,LED灯不停闪烁
}
}
