How to configure EXTI ¶
Configuring the extended interrupts and Event controller (EXTI) in STM32CubeMX2 involves setting GPIO pins to trigger interrupts on signal changes (rising or falling edges). Below is a detailed guide to identify and configure common EXTI scenarios:
EXTI Basics ¶
EXTI provides a number of interrupt and event lines: 16 lines directly connected to GPIOs. Some lines are connected internally to peripherals.
You can configure EXTI lines to trigger on rising edge, falling edge, or both.
EXTI interrupts are managed via NVIC, so priority and enabling must be configured.
Typical EXTI Configuration Scenarios in CubeMX ¶
Scenario A: Configure a GPIO pin as an external interrupt source ¶
Use case: Detect button press or external event.
Steps:
In STM32CubeMX2, select the GPIO pin you want to use.
Configure the GPIO pull-up/pull-down as needed.
In the GPIO Configuration tab, enable the EXTI.
Under EXTI Configuration, enable interruption.
Set interrupt priority if needed.
Go to NVIC Tab and check that the corresponding EXTI interrupt (e.g., EXTI0_IRQn) is enabled (optional).
Scenario B: Configure Multiple EXTI Pins ¶
Use case: Multiple buttons or sensors triggering interrupts.
Steps:
Configure each GPIO pin as EXTI line (e.g., PA0 as EXTI0, PC13 as EXTI13).
Enable corresponding EXTI interrupts in NVIC (EXTI0_IRQn, EXTI15_10_IRQn).
Assign priorities accordingly.
Scenario C: Configure Edge Trigger Type ¶
Use case: Trigger interrupt on rising edge, falling edge, or both.
Steps:
After selecting GPIO, go to the GPIO configuration tab and enable EXTI.
Set Trigger to: - Rising edge - Falling edge - Rising and falling edge
This configures the EXTI line behavior.
Scenario D: Configure EXTI Internal Line ¶
Example: RCC interrupt
The RCC CSS interrupt is internally connected to EXTI line 19.
This EXTI line is internal, meaning it is not connected to an external GPIO pin but to an internal peripheral event.
Steps: - Enable RCC interrupt. - Enable LSE. - Enable the Clock Security System feature in LSE.
Scenario E: Disable EXTI Interrupt Temporarily ¶
Use case: Temporarily ignore interrupts without changing GPIO.
Steps:
In GPIO Configuration tab, disable interruption.
This disables the NVIC interrupt but keeps GPIO configured as EXTI.