Can't get interrupt from GPIO pin
Posted: Fri Jul 26, 2024 3:02 pm
I'm working on a bare-metal code for the ESP32-H2, and I can't get an interrupt from a GPIO pin. If this is the wrong place to raise this, I'm sorry - where should I raise it?
Using the Technical Reference Manual Pre-release v0.4. (0.5 doesn't have any updates in sections 1, 6, 9)
Enabling the interrupt
Following TRM 1.6.3.2,
(0) Allocate a so-far-unused machine interrupt (1).
(1) Save the state of MIE and clear it.
(2) I'm going to use edge interrupts, so I set bit 1 in INTPRI_CORE0_CPU_INT_TYPE_REG. (By the way, doesn't this mean that all interrupts from GPIO have to have the same edge/level setting? and is edge/level here the same as edge/level for GPIO pins?)
(3) Set the priority in INTPRI_CORE0_CPU_INT_PRI_1_REG to 15.
(4) Set bit 1 of INTPRI_CORE0_CPU_INT_ENABLE_REG.
(4A) (not in TRM 1.6.3.2; in 9.5.3.1) Set the machine interrupt, 1, in INTMTX_CORE0_GPIO_INTR_MAP_REG.
(5) fence.
(6) Set the new machine interrupt bit (1) in the saved MIE, and restore it to MIE.
Configuring GPIO_3
(1) Configure GPIO_3 to function 1; set IO_MUX_GPIO3_MCU_SEL to 1. (This didn't seem to make any difference).
(2) Disable output by setting bit 3 in GPIO_ENABLE_W1TC_REG (is this right? using W1TS made no difference).
(3) Enable input by setting IO_MUX_GPIO3_FUN_IE to 1.
(4) Enable pull-up by setting IO_MUX_GPIO3_FUN_WPU to 1 and IO_MUX_GPIO3_FUN_WPD to 0.
(5) Set trigger type to any edge by setting GPIO_PIN3_INT_TYPE to 3.
(6) Enable interrupts by setting GPIO_PIN3_INT_ENA to 1 (ordinary interrupt).
Usage
Connecting GPIO_1 to ground doesn't generate an interrupt (but GPIO_IN_REG[3] goes to 0).
Using the Technical Reference Manual Pre-release v0.4. (0.5 doesn't have any updates in sections 1, 6, 9)
Enabling the interrupt
Following TRM 1.6.3.2,
(0) Allocate a so-far-unused machine interrupt (1).
(1) Save the state of MIE and clear it.
(2) I'm going to use edge interrupts, so I set bit 1 in INTPRI_CORE0_CPU_INT_TYPE_REG. (By the way, doesn't this mean that all interrupts from GPIO have to have the same edge/level setting? and is edge/level here the same as edge/level for GPIO pins?)
(3) Set the priority in INTPRI_CORE0_CPU_INT_PRI_1_REG to 15.
(4) Set bit 1 of INTPRI_CORE0_CPU_INT_ENABLE_REG.
(4A) (not in TRM 1.6.3.2; in 9.5.3.1) Set the machine interrupt, 1, in INTMTX_CORE0_GPIO_INTR_MAP_REG.
(5) fence.
(6) Set the new machine interrupt bit (1) in the saved MIE, and restore it to MIE.
Configuring GPIO_3
(1) Configure GPIO_3 to function 1; set IO_MUX_GPIO3_MCU_SEL to 1. (This didn't seem to make any difference).
(2) Disable output by setting bit 3 in GPIO_ENABLE_W1TC_REG (is this right? using W1TS made no difference).
(3) Enable input by setting IO_MUX_GPIO3_FUN_IE to 1.
(4) Enable pull-up by setting IO_MUX_GPIO3_FUN_WPU to 1 and IO_MUX_GPIO3_FUN_WPD to 0.
(5) Set trigger type to any edge by setting GPIO_PIN3_INT_TYPE to 3.
(6) Enable interrupts by setting GPIO_PIN3_INT_ENA to 1 (ordinary interrupt).
Usage
Connecting GPIO_1 to ground doesn't generate an interrupt (but GPIO_IN_REG[3] goes to 0).