Developing on ESP32 Firebeetle and trying to add watchdog with timer on my task execution scheduler. Having the following code
main.h
#include “esp_system.h”
#include “esp_int_wdt.h”
#include “esp_task_wdt.h”
…
hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
int flag[] = {0, 0, 0, 0,0,0,0,0,0,0};
main.cpp
void IRAM_ATTR onTimer() {
portENTER_CRITICAL_ISR(&timerMux);
// Check all flags if True then kick the dog
if (flag[0] == 1 && flag[1] == 1 && flag[2] == 1 && flag[3] == 1 && flag[4] == 1 && flag[5] == 1 && flag[6] == 1 && flag[7] == 1 && flag[8] == 1 && flag[9] == 1) {
// Reset all flags
flag[0] = 0;
flag[1] = 0;
flag[2] = 0;
flag[3] = 0;
flag[4] = 0;
flag[5] = 0;
flag[6] = 0;
flag[7] = 0;
flag[8] = 0;
flag[9] = 0;
// Kick the dog
timerWrite(timer, 0);
}
else {
ESP.restart();
}
portEXIT_CRITICAL_ISR(&timerMux);
}
void setup() {
Wire.begin();
Serial.begin(SERIAL_LOGGER_BAUD_RATE);
set_logging_function(logging_function)
Serial.println(“Starting up…”);
vTaskDelay( 1000 / portTICK_PERIOD_MS );
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, WDT_TIMEOUT * 1000000, true);
timerAlarmEnable(timer);
esp_task_wdt_init(WDT_TIMEOUT, true); // Initialize ESP32 Task WDT
esp_task_wdt_add(NULL); // Subscribe to the Task WDT
…
Code compiles correctly but when i run it on the device the following part comes on restart:
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
[��mum����2-hal-cpu.c:214] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
Starting up…
[ 1027][W][esp32-hal-timer.c:226] timerAttachInterrupt(): EDGE timer interrupt is not supported! Setting to LEVEL…
Been trying to look through tutorials but to no avail. Running the latest frameworks.
Many thanks