GPIO Interrupt with Deep_Sleep

Hi, I’m using wireless stick light. My program goes into a deep sleep every 10 Seconds and wakes by 2 sources,

1- Timer source: This is the Normal mode.

2- Touch sensor connected to GPIO pin 2

The program works fine with The LoRaWAN & the Touch sensor wakes the µController. Now i want to add a new feature which is touching the Touch Sensor 2 times will drive the program into a subroutine. I managed to do that by the recommended way that Esspressif uses (by interrupts on the GPIO) as follow:

static void TTP223_Setup(void)
  Serial.println("TTP223_Setup ");

// Define the LED
  gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);

  gpio_config_t io_conf
    io_conf.pin_bit_mask = GPIO_TOUCH_PIN_SEL,         // Pin bitMask
    io_conf.mode = GPIO_MODE_INPUT,
    io_conf.pull_up_en = GPIO_PULLUP_ENABLE,
    io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE,
    io_conf.intr_type = GPIO_INTR_POSEDGE,        // GPIO_INTR_NEGEDGE
  gpio_config (&io_conf);
  gpio_install_isr_service (ESP_INTR_FLAG_DEFAULT);
  gpio_isr_handler_add (Touch_PIN, Touch_ISR_Handler, (void *) Touch_PIN);   // (void *) 

The Interrupt handler is :

static void IRAM_ATTR Touch_ISR_Handler (void * Touch)

  Serial.print("Triggered by ");


  WU_R = Touch_Mode;


  if(Touch_Count <= 1)    // 1st Touch


    Serial.print(" 1st Touch..Start To2_Timer ");


  else  // 2nd Touch before Timer Time_Out ...otherwise, reset Touch_Count


    Serial.print(" 2nd Touch  ");

    // DeepSleep_Disabler = true;        // Stop Deep Sleep



Once i activate the TTP223_Setup function on the setup loop the program crashes:

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
mode:DIO, clock div:2
entry 0x400806a8
ESP32 MCU init...
ESP32 MCU inited OK!
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x40159daf  PS      : 0x00060b30  A0      : 0x800e309c  A1      : 0x3ffb1eb0
A2      : 0x00000000  A3      : 0x00000000  A4      : 0x4008133c  A5      : 0x00000000  
A6      : 0x3ffc24cc  A7      : 0x00000000  A8      : 0x80143ba6  A9      : 0x3ffb1e60
A10     : 0x00000105  A11     : 0x0000040e  A12     : 0x00000000  A13     : 0x00000000  
A14     : 0x4008133c  A15     : 0x00000000  SAR     : 0x0000001d  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff  

ELF file SHA256: 0000000000000000

Backtrace: 0x40159daf:0x3ffb1eb0 0x400e3099:0x3ffb1ed0 0x400e30f5:0x3ffb1f00 0x400d5ee4:0x3ffb1f20 0x400d1f59:0x3ffb1f50 0x400d2454:0x3ffb1f70 0x400e5272:0x3ffb1fb0 0x4008bd6a:0x3ffb1fd0

ets Jun  8 2016 00:22:57

I Tested the same GPIO functions (Setup & Interrupt Handler) on different ESP32 (without LoRaWAN) and it works fine.

this is my setup loop:

void setup()






  esp_sleep_enable_timer_wakeup( DL_P.Deep_Sleep_Time * uS_TO_S_FACTOR);

  esp_sleep_enable_ext0_wakeup(Touch_PIN, Touch_Level);  


commenting the TTP223_Setup(); The program works fine. Don’t know what is the issue here!?

More information about the issue…disabling the GPIO pin 2 interrupt makes the program not crashing.

so, Why activating the Interrupt on the GPIO (with the LoRaWAN operation) make such a crash?

LoadProhibited, StoreProhibited (prohibited to load, prohibit to store)
This CPU exception occurs when the application tries to read or write to an invalid memory location. The write/read address can be found in the EXCVADDR register in the register dump. If this address is zero, it usually means the application The program tries to dereference the NULL pointer. If this address is close to zero, it usually means that the application is trying to access a member of the structure, but the pointer to the structure is NULL. If the address is something else (garbage value, not in the range of 0x3fxxxxxx-0x6xxxxxxx) Inside), it may mean that the pointer used to access the data is not initialized or corrupted.

Thank you navi for your reply, How can i avoid accessing the NULL Pointer (Since EXCVADDR = 0)?

This requires printing and debugging to slowly locate the problem.