刚学DSP,写了一个DSP定时器中断的代码,中断服务程序显示的现象一直无法理解,请大侠指点,主要代码如下,代功能就是每次定时器中断时,把LED的显示状态进行翻转。但是实际跑出来的结果完全不同,也搞不懂它显示规律。
#include <csl.h>
#include <csl_emifa.h>
#include <csl_irq.h>
#include <csl_chip.h>
/*VMDM642的emifa的设置结构*/
EMIFA_Config vmd642ConfigA ={
0x00052078,/*gblctl EMIFA(B)global control register value */
/*将CLK6、4、1使能;将MRMODE置1;使能EK2EN,EK2RATE*/
0xffffffd3,/*cectl0 CE0 space control register value*/
/*将CE0空间设为SDRAM*/
0x73a28e01,/*cectl1 CE1 space control register value*/
/*Read hold: 1 clock;
MTYPE : 0000,选择8位的异步接口
Read strobe :001110;14个clock宽度
TA:2 clock; Read setup 2 clock;
Write hold :2 clock; Write strobe: 14 clock
Write setup :7 clock
-- ---------------
\ 14c /1c
\----------------/ */
0x22a28a22, /*cectl2 CE2 space control register value*/
0x22a28a42, /*cectl3 CE3 space control register value*/
0x57116000, /*sdctl SDRAM control register value*/
0x0000081b, /*sdtim SDRAM timing register value*/
0x001faf4d, /*sdext SDRAM extension register value*/
0x00000002, /*cesec0 CE0 space secondary control register value*/
0x00000002, /*cesec1 CE1 space secondary control register value*/
0x00000002, /*cesec2 CE2 space secondary control register value*/
0x00000073 /*cesec3 CE3 space secondary control register value*/
};
TIMER_Config MyConfig = {
0x00000200, /* ctl */
0x00630000, /* prd */
0x00000000 /* cnt */
};
/* LED address*/
Uint8 *pled = (Uint8*)0x90080015 ;
extern far void vectors();
void main()
{
TIMER_Handle hTimer;
Uint32 dwTimerEventId;
/*----------------------------------------------------------*/
/*Initialise CSL,初始化CSL库*/
CSL_init();
/*----------------------------------------------------------*/
/*EMIFA的初始化,将CE0设为SDRAM空间,CE1设为异步空间
EMIFA_config(&vmd642ConfigA);
/*----------------------------------------------------------*/
*pled = 0xaa; /*LED灯初始状态,0为亮,1为灭*/
/*定时器初始化*/
hTimer = TIMER_open(TIMER_DEV0, 0);
dwTimerEventId = TIMER_getEventId(hTimer);
TIMER_config(hTimer, &MyConfig);
/*中断向量表的初始化*/
//Point to the IRQ vector table
IRQ_setVecs(vectors);
IRQ_globalEnable(); //全局中断使能 IER|=1<<14
IRQ_nmiEnable();
IRQ_map(dwTimerEventId,14); //把定时中断重新映射到 14 MUXH[25:21]=0×02
IRQ_reset(dwTimerEventId);
IRQ_enable(dwTimerEventId);
/*定时器启动*/
TIMER_start(hTimer);
for(;;)
{
}
}
interrupt void timer0(void)
{
*pled = ~(*pled); /*每次中断,LED灯的状态发生翻转*/
} |