Getting (InstrFetchProhibited) exception when triggering an interrupt

A6ESPF
Posts: 28
Joined: Tue Dec 10, 2019 12:16 pm

Getting (InstrFetchProhibited) exception when triggering an interrupt

Postby A6ESPF » Thu May 04, 2023 11:48 am

Hello,
I'm trying to set up an interrupt handler on GPIO36 (SENSOR_VP) ESP32 pin. Here are some parts of the code that I consider relevant:

Code: Select all

static void irq_handler_func(void* arg)
{
    xSemaphoreGiveFromISR(isr_sem, NULL);
}
.
.
.
static void parent_irq_handler_func(void* arg)
{
    irq_handler_func(arg);
}
.
.
.
static void init_func(void)
{
    gpio_config_t pin_irq_cfg =
    {
        .intr_type = GPIO_INTR_NEGEDGE,
        .pull_down_en = GPIO_PULLDOWN_DISABLE,
        .pull_up_en = GPIO_PULLUP_ENABLE,
        .mode = GPIO_MODE_INPUT,
        .pin_bit_mask = 1ULL << GPIO_NUM_36,
    };

    gpio_config(&pin_irq_cfg);

    gpio_isr_handler_add(GPIO_NUM_36, parent_irq_handler_func, NULL);
}
.
.
.
static void main_task(void* arg)
{
    while (1)
    {
        if (pdTRUE == xSemaphoreTake(isr_sem, portMAX_DELAY))
        {
            .
            .
            .
        }
    }
}
The problem is, when I generate the negative edge on GPIO36, ESP32 crashes with the following error:

Code: Select all

Guru Meditation Error: Core  0 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x00000002  PS      : 0x00060031  A0      : 0x80082d20  A1      : 0x3ffb0b30
A2      : 0x3ffc9b20  A3      : 0x00000050  A4      : 0x800fd9ba  A5      : 0x3ffca480
A6      : 0x3ffb32c0  A7      : 0x3ffca4a0  A8      : 0x800df4d6  A9      : 0xfffffff8
A10     : 0x3ffc9b20  A11     : 0x00060023  A12     : 0x8008d90e  A13     : 0x3ffca470
A14     : 0x00000003  A15     : 0x00060723  SAR     : 0x0000001c  EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000

Backtrace:0xffffffff:0x3ffb0b300x40082d1d:0x3ffb0b50 0x40082155:0x3ffb0b80 0x4017a08f:0x3ffca4d0 0x400d3db2:0x3ffca4f0 0x4008b95d:0x3ffca510 0x4008d6bd:0x3ffca530
0x40082d1d: gpio_isr_loop at H:/esp-idf-v4.4/components/driver/gpio.c:416
 (inlined by) gpio_intr_service at H:/esp-idf-v4.4/components/driver/gpio.c:442

0x40082155: _xt_lowint1 at H:/esp-idf-v4.4/components/freertos/port/xtensa/xtensa_vectors.S:1111

0x4017a08f: cpu_ll_waiti at H:/esp-idf-v4.4/components/hal/esp32/include/hal/cpu_ll.h:183
 (inlined by) esp_pm_impl_waiti at H:/esp-idf-v4.4/components/esp_pm/pm_impl.c:837

0x400d3db2: esp_vApplicationIdleHook at H:/esp-idf-v4.4/components/esp_system/freertos_hooks.c:63

0x4008b95d: prvIdleTask at H:/esp-idf-v4.4/components/freertos/tasks.c:3974 (discriminator 1)

0x4008d6bd: vPortTaskWrapper at H:/esp-idf-v4.4/components/freertos/port/xtensa/port.c:131
It looks like the program counter register is getting the wrong address of the interrupt handler function. Why is this happening? Is it a problem when the interrupt function is calling another function?

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: Getting (InstrFetchProhibited) exception when triggering an interrupt

Postby ESP_Sprite » Fri May 05, 2023 1:55 am

Did you call gpio_install_isr_service() anywhere?

A6ESPF
Posts: 28
Joined: Tue Dec 10, 2019 12:16 pm

Re: Getting (InstrFetchProhibited) exception when triggering an interrupt

Postby A6ESPF » Sun May 07, 2023 8:26 pm

ESP_Sprite wrote:Did you call gpio_install_isr_service() anywhere?
Yes, I forgot to mention that. Also, when I use the child function directly, the ISR executes fine. I'm not sure why using the parent function first (which calls the child function) fails.

Who is online

Users browsing this forum: tomy983 and 225 guests