Stm32CubeMX5 configure an external interrupt

Experimental PA8 using the connection pin key triggers an interrupt, external interrupt double edge triggered, so that the release button is pressed can be detected, light the LED when the button is depressed,

When the key release the LED is off, only the corresponding flag bit set in the interrupt service routine, the specific processing in the main function.

 

1. PA8 connecting a separate button, pull-down resistor when detecting the key is high

 

2. PA8 configured as an external interrupt mode, in the modified tag produces a corresponding macro definitions main.h port pin

 

 

 

 3. Configure external interrupt priority

 

 4. Configure STM32 add your own clock frequency of 48MHz function code to initialize peripherals good export program

 

5. In the interrupt service function, specifically achieved through the callback function so you can just add the callback function in the user's source files

 

 

 6. DETAILED code implementation

Peripheral gpio.c file 

gpio.h enumerated type defined in the file

 

 main.c file

 

 

 

Guess you like

Origin www.cnblogs.com/electronic/p/11104870.html