dsp编程部分提示.doc_第1页
dsp编程部分提示.doc_第2页
dsp编程部分提示.doc_第3页
dsp编程部分提示.doc_第4页
dsp编程部分提示.doc_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include DSP281x_Device.h / DSP281x Headerfile Include File#include DSP281x_Examples.h / DSP281x Examples Include File/ Prototype statements for functions found within this errupt 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 *)0x108007int 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; CTRGR=0x80; CTRGR=0; CTRLR=0;/ 关闭东西方向的交通灯 CTRLR=0x40;/ 关闭南北方向的交通灯 CTRLR=0xc1; CTRLR=0xc8;/使能键盘外中断 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;iinDelay;ii+ ) for ( jj=0;jj512;jj+ )kk+;/=/ No more./=#include DSP281x_Device.h / DSP281x Headerfile Include File#include DSP281x_Examples.h / DSP281x Examples Include File/ Prototype statements for functions found within this errupt void cpu_timer0_isr(void);#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 *)0x108007int i=0,nCount;unsigned int uLBD;void main(void) unsigned int uPort8000; InitSysCtrl();/初始化cpu DINT;/关中断 InitPieCtrl();/初始化pie寄存器 IER = 0x0000;/禁止所有的中断 IFR = 0x0000; InitPieVectTable();/初始化pie中断向量表 EALLOW; / This is needed to write to EALLOW protected registers PieVectTable.TINT0 = &cpu_timer0_isr;/指定中断服务子程序 EDIS; / This is needed to disable write to EALLOW protected registers CpuTimer0.RegsAddr = &CpuTimer0Regs;/ Initialize timer period to maximum:CpuTimer0Regs.PRD.all = 0xff00;/ Initialize pre-scale counter to divide by 1 (SYSCLKOUT):CpuTimer0Regs.TPR.all = 0;CpuTimer0Regs.TIM.all = 0;CpuTimer0Regs.TPRH.all = 0;/ Make sure timer is stopped:CpuTimer0Regs.TCR.bit.TSS = 1;CpuTimer0Regs.TCR.bit.SOFT = 1;CpuTimer0Regs.TCR.bit.FREE = 1;/ Reload all counter register with period value:CpuTimer0Regs.TCR.bit.TRB = 1;CpuTimer0Regs.TCR.bit.TIE = 1;/ Reset interrupt counters:CpuTimer0.InterruptCount = 0; StartCpuTimer0();/启动定时器0/ 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.INTx7 = 1;/ Enable global Interrupts and higher priority real-time debug events: EINT; / Enable Global interrupt INTM ERTM; / Enable Global realtime interrupt DBGM CTRGR=0;/ 初始化CTR CTRGR=0x80; CTRGR=0; CTRLR=0;/ 关闭东西方向的交通灯 CTRLR=0x40;/ 关闭南北方向的交通灯 uPort8000=CTRCLKEY; while ( 1 ) interrupt void cpu_timer0_isr(void) int j,k; /CpuTimer0.InterruptCount+; / Acknowledge this interrupt to receive

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论