Timer error

Daliwan
Posts: 2
Joined: Mon May 09, 2022 1:59 am

Timer error

Postby Daliwan » Mon May 09, 2022 3:13 am

I am trying ESP32 with a simple timing code, in a VScode enviranment, the code is like this:
#include <Arduino.h>
//=====================================
// a timer demo
//=====================================

int interruptCounter = 0;
hw_timer_t *timer = NULL;

void TimerEvent()
{
Serial.print(interruptCounter++);
if(interruptCounter > 5)
{
interruptCounter = 1;
}
}

void setup()
{
Serial.begin(115200);

timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &TimerEvent, true);
timerAlarmWrite(timer, 1000000, true);
timerAlarmEnable(timer);
}

void loop()
{

}

But then at PC there received an "Interrupt wdt timeout error":
Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
Core 1 register dump:
PC : 0x4008a14e PS : 0x00060e35 A0 : 0x800893c2 A1 : 0x3ffbeccc
A2 : 0x3ffb8a00 A3 : 0x3ffb8890 A4 : 0x00000004 A5 : 0x00060e23
A6 : 0x00060e23 A7 : 0x00000001 A8 : 0x3ffb8890 A9 : 0x00000018
A10 : 0x3ffb8890 A11 : 0x00000018 A12 : 0x00000004 A13 : 0x00060e23
A14 : 0x007bee98 A15 : 0x003fffff SAR : 0x00000020 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x40085bfc LEND : 0x40085c07 LCOUNT : 0xffffffff
Core 1 was running in ISR context:
EPC1 : 0x400d9f43 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000
Backtrace:0x4008a14b:0x3ffbeccc |<-CORRUPTED
Core 0 register dump:
PC : 0x4008a2d1 PS : 0x00060035 A0 : 0x80088fef A1 : 0x3ffbe7ec
A2 : 0x3ffbee98 A3 : 0xb33fffff A4 : 0x0000abab A5 : 0x00060023
A6 : 0x00060021 A7 : 0x0000cdcd A8 : 0x0000abab A9 : 0xffffffff
A10 : 0x00000000 A11 : 0x00000000 A12 : 0x3ffc13e4 A13 : 0x00000007
A14 : 0x007bee98 A15 : 0x003fffff SAR : 0x0000001a EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000

Backtrace:0x4008a2ce:0x3ffbe7ec |<-CORRUPTED

ELF file SHA256: 0000000000000000

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (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:12776
load:0x40080400,len:3032
entry 0x400805e4

Is anyone can help me with this problem? Thanks.

savage
Posts: 23
Joined: Mon Jul 15, 2019 9:24 pm

Re: Timer error

Postby savage » Mon May 09, 2022 12:54 pm

Interrupt routines must complete very quickly, but writing to serial is a slow process. Try setting a flag in your interrupt routine and printing from loop() when the flag changes. You should also make sure your interrupt routine stays in internal memory using:

Code: Select all

void ARDUINO_ISR_ATTR TimerEvent()
The timer documentation page has examples at the bottom.

Daliwan
Posts: 2
Joined: Mon May 09, 2022 1:59 am

Re: Timer error

Postby Daliwan » Sun May 15, 2022 3:40 am

Thanks, I will try it.

Who is online

Users browsing this forum: No registered users and 36 guests