Board logo

标题: kbi.c中按键中断的消抖是怎么实现的,对其中的消抖功能不能很理解?请指导下 [打印本页]

作者: adam1982    时间: 2007-7-26 17:23     标题: kbi.c中按键中断的消抖是怎么实现的,对其中的消抖功能不能很理解?请指导下

(GT60,MC13192,RXDEMO)kbi.c中按键中断的消抖是怎么实现的,对其中的消抖功能不能很理解?请指导下谢谢:

interrupt void KBIisr (void) {

UINT8 u8keys;


u8keys = ~PTAD;

/* Still in debounce time - just return */
if (gu16timerEvent[1] != 0) {
KBI1SC_KBACK = 1;
return;
}


if ((u8keys & KBI_SW1) == KBI_SW1) {
gu16timerEvent[1] = gu16msTimer + KBI_DEBOUNCE;
gu16Events |= KBI2_EVENT;
}

if ((u8keys & KBI_SW2) == KBI_SW2) {
gu16timerEvent[1] = gu16msTimer + KBI_DEBOUNCE;
gu16Events |= KBI3_EVENT;
}

if ((u8keys & KBI_SW3) == KBI_SW3) {
gu16timerEvent[1] = gu16msTimer + KBI_DEBOUNCE;
gu16Events |= KBI4_EVENT;
}

if ((u8keys & KBI_SW4) == KBI_SW4) {
gu16timerEvent[1] = gu16msTimer + KBI_DEBOUNCE;
gu16Events |= KBI5_EVENT;
}

KBI1SC_KBACK = 1;

}
interrupt void IRQTimer1(void) {

gu16msTimer++;
if (gu16timerEvent[0] != 0) {
if(gu16timerEvent[0] == gu16msTimer) {
gu16Events |= TIMER_EVENT0;
gu16timerEvent[0] = 0; /* Turn off the timer0 */
}
}

if (gu16timerEvent[1] != 0) {
if(gu16timerEvent[1] == gu16msTimer) {
gu16Events |= TIMER_EVENT1;
gu16timerEvent[1] = 0; /* Turn off the timer1 */

}
}

TPM1SC &= ~0x80; /* clear the interrupt */
}





欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0