STM32F103ZET6 supports 20 external interrupt inputs (EXIT0~EXIT19), of which there are 4:
EXTI line 16 is connected to the PVD output
EXTI line 17 is connected to the RTC alarm event
EXTI line 18 is connected to the USB wake-up event
EXTI line 19 is connected to Ethernet wake-up event (only for interconnection products)
The other 16 can be used as external input interrupts, including:
EXIT0~EXIT4 have independent interrupt vectors
EXIT6~EXIT9 share an interrupt vector EXTI9_5_IRQHandler
EXIT10~EXIT16 share an interrupt vector EXTI15_10_IRQHandler
The shared interrupt vector needs to read the pending flag in the corresponding ISR to determine which signal triggered the interrupt.
On the board, the PE5/PE6 pins are connected to Key1 and Key2 through pull-up resistors, and the other ends of Key1 and Key2 are connected to GND.
The process of initializing and configuring PE5/PE6 to become an external interrupt is as follows:
1. Enable the clocks of AFIO and GPIO
2. Configure GPIO PE5/PE6 as pull-up input
3. Configure PE5/PE6 as the input pin of external EXIT interrupt through the EXITCR register group of AFIO
4. Configure the EXIT register to enable the interrupt of PE5/PE6
5. Since the level is low after the key is pressed, it is configured to generate an interrupt on the falling edge.
void SK_EXITInit(void)
{
GPIO_InitTypeDef stGpioInit;
EXTI_InitTypeDef stEXTIInit;
/// Step 1: Power On the AFIO and GPIOE
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE);
/// Step 2: Configure the NVIC
SK_SK_EXITNVICConfig();
/// Step 3: Config (PE5/PE6) As pull up input
stGpioInit.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6;
stGpioInit.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOE, &stGpioInit);
/// Step 4: Select the output interrupt source
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource5);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource6);
/// Step 5: Select the output interrupt source
stEXTIInit.EXTI_Line = EXTI_Line5 | EXTI_Line6;
stEXTIInit.EXTI_Mode = EXTI_Mode_Interrupt;
stEXTIInit.EXTI_Trigger = EXTI_Trigger_Falling;
stEXTIInit.EXTI_LineCmd = ENABLE;
EXTI_Init(&stEXTIInit);
}
Since EXIT5~EXIT9 share an interrupt vector, it is necessary to determine the pending flag in the interrupt to know which interrupt line caused the interrupt:
void EXTI9_5_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line5) != RESET)
{
EXTI_ClearITPendingBit(EXTI_Line5);
SK_SetLedStatus(SK_LED_1, SK_LED_ON);
delay_ms(5000);
SK_SetLedStatus(SK_LED_1, SK_LED_OFF);
}
if(EXTI_GetITStatus(EXTI_Line6) != RESET)
{
EXTI_ClearITPendingBit(EXTI_Line6);
SK_SetLedStatus(SK_LED_2, SK_LED_ON);
delay_ms(5000);
SK_SetLedStatus(SK_LED_2, SK_LED_OFF);
}
}
Previous article:STM32F103ZET6 — ADC
Next article:STM32F103ZET6 — USART
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Notice of community adjustments during the National Day holiday from 13:00 on September 30 to 10:00 on October 8
- Arbotix Usage Process
- Is 996 illegal? Are you still working overtime for a long time?
- Can anyone give me a serial port interrupt receiving program for STM32F03 without HAL library?
- MAXIM was finally acquired
- AD9 won't work anymore
- Share: Lightning strike experiment configuration, differential mode and common mode interference path analysis and design principles
- Design of frequency sweeper using digital frequency synthesis technology, FPGA and single chip microcomputer
- Bluetooth MESH technology makes up for the shortcomings of networking
- Some Problems with Differential Circuits