【求助】6410裸机中断之后不返回
现在想使用6410的裸机中断(触摸屏中断以及按键中断),在启动代码中设置MRC p15, 0, R0, c1, c0, 0
ORR R0, R0, #(1<<24)
MCR p15, 0, R0, c1, c0, 0
开启VIC端口。
然后设置和开启中断:
rGPNCON &= ~(0xFFF);
rGPNCON |= 0xAAA; //设置GPN0-5为外部中断管脚
rGPNPUD |= 0xAAA; //使能上拉电阻
rEINT0CON0 &= ~(0xFFF);
rEINT0CON0 |= 0x777; //双边沿触发
rEINT0FLTCON0 |= (1<<7)|(1<<15)|(1<<23);//开启滤波,延时滤波
rEINT0MASK &= ~(0x3F); //使能外部中断0-5
rVIC0INTSELECT = 0; //全部选择IRQ模式
rVIC1INTSELECT = 0;
rVIC0INTENCLEAR = 0xFFFFFFFF;
rVIC1INTENCLEAR = 0xFFFFFFFF;
rVIC0ADDRESS = 0;
rVIC1ADDRESS = 0;
rEINT0PEND = 0;
rVIC0INTENABLE = 3; //使能EINT0、EINT1
rVIC1INTENABLE = (1<<30); //使能PENDNUP中断
rVIC1VECTADDR30 = (u32)TS_GETPOS;
rVIC0VECTADDR0 = (u32)Key_Handler0;
rVIC0VECTADDR1 = (u32)Key_Handler1;
处理函数如下:
void __irq Key_Handler0(void) //按键检测发生重复检测现象,是重复检测还是Uart的问题
{
u8 i;
for(i=0;i<4;i++)
{
if(rEINT0PEND&(1<<i))
{
if(rGPNDAT&(1<<i))
{
Uart_Trans('K');
Uart_Trans('e');
Uart_Trans('y');
Uart_Trans(':');
Uart_Trans(i+1+'0');
Uart_Trans(' ');
Uart_Printf("Key Released. ");
}
else
{
Uart_Trans('K');
Uart_Trans('e');
Uart_Trans('y');
Uart_Trans(':');
Uart_Trans(i+1+'0');
Uart_Trans(' ');
Uart_Printf("Key Pressed. ");
}
}
}
rEINT0PEND |= 0x3F;//向对应位写1来清除,在循环之外清除
rVIC0ADDRESS = 0;
}
void __irq Key_Handler1(void) //按键检测发生重复检测现象,是重复检测还是Uart的问题
{
u8 i;
for(i=4;i<6;i++)
{
if(rEINT0PEND&(1<<i))
{
if(rGPNDAT&(1<<i))
{
Uart_Trans('K');
Uart_Trans('e');
Uart_Trans('y');
Uart_Trans(':');
Uart_Trans(i+1+'0');
Uart_Trans(' ');
Uart_Printf("Key Released. ");
}
else
{
Uart_Trans('K');
Uart_Trans('e');
Uart_Trans('y');
Uart_Trans(':');
Uart_Trans(i+1+'0');
Uart_Trans(' ');
Uart_Printf("Key Pressed. ");
}
}
}
rEINT0PEND |= 0x3F;//向对应位写1来清除,在循环之外清除
rVIC0ADDRESS = 0;
}
void __irq TS_GETPOS(void)
{
u16 xCor,yCor;
Uart_Printf("Fuck");
if(rADCUPDN&(1<<0))
{
rADCTSC = 0x9C;
rADCCON |= 1;
while(rADCCON&(1<<0));
while(!(rADCCON&(1<<15)));
xPos = rADCDAT0&0x3FF;
yPos = rADCDAT1&0x3FF;
rADCCLRINT = 1;
rADCTSC = 0x1D3;
xCor = xPos/0x3FF*480;
yCor = yPos/0x3FF*272;
Uart_Printf("Coordinates are:");
Uart_Trans('x');
Uart_Trans(':');
Uart_Trans(Nand_Char_2_Hex(xCor/100));
Uart_Trans(Nand_Char_2_Hex((xCor/10)%10));
Uart_Trans(Nand_Char_2_Hex(xCor%10));
Uart_Trans(',');
Uart_Trans('y');
Uart_Trans(':');
Uart_Trans(Nand_Char_2_Hex(yCor/100));
Uart_Trans(Nand_Char_2_Hex((yCor/10)%10));
Uart_Trans(Nand_Char_2_Hex(yCor%10));
Uart_Printf("");
}
if(rADCUPDN&(1<<1))
{
rADCTSC = 0xD3;
}
Uart_Printf("Fuck!");
xPos = rADCDAT0&0x3FF;
yPos = rADCDAT1&0x3FF;
// rADCCLRINTPNDNUP = 1;
rADCCLRINT = 1;
rADCCLRINTPNDNUP = 3;
rVIC0ADDRESS = 0;
rVIC1ADDRESS = 0;
// rVIC1VECTADDR30 = (u32)TS_GETPOS;
}
程序运行起来点击屏幕时会死机,有时会重启,按下按键时会产生下降沿中断(设置的双边沿触发),然后死机(就是卡住)。请大家帮忙看看是怎么回事?使用中断还需要设置其他么?
页:
[1]