stm32 priority
1. Priority level:
STM32 users can assign 16 levels of priority, that is, the upper four bits of the priority register NVIC->IP[x] are used to represent the priority of each interrupt.
2. Priority group:
In STM32, the priority of an interrupt is divided into: preemption priority and sub-priority.
When making a priority judgment, the preemption priority is compared first and then the sub-priority is compared.
In the firmware library, variables are used to represent the preemption priority and sub-priority respectively:
NVIC_InitTypeDef.NVIC_IRQChannelPreemptionPriority; (preemption priority)
NVIC_InitTypeDef.NVIC_IRQChannelSubPriority; (sub-priority)
The priority group is the boundary between the preemption priority and the sub-priority:
for example, if the priority group is set to 0x05, it means that the priority of each interrupt starts from the 5th bit as the boundary, and the upper two bits [6:7] are the preemption priority
. The second bit is [5:4], which represents the sub-priority.
Example:
//Call the priority group setting function and set the priority to 0x05.
.....
NVIC_SetPriorityGrouping(5);
.....
//Here, it is explained that the 7th and 6th bits of a priority register (NVIC->IP[x]) represent the preemption priority. 5 and 4 represent the priority.
......
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
.......
//Here is the priority setting: From the above settings, we can know that the preemption priority and sub-priority range are both 3~0;
//Then the priority of an interrupt is set
Previous article:STM32F4 sets NVIC interrupt priority grouping
Next article:Understanding interrupt priorities in STM32
Recommended ReadingLatest update time:2024-11-16 17:33
- Popular Resources
- Popular amplifiers
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
- Sensor materials for learning at home: the hottest collection of EE sensor materials
- [RVB2601 Creative Application Development] Unboxing
- A brief description of the stack structure in the ZigBee standard
- Guess: What is the origin of the code name of the open source "Wanli" Raspberry Pi car that went viral yesterday?
- E103-W01-BF Unboxing and Brief Introduction
- SensorTile.box trial (unboxing and mobile APP connection)
- [Silicon Labs Development Kit Review] +Si7021 Temperature and Humidity Sensor Detection
- RISC-V RVB2601 first experience--Section 3--IO simulation serial port completed
- Talk to a VICOR engineer about your design and how to improve your AT equipment throughput and uptime.
- [HC32F460 Development Board Review] (Part 5) On-Chip Programmable Gain Amplifier (PGA) Review