ATMega8 Watchdog測(cè)試程序
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define SET_LEDPORTB&=0XFE //PB0接黃色發(fā)光管
#define CLR_LED PORTB|=0X01
//誤差不會(huì)太大的延時(shí)1ms函數(shù)
void DelayMs(uint ms)
{
uint i;
for(i=0;i
}
int main(void)
{
DDRB=_BV(PB0);
PORTB=_BV(PB0); //CLR_LED
//WDT計(jì)數(shù)器同期為一秒
wdt_enable(WDTO_1S);
wdt_reset();//喂狗
DelayMs(500);
SET_LED;
//等待餓死狗
DelayMs(5000);
SET_LED;
while(1)
wdt_reset();
}