PlatformIO Community

timerAttachInterrupt(): EDGE timer interrupt is not supported

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

nything useful here? Hardware timer issue with ESP32

I notice a couple of issues on the Arduino/espressif github, but they have been closed. The advice there is to use an Arduino library called “Ticker”. I don’t know if that will help, sorry.

Cheers,
Norm.

it seems that edge interrupt does not work on ESP32, so giving false for edge in timerBegin would have done the job. Anyway I will add a “fix” for this in just a sec :slight_smile:

And that warning was part of the change.

Does your sketch still work if you change true to false?

Many thanks for your prompt response…will try it and revert.

Apologies for delays in responding…been dragged to a different task. Unfortunately, making the parameter false does not address the problem. it is still the same issue. Many thanks for your assistance.

Meaning the warning is still there but the code works? Or no warning but no working code?

With flag true, the message appears but it actually works. with flag false, it does not. So it seems that it reports the message but it still works. Many thanks for helping me out.