ESP32 core 1 panic'ed when EEPROM and timer interrupt used together

pwdandekar
Posts: 1
Joined: Tue Jan 14, 2020 6:04 am

ESP32 core 1 panic'ed when EEPROM and timer interrupt used together

Postby pwdandekar » Tue Jan 14, 2020 6:36 am

Hello,
I am reading an analog input in timer ISR, 100 times per second. If I write this 12-bit value in EEPROM (only once per second), I am getting following error:

Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400e9408: bad00bad bad00bad bad00bad

I am using Arduino IDE and board name selection is NODE-32S and flash frequency is 80 MHz.
If I comment out //EEPROM.commit(); then program runs well. Please help. Thanks in advance.

#include <EEPROM.h>
const int analogpin = 36; // feed here 0 to 3.3V analog signal.
int analog_count = 0; // variable to store ADC count

int address = 0;// EEPROM Address
#define eeprom_size 2 // Size of EEPROM 2 bytes to store int variable

hw_timer_t * timer = NULL;// define a pointer which can point to our timer
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;// to synv loop and isr

void IRAM_ATTR onTimer(void);

void setup()
{

Serial.begin(115200);
while(!EEPROM.begin(eeprom_size))
{
Serial.println("Failed to initialise EEPROM");
}

// setup timer and timer interrupts
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 10000, true);// 10000 microseconds or every 10 ms this interrupt will be generated.
timerAlarmEnable(timer);
}

void loop()
{
EEPROM.writeInt(address,analog_count);
//EEPROM.commit(); // If this line is un-commented then program crashes.
Serial.print("EPROM write data = ");
Serial.println(analog_count);
delay(1000);
}

void IRAM_ATTR onTimer()
{
portENTER_CRITICAL_ISR(&timerMux);
analog_count = analogRead(analogpin);
portEXIT_CRITICAL_ISR(&timerMux);
}

Colargol
Posts: 1
Joined: Sat May 09, 2020 5:04 pm

Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together

Postby Colargol » Sat May 09, 2020 5:16 pm

Hello,
I have the same problem as you with EEPROM.commit() with the use of the interrupt timer.
I have tried several solutions read on the internet, but nothing corrects this problem.
Did you find a solution ?

Thank you

shrimantpatel
Posts: 2
Joined: Sat May 30, 2020 7:04 pm

Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together

Postby shrimantpatel » Sat May 30, 2020 7:56 pm

On the same boat....but have a temp workaround:



detachInterrupt(interruptPin);

EPROM.put.....
EPROM.commit();

delay(2500);
attachInterrupt(interruptPin, ISRroutine, RISING);

shrimantpatel
Posts: 2
Joined: Sat May 30, 2020 7:04 pm

Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together

Postby shrimantpatel » Sun May 31, 2020 1:25 am

So here is what finally that worked for me:

1. Find the amount of time it takes to finish all the activities on the onTimer() routine using millis().
2.Just before EPROM.commit()
  • stop the timer(hw_timer_disarm(void))
  • Optional: detach interrupt
  • Depending on what you found in step 1 above put a delay (n) , so if you found that control spends 10ms in the timer routine then put a Delay(10).
3.execute EPROM.commit() after the above steps.
4. Arm/Start the timer , in case you detached the interrupt attach it back.

emhatek
Posts: 2
Joined: Tue Nov 17, 2020 6:55 am

Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together

Postby emhatek » Tue Sep 20, 2022 5:05 am

Hi SrimanPatel,
thanks for your valuable advice, it's work for me.

nedjmo
Posts: 1
Joined: Sun Dec 25, 2022 11:40 am

Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together

Postby nedjmo » Sun Dec 25, 2022 12:48 pm

i dont understand ..how can used EEPROM and timer interrupt used together

Who is online

Users browsing this forum: Bing [Bot] and 50 guests