主题 : 2440test中断的为什么执行了两次 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 12229
精华: 0
发帖: 23
金钱: 115 两
威望: 23 点
综合积分: 46 分
注册时间: 2010-01-01
最后登录: 2015-01-09
楼主  发表于: 2011-02-26 21:42

 2440test中断的为什么执行了两次

如题,我将中断触发方式改成下降沿触发,为什么按下键后中断程序运行了两次,就是用Uart_Printf函数提示某某键按下了,放开也是一样,这是怎么回事?程序如下
在中断程序中加了延时也不行。
static void __irq Key_ISR(void)
{
    U8 key;
    U32 r;
    int i,j;

                 Delay(100); //加在这个地方
        
    EnterCritical(&r);
    
    if(rINTPND==BIT_EINT8_23) {
        ClearPending(BIT_EINT8_23);
        if(rEINTPEND&(1<<8)) {
        //Uart_Printf("eint11\n");
            rEINTPEND |= 1<< 8;
        }
        if(rEINTPEND&(1<<11)) {
        //Uart_Printf("eint11\n");
            rEINTPEND |= 1<< 11;
        }
        if(rEINTPEND&(1<<13)) {
        //Uart_Printf("eint11\n");
            rEINTPEND |= 1<< 13;
        }
        if(rEINTPEND&(1<<14)) {
        //Uart_Printf("eint11\n");
            rEINTPEND |= 1<< 14;
        }
        if(rEINTPEND&(1<<15)) {
        //Uart_Printf("eint11\n");
            rEINTPEND |= 1<< 15;
        }
        if(rEINTPEND&(1<<19)) {
        //    Uart_Printf("eint19\n");        
            rEINTPEND |= 1<< 19;
        }
    }

    key=Key_Scan();
    if( key == 0xff )
        Uart_Printf( "Interrupt occur... Key is released!\n") ;
    else
        Uart_Printf( "Interrupt occur... K%d is pressed!\n", key) ;
        
    ExitCritical(&r);    
    
}