Skip to content

Instantly share code, notes, and snippets.

@monpetit
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save monpetit/1d4d4614bc449339bbf1 to your computer and use it in GitHub Desktop.

Select an option

Save monpetit/1d4d4614bc449339bbf1 to your computer and use it in GitHub Desktop.
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