Last active
August 29, 2015 14:23
-
-
Save monpetit/1d4d4614bc449339bbf1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uint32_t count = 10; | |
| void wdt_reset(void) | |
| { | |
| // Watchdog Timer initialization | |
| // Watchdog Timer Prescaler: OSC/2k (2048 cycles) | |
| // Watchdog timeout action: Reset | |
| WDTCSR = (0 << WDIF) | (0 << WDIE) | (0 << WDP3) | (1 << WDCE) | (1 << WDE) | (0 << WDP2) | (0 << WDP1) | (0 << WDP0); | |
| WDTCSR = (0 << WDIF) | (0 << WDIE) | (0 << WDP3) | (0 << WDCE) | (1 << WDE) | (0 << WDP2) | (0 << WDP1) | (0 << WDP0); | |
| } | |
| void setup() | |
| { | |
| Serial.begin(115200); | |
| delay(100); | |
| Serial.println("START..."); | |
| } | |
| void loop() | |
| { | |
| Serial.print("count = "); | |
| Serial.println(count--); | |
| if (count == 0) { | |
| Serial.println("SOFTWARE RESET..."); | |
| delay(500); | |
| wdt_reset(); | |
| } | |
| delay(1000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment