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);
}
ESP32 core 1 panic'ed when EEPROM and timer interrupt used together
-
- Posts: 1
- Joined: Tue Jan 14, 2020 6:04 am
Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together
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
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
-
- Posts: 2
- Joined: Sat May 30, 2020 7:04 pm
Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together
On the same boat....but have a temp workaround:
detachInterrupt(interruptPin);
EPROM.put.....
EPROM.commit();
delay(2500);
attachInterrupt(interruptPin, ISRroutine, RISING);
detachInterrupt(interruptPin);
EPROM.put.....
EPROM.commit();
delay(2500);
attachInterrupt(interruptPin, ISRroutine, RISING);
-
- Posts: 2
- Joined: Sat May 30, 2020 7:04 pm
Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together
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()
4. Arm/Start the timer , in case you detached the interrupt attach it back.
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).
4. Arm/Start the timer , in case you detached the interrupt attach it back.
Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together
Hi SrimanPatel,
thanks for your valuable advice, it's work for me.
thanks for your valuable advice, it's work for me.
Re: ESP32 core 1 panic'ed when EEPROM and timer interrupt used together
i dont understand ..how can used EEPROM and timer interrupt used together
Who is online
Users browsing this forum: No registered users and 49 guests