设置按键中断,在中断程序中设置了一个断点,在E8仿真时,按一次键后,进入中断服务程序,并运行到所设的断点处,再全速运行,这时程序又进入了中断服务程序,又到了该断点处(这次是没有按键).不知道是什么原因?难道是因为E8的单步运行和全速运行与中断向量表重叠吗?如果是,怎么改呢?在sect30.inc中只是更改了对应的13号的key interrupt和RAM的起始地址.
下面是4*4按键程序.请指教.
#include <sfr62p.h>
void ki_init (void);
#pragma INTERRUPT ki_ISR
void ki_ISR(void);
unsigned int F1Flag;
unsigned int F2Flag;
unsigned int F3Flag;
unsigned int F4Flag;
unsigned int F5Flag;
unsigned int F6Flag;
unsigned int F7Flag;
unsigned int F8Flag;
unsigned int F9Flag;
unsigned int F0Flag;
unsigned int FAFlag;
unsigned int FBFlag;
unsigned int FCFlag;
unsigned int FDFlag;
unsigned int FEFlag;
unsigned int FFFlag;
void main(void)
{
ki_init();
p1=0xff;
p2=0xff;
while (1)
{
if(F1Flag ==1){p1=0xff;F1Flag=0;}//控制LED显示
if(F2Flag ==1){p2=0xff;F2Flag=0;}
if(F3Flag ==1){p1=0x00;F3Flag=0;}
if(F4Flag ==1){p2=0x00;F4Flag=0;}
if(F5Flag ==1){p1=0xff;F5Flag=0;}
if(F6Flag ==1){p2=0xff;F6Flag=0;}
if(F7Flag ==1){p1=0x00;F7Flag=0;}
if(F8Flag ==1){p2=0x00;F8Flag=0;}
if(F9Flag ==1){p1=0xff;F9Flag=0;}
if(F0Flag ==1){p2=0xff;F0Flag=0;}
if(FAFlag ==1){p1=0x00;FAFlag=0;}
if(FBFlag ==1){p2=0x00;FBFlag=0;}
if(FCFlag ==1){p1=0xff;FCFlag=0;}
if(FDFlag ==1){p2=0xff;FDFlag=0;}
if(FEFlag ==1){p1=0x00;FEFlag=0;}
if(FFFlag ==1){p2=0x00;FFFlag=0;}
}
}
void ki_ISR(void)
{
unsigned int p;
unsigned char mask1=0,mask2=0,mask=0;
unsigned int timeout;
for (p=0;p<0x400;p++); //按键消除抖动
mask=0;
timeout=0;
while (mask==0x0) {
timeout++;
if (timeout>=1000) {
break;
}
mask1= ~p10 & 0xF0;
pd10=0xf0;
pur2=0x10;
mask2= ~p10 & 0x0F;
mask=mask1|mask2;
pd10=0x0f;
pur2=0x20;
}
switch (mask){
case 0x88:F1Flag=1;break;
case 0x84:F2Flag=1;break;
case 0x82:F3Flag=1;break;
case 0x81:F4Flag=1;break;
case 0x48:F5Flag=1;break;
case 0x44:F6Flag=1;break;
case 0x42:F7Flag=1;break;
case 0x41:F8Flag=1;break;
case 0x28:F9Flag=1;break;
case 0x24:F0Flag=1;break;
case 0x22:FAFlag=1;break;
case 0x21:FBFlag=1;break;
case 0x18:FCFlag=1;break;
case 0x14:FDFlag=1;break;
case 0x12:FEFlag=1;break;
case 0x11:FFFlag=1;
}
}
void ki_init (void)
{
pd10= 0x0F;
pur2=0x20;
asm(" FCLR I");
kupic = 7;
asm(" FSET I");
F1Flag=0;
F2Flag=0;
F3Flag=0;
F4Flag=0;
pd1=0xff;
pd2=0xff;
}