当前位置:网站首页>Three ways for Cortex-M kernel to manage global interrupts
Three ways for Cortex-M kernel to manage global interrupts
2022-07-28 11:03:00 【tutu-hu】
List of articles
1. Use PRIMASK Register mask interrupt
usage :PRIMASK Registers can be masked except NMI and HardFault All exceptions and interrupts except these two interrupts .
Program realization :
<1> When using assembly , have access to CPS( Modify the processor state ) Instruction to modify PRIMASK The value of the register :
CPSIE I; // eliminate PRIMASK( To interrupt )
CPSID I; // Set up PRIMASK( No interruptions )<2>PRIMASK Registers can also be accessed through MRS and MSR Command access , as follows :
MOVS R0, #1
MSR PRIMASK,R0 ; // take 1 write in PRIMASK Disable all interrupts
as well as :
MOVS R0, #0
MSR PRIMASK,R0 ; // take 0 write in PRIMASK To enable all interrupts 2. Use FAULTMASK Register mask interrupt
usage :FAULTMASK Than PRIMASK stronger , It will raise the priority of the current exception to -1, So you can connect HardFault It's all blocked .FAULTMASK How to use and PRIMASK similar ,FAULTMASK It will be reset automatically when exiting .
Program realization :
<1> When using assembly , have access to CPS( Modify the processor state ) Instruction to modify PRIMASK The value of the register :
CPSIE F; // eliminate FAULTMASK( To interrupt )
CPSID F; // Set up FAULTMASK( No interruptions )<2>FAULTMASK Registers can also be accessed through MRS and MSR Command access , as follows :
MOVS R0, #1
MSR FAULTMASK,R0 ; // take 1 write in FAULTMASK Disable all interrupts
as well as :
MOVS R0, #0
MSR FAULTMASK,R0 ; // take 0 write in FAULTMASK To enable all interrupts 3. Use BASEPRI Register mask interrupt
usage :FAULTMASK and PRIMASK Register is directly closed except reset ,NMI,HardFault All other interrupts except , But in some cases, it is necessary to control the interrupt shielding more finely , For example, only interrupts with priority lower than a certain threshold are screened . This threshold priority is stored in the register BASEPRI in , towards BASEPRI Write 0 Will stop shielding interrupt .
such as , The priority of shielding should not be higher than 0x50 The interrupt , You can use the following assembly instructions :
MOVS R0, #0x50
MSR BASEPRI,R0 If you need to cancel BASEPRI Shielding of interrupts , You can use the following code :
MOVS R0, #0
MSR BASEPRI,R0边栏推荐
- float浮动初步理解
- Table data processing software, what else besides excel?
- Arduino基础知识
- If you don't climb mountains, you don't know the height of the sky; If you don't face deep streams, you don't know the thickness of the earth
- 低代码(aPaas)为什么最近又火了?
- 盘点:令人心动的数据可视化图表
- I don't know how lucky the boy who randomly typed logs is. There must be a lot of overtime
- nodejs:mongodb 插入成功之后的返回值
- Installation points and precautions of split angle probe
- 做数据分析,你还不懂RFM分析方法(模型)?
猜你喜欢

CTF skill tree - file upload

JS - 修改数组中对象的键名

Learn these analysis methods and models, and no longer have no ideas when encountering problems

低代码十问:一文讲透关于低代码的一切!

Yan reports an error: exception message: /bin/bash: line 0: fg: no job control

蓝桥杯嵌入式-HAL库-LCD

Here is a super practical excel shortcut set (common + summary of eight categories)

float浮动初步理解

3. MapReduce explanation and source code analysis

剑指 Offer 06. 从尾到头打印链表
随机推荐
JS - 修改数组中对象的键名
c语言链表的使用
构建快捷开发IDE:VisualSVN+Sublime+Visual Studio 2013+QuickEasyFTPServer
适合中小企业的进销存软件,搞定5大难题
学会这些分析方法及模型,遇到问题不再没思路
Nodejs: set up the express service, set up the session and realize the exit operation
网络文件系统服务(NFS)
蓝桥杯嵌入式-HAL库-USART_TX
Blue Bridge Cup embedded Hal library USART_ TX
判断数码管是共阳极还是共阴极
哈希表的相关知识点
Software designers ask 20 questions before the exam, pay attention!!
Blue Bridge Cup embedded Hal library USART_ RX
Network file system service (NFS)
Reading these six books makes learning MySQL easier
Yan reported an error: could not find any valid local directory for nmprivate/
Explanation of JDBC classes
Causes and solutions of invalid ROM table
Nodejs: detect and install the NPM module. If it is already installed, skip
CGAL compilation error