Skip to content

Instantly share code, notes, and snippets.

@combs
Last active August 9, 2023 20:31
Show Gist options
  • Save combs/351e2b1fb9de404912e47326795dd796 to your computer and use it in GitHub Desktop.
Save combs/351e2b1fb9de404912e47326795dd796 to your computer and use it in GitHub Desktop.
// https://github.com/combs/Arduino-Watchdog-Handler
#include "watchdogHandler.h"
#include <avr/wdt.h>
volatile uint8_t canary = 0;
uint8_t scratch = 0;
bool badness = false;
void setup() {
wdt_disable();
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("hallo");
delay(1000);
setup_watchdog(WDTO_15MS);
}
void loop() {
canary = random(10);
// how to test if the interrupt is occurring not here but during the switch?
switch(canary) {
case 0:
canary = 10;
break;
case 1:
scratch = random() + 11;
break;
case 2:
scratch = random() + 12;
break;
case 3:
scratch = random() + 13;
break;
case 4:
scratch = random() + 14;
break;
case 5:
scratch = random() + 15;
break;
case 6:
scratch = random() + 16;
break;
case 7:
scratch = random() + 17;
break;
case 8:
scratch = random() + 18;
break;
case 9:
scratch = random() + 19;
break;
case 10:
scratch = random() + 20;
break;
default:
badness = true;
break;
}
if (badness) {
Serial.println("A badness occurred.");
badness = false;
}
}
ISR(WDT_vect) {
canary = 100;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment