external interrupt ESP32

haythemjls
Posts: 27
Joined: Mon Apr 06, 2020 1:32 pm

external interrupt ESP32

Postby haythemjls » Fri Sep 04, 2020 10:46 am

I have a problem of rebooting of my ESP when using external interrupt,

I try to change data between ESP32 and capacitive touch through I2C peripheral and IRQ (pin for interrupt), the ISR occures when IRQ change value from high to low.
The firmware was functional, but after installaing the new version of ESP32 in Arduino IDE, It no longer works and the serial monitor display errore msg:

Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC : 0x400d6308 PS : 0x00060e34 A0 : 0x800d640f A1 : 0x3ffbe5d0
A2 : 0x00000031 A3 : 0x00000001 A4 : 0x00060e21 A5 : 0x00000001
A6 : 0x00060e21 A7 : 0x00000000 A8 : 0x0000002e A9 : 0x3ffbe5d0
A10 : 0x3ffaff60 A11 : 0xbaad5678 A12 : 0x3ffb84e4 A13 : 0x00000001
A14 : 0x00060e23 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Core 1 was running in ISR context:
EPC1 : 0x400d1c2a EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x400d6308

Backtrace: 0x400d6308:0x3ffbe5d0 0x400d640c:0x3ffbe5f0 0x400d6638:0x3ffbe630 0x400d189c:0x3ffbe670 0x400d1d1d:0x3ffbe6a0 0x400d0fed:0x3ffbe6c0 0x400d10a2:0x3ffbe6f0 0x400d10f1:0x3ffbe720 0x400d0d50:0x3ffbe740 0x400d0d7d:0x3ffbe760 0x400d0d90:0x3ffbe780 0x40080ebd:0x3ffbe7a0 0x40081e41:0x3ffbe7c0 0x400e9d9d:0x3ffb1fb0 0x40085aa1:0x3ffb1fd0

Core 0 register dump:
PC : 0x400ea1ae PS : 0x00060534 A0 : 0x800d5f92 A1 : 0x3ffbbff0
A2 : 0x00000000 A3 : 0x00000001 A4 : 0x00000000 A5 : 0x00000001
A6 : 0x00060320 A7 : 0x00000000 A8 : 0x800d70ae A9 : 0x3ffbbfc0
A10 : 0x00000000 A11 : 0x40085214 A12 : 0x00060320 A13 : 0x3ffbb660
A14 : 0x00000000 A15 : 0x3ffbbce0 SAR : 0x00000000 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000

Backtrace: 0x400ea1ae:0x3ffbbff0 0x400d5f8f:0x3ffbc010 0x4008794e:0x3ffbc030 0x40085aa1:0x3ffbc050

Rebooting...


I attached you my full code.
Attachments
code.txt
(1.22 KiB) Downloaded 367 times

idahowalker
Posts: 166
Joined: Wed Aug 01, 2018 12:06 pm

Re: external interrupt ESP32

Postby idahowalker » Fri Sep 04, 2020 12:20 pm

There is this thingy that is an add on to the Arduino IDe called ESP Exception Decored which can be found here https://github.com/me-no-dev/EspExceptionDecoder that has been, for me, a great help in getting to the cause of those Guru error thingies.

Why not post your code with code tags so i don't have to download the test file and so on and so forth?

Without loking at your code, I'd guess you have to much going on with your ISR. For the ESP32, I like to have the ISR trigger a freeRTOS task, that way the ISR can get back to being an ISR.

haythemjls
Posts: 27
Joined: Mon Apr 06, 2020 1:32 pm

Re: external interrupt ESP32

Postby haythemjls » Fri Sep 04, 2020 2:25 pm

Thank you for your reply, what do you mean about "ISR trigger a freeRTOS task" ? have you any example about it ?

I attached you the code part of my ISR function :

void DATA_MPR121(){

// Get the currently touched pads
currtouched = cap.touched();

for (uint8_t i=0; i<12; i++) {
if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" touched");
}

if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" released");
}
}

lasttouched = currtouched;
attachInterrupt(digitalPinToInterrupt(IRQ_pin),DATA_MPR121,CHANGE);
}

lbernstone
Posts: 638
Joined: Mon Jul 22, 2019 3:20 pm

Re: external interrupt ESP32

Postby lbernstone » Fri Sep 04, 2020 2:40 pm

If you don't know how to start a new task, then just set a variable in your ISR, check for that variable in your main processing loop and do your interaction with hardware (including Serial.print) there. Also, tag your ISR with IRAM_ATTR.
https://github.com/espressif/arduino-es ... errupt.ino

Who is online

Users browsing this forum: No registered users and 41 guests