I'm running some code on an ESP32 PICO that would work fine on an Arduino or other microcontroller (i've run the same code on Atmega328p, SAMD21 and ESP32 C3) but on an ESP32 PICO i get the following error (shown at the bottom). I've done some reading and the EXCVADDR: 0x80081122 seems to point to memory where the exception occurred but that doesn't help me at all since i'm working in the Arduino IDE. The lines of code i have identified are the following...
decaySlopeFLOAT = (1023 - sustainDAC) / decayTicksFLOAT;
or
releaseSlopeFLOAT = sustainDAC / releaseTicksFLOAT;
It's just some simple maths involving floats and integers which is getting called once a second but i can't figure out why it would cause any problems. The code is run in an ISR which is called by a timer which was created by a task running the code on core 0. Here is some of the relevant code snippets.
Code: Select all
hw_timer_t * timer = NULL;
TaskHandle_t Task1;
void IRAM_ATTR onTimer() {
getPotValues();
}
void setup()
{
//create a task that will be executed in the vTaskFunction() function, with priority 2 and executed on core 0
xTaskCreatePinnedToCore(
vTaskFunction, /* Task function. */
"Task1", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
2, /* priority of the task */
&Task1, /* Task handle to keep track of created task */
0);
}
// Create the timer then delete the task that created it
void vTaskFunction( void * pvParameters )
{
Serial.print("vTaskFunction running on core ");
Serial.println(xPortGetCoreID());
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 1000000, true);
timerAlarmEnable(timer);
// delete this task
vTaskDelete( Task1 );
}
void getPotValues()
{
// there is a whole bunch of code here doing analog reads and calcs on the values it gets from the reads
// then this line will cause the Guru Meditation Error
// i've tried reworking it in different ways but always get the same result
decaySlopeFLOAT = (1023 - sustainDAC) / decayTicksFLOAT;
}
Code: Select all
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40084186 PS : 0x00050d31 A0 : 0x80081116 A1 : 0x3ffbe89c
A2 : 0x00000040 A3 : 0x00018040 A4 : 0x000637ff A5 : 0x3ffbe87c
A6 : 0x00000000 A7 : 0x3ffbdbdc A8 : 0x3ffb938c A9 : 0x00000000
A10 : 0x000f4240 A11 : 0x3ffbeeb4 A12 : 0x800811dc A13 : 0x3ffbe82c
A14 : 0x00000000 A15 : 0x3ffbe82c SAR : 0x00000015 EXCCAUSE: 0x0000001c
EXCVADDR: 0x80081122 LBEG : 0x400860b9 LEND : 0x400860c9 LCOUNT : 0xffffffff
Backtrace:0x40084183:0x3ffbe89c |<-CORRUPTED
ELF file SHA256: 0000000000000000
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:12812
load:0x40080400,len:3032
entry 0x400805e4
Cheers
NM
p.s. does the Stack Size of the task have anything to do with it? (10000)