PA1 ... PF1 share an interrupt flag EXT1
. .
. .
PA15... PF15 share an interrupt flag EXT15
2. EXT5-9 share an interrupt source
EXT10-15 share an interrupt source
3. Before enabling interrupts, you need to ENABLE the multiplexing function of the IO port (AFIO)
4. Set the interrupt IO port
5. Register the IO port to the interrupt line (map the IO port to the interrupt line N)
Example: GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource3); Register GPIOD.3 to
Interrupt line EXTIline3
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource4); Register GPIOD.4 to
Interrupt line EXTIline4
6. Configure interrupt
EXTI_InitStructure.EXTI_Line = EXTI_Line3;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; Interrupt
= EXTI_Mode_Event event (trigger other modules)
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising Rising edge trigger
= EXTI_Trigger_Falling Falling edge trigger
= EXTI_Trigger_Rising_Falling Pulse trigger
7. Configure NVIC
8. If you use the library function to write interrupts, you must open the corresponding interrupt in stm32f10x_conf.h
----------------------------------------------------------------------------------------------------
Example:
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO, ENABLE);
/* PD3,4,5,6 key input*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //Pull-up input
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* Connect the IO port to the interrupt line*/
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource3);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource4);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource5);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource6);
/* Configure interrupt line 3 as falling edge Trigger*/
EXTI_InitStructure.EXTI_Line = EXTI_Line3;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/*Others are falling edge triggers*/
EXTI_InitStructure.EXTI_Line = EXTI_Line4|EXTI_Line5|EXTI_Line6;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(& EXTI_InitStructure);
Previous article:EXTI external interrupt of stm32F407
Next article:STM32 RTC clock program
Recommended ReadingLatest update time:2024-11-16 14:50
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Inter-core communication mechanism of multi-core processor
- Summary of performance indicators of integrated operational amplifiers
- Things you must know about Gallium Nitride (GaN): Introduction (Part 1)!
- EEWORLD University ---- Cisco CCNA+CCNP Learning Tutorial
- IIC communication of msp430g2553
- What software do you usually use when doing circuit simulation?
- About LoRa networking issues?
- Comparison of MC34063 circuit structures
- The board for showing goods + collecting dust
- How to deal with cross wiring of PCB circuit boards