⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xint.c

📁 ICETEK-F2812-A评估板所附带的源程序.rar
💻 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 CTRGR *(int *)0x108000
#define CTRLCDCMDR *(int *)0x108001
#define CTRKEY *(int *)0x108001
#define CTRLCDCR *(int *)0x108002
#define CTRCLKEY *(int *)0x108002
#define CTRLCDLCR  *(int *)0x108003
#define CTRLCDRCR *(int *)0x108004
#define CTRLA *(int *)0x108005
#define CTRLR *(int *)0x108007

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扩展板
   CTRGR=0;		// 初始化ICETEK-CTR
   CTRGR=0x80;
   CTRGR=0;
   CTRLR=0;			// 关闭东西方向的交通灯
   CTRLR=0x40;	// 关闭南北方向的交通灯
   CTRLR=0xc1;
  uPort8000=CTRCLKEY;

     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 + -