美文网首页
EX16AVR ATmega8A watchdog reset

EX16AVR ATmega8A watchdog reset

作者: 山前雨1 | 来源:发表于2018-06-14 10:32 被阅读12次

//EX16AVR ATmega8A watchdog reset//atuhor:QI小米粥//data:2018.3.29#include#includevoid delay(void) //延时半秒

{

int a,b,c;

for(a=0;a<8;a++)

for(b=0;b<28;b++)

  for(c=0;c<250;c++) {}

}

void delay1(void)  //延时半秒

{

int a,b,c;

for(a=0;a<8;a++)

for(b=0;b<25;b++)

  for(c=0;c<250;c++) {}

}

void main(void)

{

DDRB |=BIT(0);

PORTB |=BIT(0);

while(1)

{

//watchdog program

WDTCR |=0X18;//写预定标的之前一定要WDTC置位

WDTCR |=0X0F;//watchdog time out 2.2s实测2.8s可能是因为不准吧

delay();

delay();

delay();

delay();

delay();

delay();

  delay1();

  //delay();

//delay();

//delay();

//delay();

//delay();

//delay();

WDTCR |=0X18;

WDTCR =0X07;

/*

//验证最长多少秒,可以不重启,示波器显示2.77s

PORTB |=BIT(0);

delay();

delay();

delay();

delay();

delay();

delay();

  delay1();

PORTB &=~BIT(0);

delay();

delay();

delay();

delay();

delay();

delay();

  delay1();

*/

}

}

相关文章

网友评论

      本文标题:EX16AVR ATmega8A watchdog reset

      本文链接:https://www.haomeiwen.com/subject/olbeeftx.html