概念
中断向量:中断服务程序的入口地址(首地址);
中断向量表:系统中RAM或ROM的一个区域,用于存储各种中断向量的首地址,其大小取决于CPU支持的中断类型和数量; 中断优先级:多个中断源同时向CPU申请中断,为了能够有序地处理多个中断申请所以要有中断优先级的规定。对于CPU来说中断源的优先级是默认规定好的;
外设级中断:产生中断请求,未屏蔽则传到PIE级;
PIE级中断:分组与仲裁,向CPU提出申请。PIE级中断又分为可屏蔽中断(检查IER和INTM决定是否响应)和非屏蔽中断(立即响应);
CPU级中断:终极响应。完成当前指令,清流水线,自动保存现场,取中断向量送PC,执行ISR。
PIE----------Peripheral Interrupt Expansion-外设中断扩展模块
步骤
1、关闭CPU级中断总开关;
2、关闭PIE级中断;
3、关闭PIE组开关;
4、清除组中断标志;
5、启动PIE_Vector RAM区;
6、配置PIE中断;
7、注册PIE中断向量;
8、开启PIE支路开关;
9、开启组开关;
10、开启总开关;
中断寄存器:
CPU中断标志寄存器IFR和CPU中断使能寄存器IER跟上面PIE级寄存器是一样的关系,只不过响应的级别不同而已,贴图
程序
void InitPieCtrl(void)
{
// Disable Interrupts at the CPU level:
//#define DINT asm(" setc INTM")
DINT;
// Disable the PIE
PieCtrlRegs.PIECTRL.bit.ENPIE = 0;
// Clear all PIEIER registers:
PieCtrlRegs.PIEIER1.all = 0;
PieCtrlRegs.PIEIER2.all = 0;
PieCtrlRegs.PIEIER3.all = 0;
PieCtrlRegs.PIEIER4.all = 0;
PieCtrlRegs.PIEIER5.all = 0;
PieCtrlRegs.PIEIER6.all = 0;
PieCtrlRegs.PIEIER7.all = 0;
PieCtrlRegs.PIEIER8.all = 0;
PieCtrlRegs.PIEIER9.all = 0;
PieCtrlRegs.PIEIER10.all = 0;
PieCtrlRegs.PIEIER11.all = 0;
PieCtrlRegs.PIEIER12.all = 0;
// Clear all PIEIFR registers:
PieCtrlRegs.PIEIFR1.all = 0;
PieCtrlRegs.PIEIFR2.all = 0;
PieCtrlRegs.PIEIFR3.all = 0;
PieCtrlRegs.PIEIFR4.all = 0;
PieCtrlRegs.PIEIFR5.all = 0;
PieCtrlRegs.PIEIFR6.all = 0;
PieCtrlRegs.PIEIFR7.all = 0;
PieCtrlRegs.PIEIFR8.all = 0;
PieCtrlRegs.PIEIFR9.all = 0;
PieCtrlRegs.PIEIFR10.all = 0;
PieCtrlRegs.PIEIFR11.all = 0;
PieCtrlRegs.PIEIFR12.all = 0;
}
IER = 0x0000; //clear flag
IFR = 0x0000;
//初始化中断向量
void InitPieVectTable(void)
{
int16 i;
Uint32 *Source = (void *) &PieVectTableInit;
Uint32 *Dest = (void *) &PieVectTable;
// Do not write over first 3 32-bit locations (these locations are
// initialized by Boot ROM with boot variables)
Source = Source + 3;
Dest = Dest + 3;
EALLOW;
for(i=0; i < 125; i++)
*Dest++ = *Source++;
EDIS;
// Enable the PIE Vector Table
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
}
---------------------
作者:隔壁发哥
来源:CSDN
原文:https://blog.csdn.net/BHK_SOFTWARE/article/details/52059805
版权声明:本文为博主原创文章,转载请附上博文链接!