当前位置:网站首页>刚学嵌入式,想问问什么是中断,中断的概念是什么
刚学嵌入式,想问问什么是中断,中断的概念是什么
2022-06-09 20:25:00 【大方老师讲单片机】
一个简单的生活场景:孩子在卧室睡觉,妈妈在客厅看书,那么,妈妈如何知道孩子醒了?

· 时时进房间查看:查询方式
· 进房间陪小孩一起睡觉,小孩醒了会吵醒她:休眠-唤醒
· 妈妈要干很多活,但可以定个闹钟陪小孩睡一会:poll方式
· 妈妈在房间干活,小孩自己醒了,走出房间告诉妈妈:异步通知
后面3中方式都需要小孩中断妈妈:中断她的睡眠、她的工作。


事实上能“中断”妈妈的事儿多着呢
· 远处猫叫:忽略
· 门铃,小孩哭声:对应不同处理
· 身体不舒服:赶紧休息
· 有蜘蛛掉下来:赶紧跑
妈妈正在看书。被中断后的流程:
· 正在看书
· 发生各种声音:中断源
o 远处猫叫
o 小孩哭声
o 门铃 ...
怎么处理
· 先在书中放上书签,合上书:保存现场
· 去处理:中断服务程序
· 回来继续看书:返回处理
嵌入式系统中的中断


CPU 在运行过程中会被各种“异常”打断:
· 未定义
· 指令、数据有问题
· SWI:软中断
· 快中断
· 中断
中断也是一种异常。导致中断的情况有很多:
· 按键
· 定时器
· ADC转换完成
· UART发送完数据、收到数据
· 等等
这些中断源,汇集到中断控制器,由中断控制器选择最高的中断并通知CPU
中断处理流程
· 初始化:
o 设置中断源:何种中断
o 设置中断控制器(屏蔽某个中断,中断优先级)
o 设置CPU总开关:使能中断
· 执行正常程序:
· 产生中断:比如按下按键 -> 中断控制器 -> CPU
· CPU 没执行一条命令都会检查有无中断/异常的产生
· CPU发现有中断/异常,开始处理:
o 对于不同的的异常,跳转到不同的地址执行程序
o 这个地址上,只是一条跳转指令,跳去执行某个函数,这个就是异常向量。
后3步都是硬件做的。软件做的:
· 保存现场(各种寄存器)
· 处理异常和中断
· 恢复现场
边栏推荐
- LeetCode 497. 非重叠矩形中的随机点**
- Leetcode 1984. Minimum difference in student scores (yes, resolved)
- Target Segmentation -- semantic segmentation of multi category dataset by Unet
- Leetcode 1984. 学生分数的最小差值(可以,已解决)
- Leetcode 1984. Différence minimale entre les notes des élèves (Oui, résolu)
- 压缩文件报错 tar: Exiting with failure status due to previous errors
- Redis知识点
- Official announcement! Broadcom will acquire VMware with us $61billion and assume US $8billion in debt
- Resolving the disorder of JSON parsing by fastjson
- STM32 memory knowledge
猜你喜欢

Neo4j桌面版數據庫備份

HMI 串口屏 SD卡/TF卡升级的 bug

Drink at night, 50 classic SQL questions, really fragrant~

Potential functions commonly used in lammps and collection of crystal library resources

A potential bug in creating project generated word library in HMI

Sauvegarde de la base de données neo4j Desktop

Set creation and traversal methods

申请软件代码签名证书

leetcode-栈与队列

Unity upgrade project to URP
随机推荐
上海光机所两名员工核酸阳性,园区367人将被转运
Leetcode 1984. 学生分数的最小差值(可以,已解决)
UTM转经纬度
Oracle one line to multiple lines
压缩文件报错 tar: Exiting with failure status due to previous errors
C#中关于Partial的作用
Kalman filter (KF) unscented Kalman filter (UKF)
ClickHouse 数据插入、更新与删除操作 SQL
Jvm- how the bytecode is executed by the JVM + a little thought about the thread primer
看看人家那文本识别系统,那叫一个优雅!
95后大厂程序员删库被判刑9个月
卡尔曼滤波(KF)无迹卡尔曼滤波(UKF)
2022 Shandong Health Expo, dietotherapy and nourishing health exhibition, health management and precision medicine Exhibition
Jerry's use of network diagram to replace LwIP library and WiFi library [chapter]
Discussion on mobx
Problems and solutions of HMI online download failure
Jerry's modification to improve the output frame rate of camera source video [chapter]
Edge browser setting network speed limit
Jerry's chart confirms that the project has not opened config_ NO_ SDRAM_ Enable macro, SDRAM used in the project [chapter]
JVM-字节码是如何被JVM执行的+关于线程一点思想引子