在线时间2 小时
UID52696
注册时间2008-6-7
NXP金币0
该用户从未签到
高级会员

- 积分
- 799
- 最后登录
- 1970-1-1
|
北京龙丘智能科技--应求--MCF52JM128完整键盘中断工程,KBI演示程序:
#include /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
/*********************变量和函数定义****************************/
/***********************I/O初始化********************************/
void IO_INIT(void)
{
PTGDD &= 0xF0; /*set PTG0-3 to input*/
PTGPE |= 0x0F; /*enable PTG0-3 pull-up resistor*/
PTFDD =0XFF; // LED
}
/************************KB初始化********************************/
void KB_INIT(void)
{
KBI1PE =0XC3; /* Enable KBI10,1,6,7*/
KBI1SC_KBIE = 1; /* Enable Keyboard Interrupts */
//KBI1SC_KBMOD = 1;
KBI1PE =0XC3; /* Enable Pullup for Keyboard pin */
KBI1SC_KBACK = 1; /* Clear Pending Keyboard Interrupts */
}
/********************************键盘中断**************************/
interrupt 87 void KBI1_ISR(void)
{
//KBI1SC_KBACK = 1; //清除键盘中断标志
//delayms(1);
if(PTGD_PTGD0==0){ //查询是由哪一个口引起的中断
PTFD_PTFD0 = ~PTFD_PTFD0;
}
else if(PTGD_PTGD1==0){
PTFD_PTFD1 = ~PTFD_PTFD1;
}
else if(PTGD_PTGD2==0){
PTFD_PTFD2 = ~PTFD_PTFD2;
}
else if(PTGD_PTGD3==0){
PTFD_PTFD3 = ~PTFD_PTFD3;
}
KBI1SC_KBACK = 1; //清除键盘中断标志
}
/***************************************************
延时1毫秒函数
****************************************************/
void delayms(int ms)
{
int ii,jj;
if (ms
|
|