User Tools

Site Tools


esp32:watchdog

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
esp32:watchdog [2022/04/25 19:56] – created aistisesp32:watchdog [2022/04/25 20:10] (current) – aistis
Line 1: Line 1:
-aaa+esp32 watchdog 
 + 
 +<code cpp> 
 + 
 +#include "esp_system.h" 
 +void IRAM_ATTR resetModule() { 
 +  ets_printf("reboot\n"); 
 +  esp_restart(); 
 +} 
 + 
 + 
 +//setup 
 +  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 
 +   
 +   
 +//loop   
 +  timerWrite(timer, 0); //reset timer (feed watchdog) 
 + 
 + 
 +</code> 
 + 
esp32/watchdog.1650905784.txt.gz · Last modified: by aistis