|
我有一个中断按键,初始化的时候我把它设成上升沿触发,在中断服务程序中按键按下后设成下降沿触发,
可是系统运行的时候不能触发中断,可是如果有下列情况之一的时候就好用了,
当我用万用表量一次以后,或者是我按过其他下降沿触发的按键之后,该按键按下和抬起的中断就都管用了,
请高手帮我分析下,先谢了。
初始化代码:
//PTT button
v_pIOPregs->rGPGCON &= ~(0x3 << 16); /* Set GPG8 as EINT16 */
v_pIOPregs->rGPGCON |= (0x2 << 16);
v_pIOPregs->rEXTINT2 &= ~(0x7 << 0);
v_pIOPregs->rEXTINT2 |= (0x4 << 0); /* Configure EINT16 as Raising Edge Mode*/
在中断线程的代码:
if(dwReturnVal == WAIT_OBJECT_0)
{
delay_ms(100);
GPG7val = v_pIOPregs->rGPGDAT & 0x80;
GPG4val = v_pIOPregs->rGPGDAT & 0x10;
GPG8val = v_pIOPregs->rGPGDAT & 0x100;
GPG10val = v_pIOPregs->rGPGDAT & 0x400;
GPG11val = v_pIOPregs->rGPGDAT & 0x800;
if(GPG8val && !g_PTTFlag && !GPG10val) //去抖动PTT键没有按下
{
SendNotifyMessage(HWND_BROADCAST, WM_PTTKEYDOWN_MSG, 0, 0);
RETAILMSG(1,(TEXT("PTT KEYDOWN SendNotifyMessage has Send Out!!!\r\n")));
v_pIOPregs->rEXTINT2 &= ~(0x7 << 0);
v_pIOPregs->rEXTINT2 |= (0x2 << 0); /* Configure EINT16 as Falling Edge Mode */
g_PTTFlag = 1;
}
if(!GPG8val && g_PTTFlag) //去抖动
{
SendNotifyMessage(HWND_BROADCAST, WM_PTTKEYUP_MSG, 0, 0);
RETAILMSG(1,(TEXT("PTT KEYUP SendNotifyMessage has Send Out!!!\r\n")));
v_pIOPregs->rEXTINT2 &= ~(0x7 << 0);
v_pIOPregs->rEXTINT2 |= (0x4 << 0); /* Configure EINT16 as Raising Edge Mode */
g_PTTFlag = 0;
}
折腾了一天,也不知道是怎么回事,期待您的回贴。
|
|