参考文章:
//芯片:ATmega8
//晶振:11.0592MHz
void watchdog_init(void)
{
WDR (); //this prevents a timeout on enabling
//WDTCR |= (1<
//WDTCR = 0x07; //WATCHDOG ENABLED - dont forget to issue WDRs
WDTCR=0x1F; //使能watchdog,并且,采用2048K分频,典型溢出时间5V时2.1S
WDTCR=0x0F; //使能watchdog,并且,采用2048K分频,典型溢出时间5V时2.1S
}
// Initialization function for device,
// Call Init_Device() from your main program
void Init_Device(void)
{
CLI();
port_init();
uart0_init();
watchdog_init();
SEI();
}
void main()
{
unsigned int i;
unsigned char ti;
Init_Device();
LED1_L;
LED2_L;
delay_nms(1000);
while(1)
{
LED1_L;
LED2_H;
WDR();//喂狗指令
}
}
阅读(3758) | 评论(0) | 转发(0) |