This is an old revision of the document!
External Interrupts
EXTI Lines
0..15 | EXTI lines 0..15 correspond to the GPIO pins 0..15 |
16 | PVD interrupt |
17 | RTC Alarm A & B interrupt |
18 | USB OTG FS interrupt |
19 | Ethernet wakeup |
20 | USB OTG HS interrupt |
21 | Tamper & time stamp interrupt |
22 | RTC wakeup interrupt |
Programming Example
Setup Peripheral (e.g. GPIOA Pin 5)
#include "reg_stm32f4xx.h" #include "reg_stm32f4xx.h" RCC->AHBENR[0] |= (0x1 << 0u); /* Enable GPIOA clock */ /* Configure GPIO pin A.10 as input. */ GPIOA->MODER &= ~(0x3 << 10u); /* Clear existing mode bits 10 and 11. */ GPIOA->PUPDR &= ~(0x3 << 10u); /* Clear existing pull-up/-down bits 10 and 11. */ GPIOA->PUPDR |= (0x1 << 10u); /* Set pin 5 to pull-up mode. */
Setup SYSCFG
To choose which GPIO peripheral should trigger EXTI5 you have to configure the SYSCFG register.
#include "reg_stm32f4xx.h" SYSCFG->EXTICR[1] |= (0x0 << 4u); /* Set EXTI5 to GPIOA. */
Setup EXTI
#include "reg_stm32f4xx.h" EXTI->RTSR |= (0x1 << 5u); /* Trigger on rising edge. */ EXTI->IMR |= (0x1 << 5u); /* Unmask interrupt line. */
Setup NVIC
#include "reg_stm32f4xx.h" NVIC->ISER[0] |= (0x1 << 23u); /* Enable EXTI5 interrupt. */
Configuration Register
SYSCFG - EXTICRx
EXTICR1
EXTICR2
EXTICR3
EXTICR4
External interrupt configuration register 4
EXTIx | 0000 | GPIOA pin x (reset state) |
0001 | GPIOB pin x | |
… | ||
1010 | GPIOK pin x |
EXTI - RTSR / FTSR
Rising / falling trigger selection register
TRx | 0 | Trigger for EXTI line x disabled (reset state) |
1 | Trigger for EXTI line x enabled |