esp32:watchdog
This is an old revision of the document!
esp32 watchdog
#include "esp_system.h" void IRAM_ATTR resetModule() { ets_printf("reboot\n"); esp_restart(); } timer = timerBegin(0, 80, true); //timer 0, div 80 timerAttachInterrupt(timer, &resetModule, true); //attach callback const int wdtTimeout = 3000; //time in ms to trigger the watchdog timerAlarmWrite(timer, wdtTimeout * 1000, false); //set time in us timerAlarmEnable(timer); //enable interrupt timerWrite(timer, 0); //reset timer (feed watchdog) <code> <code cpp> #include <Arduino.h> void setup() { Serial.begin(115200); pinMode(16, OUTPUT); } void loop() { static int zzz = 0; Serial.println(zzz++); digitalWrite(16, HIGH); delay(1000); digitalWrite(16, LOW); delay(1000); // wait for a second }
esp32/watchdog.1650906623.txt.gz · Last modified: by aistis
