External interrupt problem with ESP32

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

External interrupt problem with ESP32

Postby haythemjls » Tue Apr 21, 2020 6:37 pm

Hello,

I have a problem with external Interrupt in ESP32, the serial monitor display this message when interrupt is occurred :

Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC : 0x4008875c PS : 0x00060234 A0 : 0x800d254c A1 : 0x3ffbe620
A2 : 0x3ffb8420 A3 : 0x00000000 A4 : 0xffffffff A5 : 0x00000000
A6 : 0x0000001f A7 : 0x00000001 A8 : 0x8000beb2 A9 : 0x3ffbe620
A10 : 0x3ffb854c A11 : 0x0000000c A12 : 0x00060221 A13 : 0xffffffff
A14 : 0x00060e21 A15 : 0x00000000 SAR : 0x0000001c EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
Core 1 was running in ISR context:
EPC1 : 0x4000beb4 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x4008875c

Backtrace: 0x4008875c:0x3ffbe620 0x400d2549:0x3ffbe660 0x400d187f:0x3ffbe680 0x400d1ce5:0x3ffbe6b0 0x400d0fb5:0x3ffbe6d0 0x400d106a:0x3ffbe700 0x400d10b9:0x3ffbe730 0x400d0dc0:0x3ffbe750 0x400d0ded:0x3ffbe770 0x40080ed0:0x3ffbe790 0x40080f85:0x3ffbe7b0 0x40084e45:0x3ffbe7d0 0x400d246e:0x3ffb1fb0 0x40088a6d:0x3ffb1fd0

Core 0 register dump:
PC : 0x400ea0f2 PS : 0x00060334 A0 : 0x800d4e36 A1 : 0x3ffbbff0
A2 : 0x00000000 A3 : 0x00000001 A4 : 0x00000000 A5 : 0x00000001
A6 : 0x00060520 A7 : 0x00000000 A8 : 0x800d49fe A9 : 0x3ffbbfc0
A10 : 0x00000000 A11 : 0x400855d0 A12 : 0x00060520 A13 : 0x3ffbb710
A14 : 0x3ff000e0 A15 : 0x00000001 SAR : 0x00000000 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000

Backtrace: 0x400ea0f2:0x3ffbbff0 0x400d4e33:0x3ffbc010 0x4008a20e:0x3ffbc030 0x40088a6d:0x3ffbc050

Rebooting...

any one help me p pls ?

ESP_Sprite
Posts: 9739
Joined: Thu Nov 26, 2015 4:08 am

Re: External interrupt problem with ESP32

Postby ESP_Sprite » Tue Apr 21, 2020 7:17 pm

Looks like you're doing something silly in the interrupt handler, but without looking at your code that's about all we can say about that.

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

Re: External interrupt problem with ESP32

Postby haythemjls » Tue Apr 21, 2020 10:00 pm

I try to change data betwen capacitive keypad "MPR121" and ESP32 through I2C peripheral and IRQ pin which uses for external interrupt,
when an interrupt is occurred the IRQ change value from HIGH to LOW and ISR execute received data from MPR121, the main loop is empty.

I have tested the same code withe Arduino uno and the interrupt works well!

Code:

Code: Select all

#include <Wire.h>
#include "Adafruit_MPR121.h"
Adafruit_MPR121 cap = Adafruit_MPR121();

#define IRQ_pin  2
#define Buz 13

volatile uint16_t lasttouched = 0;
volatile uint16_t currtouched = 0;



void IRAM_ATTR data_Interrupt(){
    
 interrupts();

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



 for (uint8_t i=0; i<12; i++) {
   // it if *is* touched and *wasnt* touched before, alert!
    if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
       
      Serial.print(i); Serial.println(" touched");
    }


    // if it *was* touched and now *isnt*, alert!
    if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
    
      Serial.print(i); Serial.println(" released");
    }
    
 }

    // reset our state
  lasttouched = currtouched; 

 attachInterrupt(digitalPinToInterrupt(IRQ_pin),data_Interrupt,FALLING); 
 }
 

void setup() {
   pinMode(IRQ_pin, INPUT_PULLUP);
   pinMode(Buz, OUTPUT);
   Serial.begin(115200);


  
    if (!cap.begin(0x5A)) {
    Serial.println("MPR121 not found, check wiring?");
   while (1);
  }
  
  
  Serial.println("MPR121 found!");
attachInterrupt(digitalPinToInterrupt(IRQ_pin),data_Interrupt,FALLING);
}

void loop() {
  
  
 
 
 
}

ESP_Sprite
Posts: 9739
Joined: Thu Nov 26, 2015 4:08 am

Re: External interrupt problem with ESP32

Postby ESP_Sprite » Wed Apr 22, 2020 8:13 am

Moving this to the Arduino forum, as you're using that. I don't know the details about Arduino, but if interrupts are implemented in the same way as ESP-IDF, you cannot do any blocking operations in an interrupt. Specifically, your Serial.println likely is a blocking operation.

Who is online

Users browsing this forum: No registered users and 71 guests