ESP32 core 1 panic'ed when EEPROM and timer interrupt used together
Posted: 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);
}
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);
}