想实现的功能是,通过按下key1,key2中断EINT0,EINT1,
使led1和led2点亮。
修改的程序如下:
void VICInit(void)
{
extern void IRQ_Handler(void);
extern void Timer0_Handler(void);
extern void UART0_Handler(void);
extern void EINT0_Handler(void);
extern void EINT1_Handler(void);
VICIntEnClr = 0xffffffff;
VICDefVectAddr = (uint32)IRQ_Handler;
VICIntSelect=0x00000000;
VICVectAddr14 = (uint32)UART0_Handler;/*向量地址*/
VICVectCntl14 = (0x20 | 0x06);/*优先级*/
VICIntEnable = 1 << 6;/*中断使能*/
VICVectAddr15 = (uint32)Timer0_Handler;
VICVectCntl15 = (0x20 | 0x04);
VICIntEnable = 1 << 4;
VICVectAddr13 = (uint32)EINT0_Handler;
VICVectCntl13=(0x20|0x0E);
VICIntEnable=1<<14;
VICVectAddr12 = (uint32)EINT1_Handler;
VICVectCntl12=(0x20|0x0F);
VICIntEnable=1<<15;
}
EINT0和EINT1的中断程序为:
void EINT0_Exception(void)
{
uint32 i;
uint8 cp1;
OS_ENTER_CRITICAL();
i=VICIRQStatus;
VICVectAddr = 0;
OS_EXIT_CRITICAL();
cp1=0x05;
OSMboxPost(EintMbox,&cp1);
}
void EINT1_Exception(void)
{
uint32 i;
uint8 cp2;
OS_ENTER_CRITICAL();
i=VICIRQStatus;
VICVectAddr = 0;
OS_EXIT_CRITICAL();
cp2=0x06;
OSMboxPost(EintMbox,&cp2);
}
uint8 EintGet(void)
{
uint8 err;
uint8 *ok;
ok=(uint8 *)OSMboxPend(EintMbox,0,&err);
return *ok;
}
vectors.s中添加:
;通用串行口0中断
UART0_Handler HANDLER UART0_Exception
EINT1_Handler HANDLER EINT1_Exception
EINT0_Handler HANDLER EINT0_Exception
主程序中添加:
cp1=EintGet();
可是永远得不到值。另外调试中断有没有经验呀,太不好调了。 |