The external interrupt/event controller consists of edge detectors for generating
event/interrupt requests. Each input line can be independently configured to select the type
(interrupt or event) and the corresponding trigger event (rising or falling or both). Each line
can also masked independently. A pending register maintains the status line of the interrupt
requests.
Creating STM32 executable projects steps are available on this link , please follow steps 1 to 10 as per blog, here we will start from step 11. PA9 & PA10 Pin used for debugging purpose as UART Tx & UART Rx respectively.
11. External interrupt selection, we will select PE4 as external interrupt pin
12. Pin Configuration
GPIO Mode:
- External interrupt with rising edge selection
- External interrupt with rising edge selection
- External interrupt with rising & falling edge selection
for testing purpose we will select as rising edge trigger detection
13 . Go to System mode > GPIO > GPIO configuration > NVIC > enabled PE4 external interrupt
14. Press below icon for code generation
15.For code demonstration we will connect PE2 (GPIO Output) to PE4 (EXTI pin 4) , already we have configured UART1 for debugging purpose.
16. Sample Code
/* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { /* PE2 is connected to PE4 for demonstrations*/ uart1_putch_debug('X'); } /* USER CODE END 0 */
/* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_2); HAL_Delay(2000); //2000 ms delay } /* USER CODE END 3 */
17. Debug output (Teraterm)
Software Tools:
- STM32CubeIDE
- STM32CubeMx
- Teraterm
Hardware Setup;
- STM32F429IDISCOVERY board
- Mini USB Cable
- Jumper wire
Conclusion:
Successfully demonstrated external interrupt pin configuration & its usage with simple code example.
References:
- STM32 HAL Library
- STM32 UM1718 document
Similar topics: