当前位置:网站首页>STM32 - interrupt overview (interrupt priority)
STM32 - interrupt overview (interrupt priority)
2022-07-28 22:37:00 【Green hedgerow bamboo maple】
Interruption refers to the process of computer operation , When there are some unexpected situations that require host intervention , The machine can automatically stop the running program and transfer to the program dealing with new situations , After processing, the program that was suspended will continue to run
STM32 Interrupts and exceptions for
(1) Functions for exceptions and external interrupts , about STM32 In terms of single chip microcomputer , It is made by Cortex-M The kernel provides support , This part of the function sometimes ST The company in Cortex-M Extended or modified from the kernel
(2) The concepts of exception and interrupt are similar , Exceptions can be said to be caused by kernel activities ( For example, there is an error in executing instructions ), Interruption generally refers to , There are external devices connected to the core ( peripherals ) produce ( For example, peripheral interrupts , Prompt that the data transmission is complete ), Their triggering or processing mechanism is the same , The two are not strictly distinguished in use
STM32 List of exceptions and interrupts

You can see , Exceptions are represented by numbers , And there are many interrupt types , Interrupt has priority
Interrupt priority
(1) Interrupt priority is divided into two types , Programmable and non programmable , Programmable representation can modify interrupt priority by itself , What is not programmable cannot be modified
(2) about STM32 Interrupt priority , Determines whose interrupt request the kernel responds to first
(3) The principle of small value first , The smaller the interrupt priority value , Interrupts will be prioritized accordingly
(4) Interrupt priority is configured according to priority grouping
Interrupt priority grouping
With F103 For example ,STM32 Use only on M3 The kernel supports 8bit High priority 4 position bit, That is to say STM32 Support 2^4 Priority
| bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 |
| Used to express priority | not used , Read back as 0 | ||||||
stay F103 On , Use this 4 individual bit, Organized into 5 Group priority grouping , Each group is divided into 1 Preemptive groups ,1 Sub priority group
| Priority groups | preemption | Sub priority | describe |
| NVIC_PriorityGroup_0 | 0 | 0-15 | Lord -0bit, Son -4bit |
| NVIC_PriorityGroup_1 | 0-1 | 0-7 | Lord -1bit, Son -3bit |
| NVIC_PriorityGroup_2 | 0-3 | 0-3 | Lord -2bit, Son -2bit |
| NVIC_PriorityGroup_3 | 0-7 | 0-1 | Lord -3bit, Son -1bit |
| NVIC_PriorityGroup_4 | 0-15 | 0 | Lord -4bit, Son -0bit |
For groups 0, Preemption priority is 0, It means that he didn't preempt the priority ,4 individual bit All are used to represent sub priorities . For groups 1, Preemption priority is 0-1, use 1 individual bit Indicates preemption priority , rest 3 individual bit Indicates sub priority ...
(1) Group by priority , You can manage the response sequence of interrupts
(2) Only preemption priority can be interrupted by preemption , Interrupt nesting occurs , Break occurs when you break , Unable to interrupt , Then it will be suspended
If the event A Preemption priority is 0,B The preemption priority of is 10, stay B In the process of execution ,A Make an interrupt request , Will rob B The right to use the interruption , etc. A After the execution, continue the execution B(ps: If A Don't interrupt the event B,A Will be suspended )
(3) If the interrupt preemption priority is the same , No preemption
(4) If multiple suspended interrupts have the same preemption priority , Then the child with high priority will go first , If the sub priorities are the same , be IRQ( Usually refers to external interrupt request ) Small numbers go first (IRQ Source e.g :stm32f103xe.h)
preemption > Sub priority >IRQ Number

(5) Programmable priority , Interrupt the controller through nested vectors (NVIC) Realization
| NVIC Library function | describe |
| void NVIC_EnableIRQ(IRQn_Type IRQn) | To interrupt |
| void NVIC_DisableIRQ(IRQn_Type IRQn) | Disability interruption |
| void NVIC_SetPendingIRQ(IRQn_Type IRQn) | Set the interrupt suspend position ( Initiate interrupt request , Hardware trigger ) |
| void NVIC_ClearPendingIRQ(IRQn_Type IRQn) | Clear the interrupt suspend position |
| uint_32t NVIC_GetPendingIRQ(IRQn_Type IRQn) | Get the interrupt suspension number |
| void NVIC_SetPriorityIRQ(IRQn_Type IRQn,uint32_t priorty) | Set interrupt priority |
| uint_32t NVIC_GetPriorityIRQ(IRQn_Type IRQn) | Get interrupt priority |
| void NVIC_SystemReset(void) | System reset |
边栏推荐
- Common commands of NPM
- Paddlenlp is based on ernir3.0 text classification. Take the crime prediction task of cail2018-small dataset as an example [multiple tags]
- CMD common commands
- MySQL installation and configuration (super detailed, simple and practical)
- [Ruiji takeout project]day4 - dish management
- The blueprint of flask complements openpyxl
- What is time complexity
- 842. 排列数字
- 使用webWorker执行后台任务
- Which is the file transfer command in the basic services of the Internet
猜你喜欢
随机推荐
How to realize dynamic route switching and route caching in vuejs
PaddleNLP基于ERNIR3.0文本分类:WOS数据集为例(层次分类)
Mysql8.0 cannot authorize users or prompt you are not allowed to create a user with grant
When can I sign up for the 2022 class I constructor examination?
Jmeter 安装第三方插件 Plugins Manager
Kali source solution software cannot be installed correctly
Soft exam network engineer
SQL injection less42 (post stack injection)
winServer运维技术栈
Solve various problems of sudo rosdep init and rosdep update
Ngrok intranet penetration
Integrating database Ecology: using eventbridge to build CDC applications
imx6q gpio复用
NPM switch Taobao source (NPM source)
Ngx+sql environment offline installation log (RPM installation)
Solve Jupiter: the term 'Jupiter' is not recognized as the name of a cmdlet, function, script file
二进制的原码、反码、补码
Ultra detailed visual studio 2019 running littlevgl (lvgl) simulator
Paddlenlp text classification based on ernir3.0: take wos dataset as an example (hierarchical classification)
Target segmentation learning









