本站改版新增arduino频道

Micropython
Arduino

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.0094809532165527 seconds