1. Classification of interruptions:
A global interrupt means that interrupt service can be executed immediately in any part of the running program. If an open interrupt instruction is added during the program interrupt, it means that when the conditions for the interrupt are met, the interrupt service can only be executed after the instruction to enable the interrupt is executed.
External interrupts are maskable interrupts, that is, the interrupt controller can be used to mask the interrupt requests of these external devices.
Internal interrupts refer to interrupts caused by hardware errors (such as sudden power failure, parity error, etc.) or calculation errors (division by zero, calculation overflow, single-step interrupt, etc.).
Each IO port of STM32F10 can be set as an external interrupt, up to 19 can be set, 16+3=19
When designing the hardware, be careful not to connect external interrupts to PA[1], PB1], PC[1], etc., because then the processor can only choose one as an interrupt source.
in addition:
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 the Ethernet wake-up event
2. Interrupt Priority
The interrupt priority relationship of interrupt sources can be summarized into the following two basic principles:
(1) A low priority level can be interrupted by a high priority level, but a high priority level cannot be interrupted by a low priority level.
(2) Once any interrupt (whether high-level or low-level) is responded to, it will not be interrupted by an interrupt source of the same level.
In STM32, interrupts are configured with priority by group. Each interrupt priority group includes: preemptive priority and responsive priority. The former is the level division of preemptive priority, and the latter is the priority division of the same preemptive priority.
for example:
Interrupt A has a higher preemption priority than B, so A's interrupt can be triggered in B, ignoring the response priority;
If A and B have the same preemption priority, the response priority of A and B determines who responds first;
Let's first look at a picture of ST company:
According to NVIC_PriorityGroup_0, there is one preemption (priority) level, and each preemption (priority) level has only 16 sub-priorities: 0-15;
According to NVIC_PriorityGroup_1, there are 2 preemption (priority) levels, and each preemption (priority) level has only 8 sub-priorities: 0-7;
According to NVIC_PriorityGroup_2, there are 4 preemption (priority) levels, and each preemption (priority) level has only 4 sub-priorities: 0-3;
According to NVIC_PriorityGroup_3, there are 8 preemption (priority) levels, and each preemption (priority) level has only 2 sub-priorities: 0-1;
According to NVIC_PriorityGroup_4, there are 16 preemption (priority) levels, and each preemption (priority) level has only one sub-priority level: 0;
Learn with related programs
/* Enable the USART1 Interrupt */Configure the driver part of the serial port interrupt
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //The preemptive priority is 0,
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; The responsive priority under the same preemptive priority cannot interrupt each other
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* SPI1-------------------------------------------------- -------------------------- */
NVIC_InitStructure.NVIC_IRQChannel = SPI1_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
EXTI0_IRQChannel is a high-priority group of level 0 group > SPI's level 3 group, which can interrupt the lower-level group that is doing things (nested), so when SPI is working, EXTI0 can interrupt it and enter EXTI0 interrupt;
The configuration of each interrupt priority can be seen in the library file misc.h
When working with two serial ports at the same time, if you don't want them to be interrupted by each other, you can set their preemptive priorities to the same so that they will not affect each other. The same applies to other ports.
Previous article:The concept of STM32F4 interrupt preemption priority and response priority
Next article:STM32 NVIC interrupt priority grouping description
- 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
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- STM32L151 reads W25Q16 ID error, please help me find out what is the reason
- Lesson 4: Programmable Logic Solutions for Video and Image Processing
- 2020 02 02 Should be distributed at 20:20 Leave a footprint
- Can you provide a text box where I can paste the names of the 8 teachers I often invite directly, so that I don’t have to search them one by one?
- EEWORLD University ---- Miz702 zynq video advanced tutorial (Milinke)
- [National Technology N32G430] 6. STK33B62 optical sensor detection
- Capacitor usage in power supply design
- How to implement an iterative equation using Verilog?
- Qorvo PAC Series Chips in High-Speed DC Motor Control
- FreeRTOS MPU makes the system more robust!