本站改版新增arduino频道
arduino 看门狗
#include "esp_system.h"
#include "rom/ets_sys.h"
const int wdtTimeout = 5000; //time in ms to trigger the watchdog
hw_timer_t * timer = NULL;
void ARDUINO_ISR_ATTR resetModule() {
ets_printf("reboot\n");
esp_restart();
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println("running setup");
timer = timerBegin(1000000); //timer 1Mhz resolution
timerAttachInterrupt(timer, &resetModule); //attach callback
timerAlarm(timer, wdtTimeout * 1000, false, 0); //set time in us
}
void loop() {
Serial.println("running main loop");
timerWrite(timer, 0); //reset timer (feed watchdog)
delay(1000);
}
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0094821453094482 seconds