Guru Meditation Error: Core 1 panic'ed (StoreProhibited) (only crashes when function invoked from ISR)
Posted: Thu Sep 14, 2023 6:17 pm
When I call the function below from an ISR, I'm randomly getting
Guru Meditation Error: Core 1 panic'ed (StoreProhibited)
It might run fine for 30 seconds, or 10 minutes before I get the crash.
When I call it from loop(), it appears to work fine.
I need to call it from my ISR because I'm doing a median filter on some timing values from an external interrupt.
Backtrace info and function are below.
Thank you for any assistance you can offer !
Guru Meditation Error: Core 1 panic'ed (StoreProhibited)
It might run fine for 30 seconds, or 10 minutes before I get the crash.
When I call it from loop(), it appears to work fine.
I need to call it from my ISR because I'm doing a median filter on some timing values from an external interrupt.
Backtrace info and function are below.
Thank you for any assistance you can offer !
- Guru Meditation Error: Core 1 panic'ed (StoreProhibited). Exception was unhandled.
- Core 1 register dump:
- PC : 0x4008f748 PS : 0x00060e33 A0 : 0x8008ff32 A1 : 0x3ffb2610
- A2 : 0x3ffb8014 A3 : 0x3ffb1408 A4 : 0x3ffc3514 A5 : 0x00060c23
- A6 : 0x00060c20 A7 : 0x00000001 A8 : 0x00000014 A9 : 0x00000000
- A10 : 0x3ffb8064 A11 : 0x00000018 A12 : 0xa5a5a5a5 A13 : 0xa5a5a5a5
- A14 : 0x3ffb8014 A15 : 0xa5a5a5a4 SAR : 0x0000001a EXCCAUSE: 0x0000001d
- EXCVADDR: 0xa5a5a5b1 LBEG : 0x40086f38 LEND : 0x40086f43 LCOUNT : 0x00000000
- Backtrace: 0x4008f745:0x3ffb2610 0x4008ff2f:0x3ffb2630 0x400901a4:0x3ffb2650 0x40083d16:0x3ffb2670 0x40083d29:0x3ffb26a0 0x40083d56:0x3ffb26c0 0x4009055d:0x3ffb26e0 0x400d7127:0x3ffb2700 0x400d8401:0x3ffb2720 0x400d859a:0x3ffb2780 0x400d198a:0x3ffb27c0 0x400d2285:0x3ffb2800 0x400daf6d:0x3ffb2820
- #0 0x4008f745:0x3ffb2610 in remove_free_block at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_tlsf.c:212
- (inlined by) block_locate_free at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_tlsf.c:448
- (inlined by) tlsf_malloc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_tlsf.c:779
- #1 0x4008ff2f:0x3ffb2630 in multi_heap_malloc_impl at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/multi_heap.c:197
- #2 0x400901a4:0x3ffb2650 in multi_heap_malloc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/multi_heap_poisoning.c:230
- (inlined by) multi_heap_malloc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/multi_heap_poisoning.c:219
- #3 0x40083d16:0x3ffb2670 in heap_caps_malloc_base at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:154
- (inlined by) heap_caps_malloc_base at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:99
- #4 0x40083d29:0x3ffb26a0 in heap_caps_malloc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:174
- #5 0x40083d56:0x3ffb26c0 in heap_caps_malloc_default at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/heap/heap_caps.c:199
- #6 0x4009055d:0x3ffb26e0 in malloc at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/heap.c:24
- #7 0x400d7127:0x3ffb2700 in TFT_eSPI::loadMetrics() at .pio/libdeps/esp32dev_default_16MB/TFT_eSPI/Extensions/Smooth_font.cpp:173
- #8 0x400d8401:0x3ffb2720 in TFT_eSPI::loadFont(String, bool) at .pio/libdeps/esp32dev_default_16MB/TFT_eSPI/Extensions/Smooth_font.cpp:144
- #9 0x400d859a:0x3ffb2780 in TFT_eSPI::loadFont(unsigned char const*) at .pio/libdeps/esp32dev_default_16MB/TFT_eSPI/Extensions/Smooth_font.cpp:17
- #10 0x400d198a:0x3ffb27c0 in readTach() at src/main.cpp:343
- #11 0x400d2285:0x3ffb2800 in loop() at src/main.cpp:283
- #12 0x400daf6d:0x3ffb2820 in loopTask(void*) at C:/Users/Dave/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50
- int IRAM_ATTR MedianFilter::in(const int & value)
- {
- // sort sizeMap
- // small vaues on the left (-)
- // larger values on the right (+)
- boolean dataMoved = false;
- const uint8_t rightEdge = medFilterWin - 1; // adjusted for zero indexed array
- totalSum += value - data[oldestDataPoint]; // add new value and remove oldest value
- data[oldestDataPoint] = value; // store new data in location of oldest data in ring buffer
- // SORT LEFT (-) <======(n) (+)
- if(locationMap[oldestDataPoint] > 0) // don't check left neighbours if at the extreme left
- {
- for(uint8_t i = locationMap[oldestDataPoint]; i > 0; i--) //index through left adjacent data
- {
- uint8_t n = i - 1; // neighbour location
- if(data[oldestDataPoint] < data[sizeMap[n]]) // find insertion point, move old data into position
- {
- sizeMap[i] = sizeMap[n]; // move existing data right so the new data can go left
- locationMap[sizeMap[n]]++;
- sizeMap[n] = oldestDataPoint; // assign new data to neighbor position
- locationMap[oldestDataPoint]--;
- dataMoved = true;
- }
- else
- {
- break; // stop checking once a smaller value is found on the left
- }
- }
- }
- // SORT RIGHT (-) (n)======> (+)
- if(!dataMoved && locationMap[oldestDataPoint] < rightEdge) // don't check right if at right border, or the data has already moved
- {
- for(int i = locationMap[oldestDataPoint]; i < rightEdge; i++) //index through left adjacent data
- {
- int n = i + 1; // neighbour location
- if(data[oldestDataPoint] > data[sizeMap[n]]) // find insertion point, move old data into position
- {
- sizeMap[i] = sizeMap[n]; // move existing data left so the new data can go right
- locationMap[sizeMap[n]]--;
- sizeMap[n] = oldestDataPoint; // assign new data to neighbor position
- locationMap[oldestDataPoint]++;
- }
- else
- {
- break; // stop checking once a smaller value is found on the right
- }
- }
- }
- oldestDataPoint++; // increment and wrap
- if(oldestDataPoint == medFilterWin) oldestDataPoint = 0;
- return data[sizeMap[medDataPointer]];
- }