STM32-Peripheral’s-GPIO: EXTI

STM32-Peripheral’s-GPIO: EXTI

Closeup picture of some computer parts in blue light

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

Figure 1: External interrupt selection

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

Figure 2: Pin Configuration

13 . Go to System mode > GPIO > GPIO configuration > NVIC > enabled PE4 external interrupt

Figure 3: Enabled 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)

Figure 4: Debug Output

Software Tools:

  1. STM32CubeIDE
  2. STM32CubeMx
  3. Teraterm

Hardware Setup;

  1. STM32F429IDISCOVERY board
  2. Mini USB Cable
  3. Jumper wire

Conclusion:

Successfully demonstrated external interrupt pin configuration & its usage with simple code example.

References:

  1. STM32 HAL Library
  2. STM32 UM1718 document

Similar topics:

  1. https://kalapiinfotech.in/stm32-cube-ide-freertos-code-generation-using-cubemx/
  2. https://kalapiinfotech.in/stm32-peripherals-gpio-output-input/

Leave a Reply

Your email address will not be published. Required fields are marked *