打印
[DSP编程]

CPU的定时器0中断怎么进不去?

[复制链接]
1750|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zh9454|  楼主 | 2014-4-8 17:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include "2812.h"
cregister volatile WORD IER;
cregister volatile WORD IFR;
static WORD loopcount = 0;
void SetupInterrupts(void);
void Time0Init(DWORD Freq,DWORD Period)
{
DWORD temp;
temp = Freq*Period;
TIMER0TIM = 0;
TIMER0TPR = 0;
TIMER0PRD = temp-1;
TIMER0TCR = 0x4820;
}
void InitGpio(void)
{
EALLOW;
GPAMUX = 0x0000;
GPADIR = 0xffff;
GPAQUAL = 0x0000;
GPBMUX = 0x0000;     // GPIO:0-15;
GPBDIR = 0x07ff;     // Input:11-15; Output:0-10;
GPBQUAL = 0x00ff;     // Input Qual: HSPCLK/510;
GPDMUX = 0x0000;     // GPIO:0-15;
GPDDIR = 0xffff;     // Output:0-15;
GPDQUAL = 0x00;      // Input Qual: NULL;
GPEMUX = 0x0003;     // GPIO:8-15; 0:XINT1; 1:XINT2;
GPEDIR = 0x0000;     // Input:8-15;
GPEQUAL = 0x00ff;     // Input Qual: HSPCLK/510;
GPFMUX = 0x00f7;     // GPIO:8-15;
GPFDIR = 0xff08;     // Output:8-15;
GPGMUX = 0x00ff;     // GPIO:8-15;
GPGDIR = 0xff00;     // Output:8-15;
EDIS;
GPADAT = 0xffff;
GPBDAT = 0x0000;
GPDDAT = 0x0000;
GPEDAT = 0x0000;
GPFDAT = 0x0008;
GPGDAT = 0x0000;
}
void SystemInit(WORD Sysclk,WORD Oscclk)
{
WORD i,Freq,OSC;
Freq = Sysclk;
OSC = Oscclk;
EALLOW;
WDCR = 0x0068;   //Disable WatchDog;
PLLCR = Freq*2/OSC;  //SYSCLKOUT=CLKIN=150MHz,SYSCLKOUT=CLKIN=(OSCCLK*PLLCR/2);
for(i=0;i<1000;i++)  // Delay for PLL to stabilize;
{
  asm(" NOP");
}
PCLKCR = 0x0000;  //Enable of Peripheral Clock;
HISPCP = 0x0001;  
LOSPCP = 0x0002;  
IER = 0x0000;   
IFR = 0x0000;   
EDIS;
SetupInterrupts();
Time0Init(150,1000); //定时1ms
InitGpio();
}
interrupt void UnusedIsr(void)
{
return;
}
int main(void)
{
DINT;
SystemInit(150,30);
PIEIER1 = 0x0040;
PIECTRL |= 1;
IER |= 1;
EINT;
ERTM;
while(1);
}

/*CPU定时器,Time1、Time2、Time0*/
interrupt void CPU_Time0(void)
{
loopcount++;
if(loopcount>5000){loopcount = 0;GPADAT = 0x0000;}
TIMER0TCR |= 0x8000;
PIEACK |= 0x0001;
EINT;
}

typedef void (*VECTORS)();//函数指针
void SetupInterrupts(void)
{
VECTORS* pVectors = (VECTORS*)0x0d02;
asm(" EALLOW");
*pVectors++ = UnusedIsr;   // INT1   - Maskable int 1            ;
*pVectors++ = UnusedIsr;   // INT2   - Maskable int 2            ;
*pVectors++ = UnusedIsr;   // INT3   - Maskable int 3            ;
*pVectors++ = UnusedIsr;   // INT4   - Maskable int 4            ;
*pVectors++ = UnusedIsr;   // INT5   - Maskable int 5            ;
*pVectors++ = UnusedIsr;   // INT6   - Maskable int 6            ;
*pVectors++ = UnusedIsr;   // INT7   - Maskable int 7            ;
*pVectors++ = UnusedIsr;   // INT8   - Maskable int 8            ;
*pVectors++ = UnusedIsr;   // INT9   - Maskable int 9            ;
*pVectors++ = UnusedIsr;   // INT10  - Maskable int 10           ;
*pVectors++ = UnusedIsr;   // INT11  - Maskable int 11           ;
*pVectors++ = UnusedIsr;   // INT12  - Maskable int 12           ;
*pVectors++ = UnusedIsr;   // INT13  - Maskable int 13, timer 1  ;
*pVectors++ = UnusedIsr;   // INT14  - Maskable int 14, timer 2  ;
*pVectors++ = UnusedIsr;   // DLOGINT- Maskable data-logging int ;
*pVectors++ = UnusedIsr;   // RTOSINT- Maskable real-time OS int ;
*pVectors++ = UnusedIsr;   // Reserved                           ;
*pVectors++ = UnusedIsr;   // NMI    - Nonmaskable interrupt     ;
*pVectors++ = UnusedIsr;   // ILLEGAL- Illegal instruction trap  ;
*pVectors++ = UnusedIsr;   // USER1  - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER2  - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER3  - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER4  - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER5  - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER6  - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER7  - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER8  - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER9  - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER10 - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER11 - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;   // USER12 - User-defined sw int/trap  ;
*pVectors++ = UnusedIsr;            // PIE int 1.1 ;
*pVectors++ = UnusedIsr;            // PIE int 1.2 ;
*pVectors++ = UnusedIsr;            // PIE int 1.3 ;
*pVectors++ = UnusedIsr;          // PIE int 1.4 XINT1;
*pVectors++ = UnusedIsr;          // PIE int 1.5 XINT2;
*pVectors++ = UnusedIsr;            // PIE int 1.6 ;
*pVectors++ = CPU_Time0;            // PIE int 1.7 ;
*pVectors++ = UnusedIsr;            // PIE int 1.8 ;
asm(" EDIS");
}

新手谢谢指导!

相关帖子

沙发
zhangmangui| | 2014-4-8 22:02 | 只看该作者
肯定是没有配置好  你对比一下看看吧

TOP2812_CODE.zip (680.93 KB)

使用特权

评论回复
板凳
zh9454|  楼主 | 2014-4-18 10:12 | 只看该作者
下到板子里可以进去了

使用特权

评论回复
地板
sjl0991| | 2014-4-20 16:55 | 只看该作者
软件仿真应该也可以啊?和硬件仿真没什么区别。

使用特权

评论回复
5
zh9454|  楼主 | 2014-4-21 15:51 | 只看该作者
sjl0991 发表于 2014-4-20 16:55
软件仿真应该也可以啊?和硬件仿真没什么区别。

也搞不清楚 但是就进去了啊

使用特权

评论回复
6
zhangmangui| | 2014-4-21 22:43 | 只看该作者
zh9454 发表于 2014-4-18 10:12
下到板子里可以进去了

嗯   程序全速运行  也应该能进去才对   

使用特权

评论回复
7
sjl0991| | 2014-5-24 16:22 | 只看该作者
自己失误造成的,没把nmi终端使能打开.

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

17

主题

110

帖子

3

粉丝