ATmega48A/PA/88A/PA/168A/PA/328/P has an Enhanced Watchdog Timer (WDT). The WDT is a timer counting
cycles of a separate on-chip 128kHz oscillator. The WDT gives an interrupt or a system reset when the counter
reaches a given time-out value. In normal operation mode, it is required that the system uses the WDR - Watchdog
Timer Reset - instruction to restart the counter before the time-out value is reached. If the system doesn't restart
the counter, an interrupt or system reset will be issued.
Threshold value | Constant name | Supported on |
15 ms | WDTO_15MS | ATMega 8, 168, 328, 1280, 2560 |
30 ms | WDTO_30MS | ATMega 8, 168, 328, 1280, 2560 |
60 ms | WDTO_60MS | ATMega 8, 168, 328, 1280, 2560 |
120 ms | WDTO_120MS | ATMega 8, 168, 328, 1280, 2560 |
250 ms | WDTO_250MS | ATMega 8, 168, 328, 1280, 2560 |
500 ms | WDTO_500MS | ATMega 8, 168, 328, 1280, 2560 |
1 s | WDTO_1S | ATMega 8, 168, 328, 1280, 2560 |
2 s | WDTO_2S | ATMega 8, 168, 328, 1280, 2560 |
4 s | WDTO_4S | ATMega 168, 328, 1280, 2560 |
8 s | WDTO_8S | ATMega 168, 328, 1280, 2560 |
//example by Joytag
#include <avr/wdt.h>
void setup() {
Serial.begin(9600);
wdt_enable(WDTO_4S);
Serial.println("restart");
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1000);
}
//example by Joytag
#include <avr/wdt.h>
void setup() {
Serial.begin(9600);
wdt_enable(WDTO_4S);
Serial.println("restart");
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1000);
wdt_reset();
}
欢迎光临 狗趴(GodPub),开源硬件学习与实践 (http://forum.godpub.com/) | Powered by Discuz! X3.2 |