📄 xint.c
字号:
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File
// Prototype statements for functions found within this file.
interrupt void XINT2_isr(void);
// 子程序接口
void Delay(unsigned int nDelay); // 延时子程序
// 定义指示灯寄存器地址和寄存器类型
#define LBDS (*((unsigned int *)0xc0000))
#define XINT2CR (*((unsigned int *)0x7071))
#define XNMICR (*((unsigned int *)0x7077))
#define LEDS *(int *)0xc0000
// 液晶 ----------------------------------------------------------
#define CTRLED (*(unsigned int *)0x108004) // port8004
#define MCTRKEY (*(unsigned int *)0x108005) // port8005
#define CTRCLKEY (*(unsigned int *)0x108006) // port8006
#define CTRSTATUS (*(unsigned int *)0x108000) //port8000
#define CTRGR (*(unsigned int *)0x108000)
int i=0,nCount,a=0;
unsigned int uLBD;
void main(void)
{
unsigned int uPort8000;
// This example function is found in the DSP281x_SysCtrl.c file.
uLBD=nCount=0;
InitSysCtrl();//初始化cpu
DINT;//关中断
InitPieCtrl();//初始化pie寄存器
IER = 0x0000;//禁止所有的中断
IFR = 0x0000;
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.XINT2 = &XINT2_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable CPU INT1 which is connected to CPU-Timer 0:
IER |= M_INT1;
// Enable TINT0 in the PIE: Group 1 interrupt 7
PieCtrlRegs.PIEIER1.bit.INTx5 = 1;
XINT2CR =0x1;/*打开管脚xint2外中断*/
//XNMICR=0x1;/*打开nmi中断*/
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
//初始化CTR扩展板
CTRSTATUS=0x80;
CTRSTATUS=0;
CTRSTATUS=0x80;
CTRSTATUS=0;
CTRLED=0xff;
CTRGR=2; // 使能IO
while ( 1 )
{
if(a==1)
{ LBDS=0x1;//点亮LED灯
a=0;
}
Delay(256);
if(a==0)
{ LBDS=0x0;//关闭LED灯
}
}
}
interrupt void XINT2_isr(void)
{
a=1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
void Delay(unsigned int nDelay)
{
int ii,jj,kk=0;
for ( ii=0;ii<nDelay;ii++ )
{
for ( jj=0;jj<512;jj++ )
{
kk++;
}
}
}
//===========================================================================
// No more.
//========================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -