Using preferences in esp32 ISR

I am trying to store the value in esp32 using preferences library when an interrupt is triggered.

Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC      : 0x4008867a  PS      : 0x00060034  A0      : 0x80087a9b  A1      : 0x3ffbe860  
A2      : 0x3ffb7e0c  A3      : 0x3ffb8074  A4      : 0x00000001  A5      : 0x00000001  
A6      : 0x00060023  A7      : 0x00000000  A8      : 0x3ffb8074  A9      : 0x3ffb8074  
A10     : 0x00000001  A11     : 0x00000001  A12     : 0x00000020  A13     : 0x0000ff00  
A14     : 0x00ff0000  A15     : 0xff000000  SAR     : 0x0000001e  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  
Core 1 was running in ISR context:
EPC1    : 0x40085d07  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x4008867a

ELF file SHA256: 0000000000000000

Backtrace: 0x4008867a:0x3ffbe860 0x40087a98:0x3ffbe880 0x400860cf:0x3ffbe8a0 0x400e2f42:0x3ffbe8e0 0x400e300a:0x3ffbe900 0x40083cad:0x3ffbe920 0x400840c4:0x3ffbe940 0x400e7b01:0x3ffbe990 0x400e5f66:0x3ffbe9b0 0x400e629e:0x3ffbe9d0 0x400e5a92:0x3ffbea50 0x400e4a77:0x3ffbeac0 0x400e4e55:0x3ffbeb10 0x400d1fa4:0x3ffbeb30 0x40080ecd:0x3ffbeb50 0x40080f19:0x3ffbeb70 0x40083969:0x3ffbeb90 0x40081b46:0x3ffb1e00 0x400826ef:0x3ffb1e20 0x40081183:0x3ffb1e40 0x400811a7:0x3ffb1e60 0x400d1cb7:0x3ffb1e80 0x400d1c85:0x3ffb1ea0 0x400d1c30:0x3ffb1ec0 0x400ebb35:0x3ffb1ee0 0x400ebbfe:0x3ffb1f00 0x400d1795:0x3ffb1f30 0x400d18da:0x3ffb1f70 0x400d1b47:0x3ffb1f90 0x400d33e9:0x3ffb1fb0 0x40086295:0x3ffb1fd0

Core 0 register dump:
PC      : 0x40086729  PS      : 0x00060034  A0      : 0x80086bd6  A1      : 0x3ffbc020  
A2      : 0x3ffbdf74  A3      : 0xb33fffff  A4      : 0x00060023  A5      : 0x003fffff  
A6      : 0x00060021  A7      : 0x00000000  A8      : 0x0000abab  A9      : 0x0000cdcd  
A10     : 0x0000abab  A11     : 0x00060023  A12     : 0x00060021  A13     : 0x3ffbc0d0  
A14     : 0x00000003  A15     : 0x00060b23  SAR     : 0x00000013  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  

ELF file SHA256: 0000000000000000

Backtrace: 0x40086729:0x3ffbc020 0x40086bd3:0x3ffbc050 0x40088524:0x3ffbc070 0x400884da:0x3ffbc090 0x400893fb:0x00000000


But I am getting this error when the interrupt is triggered. Please help me to resolve this

Is it acceptable in your firmware to notify a FreeRTOS task in the ISR, then do the preference saving in that task? I don’t think you can really do a complex writing to flash stuff within an ISR (which needs to be as short as possible anyways), but the Espressif people can confirm that for sure for you (Issues · espressif/arduino-esp32 · GitHub).