请老哥们帮忙看一下训练十,我下面这个代码哪出问题了,编译是没问题的,但是烧录之后按键触发外部中断触发不出来要求的结果,还是保持2019显示。
#include<reg52.h>
#include<intrins.h>
#define ui unsigned int
#define uc unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
sbit key=P3^5;
sbit stop=P3^2;
ui b;
ui i;
ui a;
uc c;
uc code table[]={0x5b,0x3f,0x06,0x6f};
uc code table1[]={0x3e,0xfd,0xfb,0xf7};
uc code table2[]={0xfd,0xfb,0xf7,0xef};
uc code table3[]={0xfb,0xf7,0xef,0xdf};
uc code table4[]={0xf7,0xef,0xdf,0x3e};
uc code table5[]={0xef,0xdf,0x3e,0xfd};
uc code table6[]={0xdf,0x3e,0xfd,0xfb};
void delay(ui xms)
{
ui x,y;
for(x=xms;x>0;x--)
for(y=110;y>0;y--);
}
void display(){
for(a=650;a>0;a--)
{
for(i=0;i<4;i++){
dula=1;
P0=table;
dula=0;
P0=0xff;
wela=1;
P0=table1;
wela=0;
delay(1);
}
}
for(a=650;a>0;a--)
{
for(i=0;i<4;i++){
dula=1;
P0=table;
dula=0;
P0=0xff;
wela=1;
P0=table2;
wela=0;
delay(1);
}
}
for(a=650;a>0;a--)
{
for(i=0;i<4;i++){
dula=1;
P0=table;
dula=0;
P0=0xff;
wela=1;
P0=table3;
wela=0;
delay(1);
}
}
for(a=650;a>0;a--)
{
for(i=0;i<4;i++){
dula=1;
P0=table;
dula=0;
P0=0xff;
wela=1;
P0=table4;
wela=0;
delay(1);
}
}
for(a=650;a>0;a--)
{
for(i=0;i<4;i++){
dula=1;
P0=table;
dula=0;
P0=0xff;
wela=1;
P0=table5;
wela=0;
delay(1);
}
}
for(a=650;a>0;a--)
{
for(i=0;i<4;i++){
dula=1;
P0=table;
dula=0;
P0=0xff;
wela=1;
P0=table6;
wela=0;
delay(1);
}
}
}
void init()
{
EA=1;
EX0=1;
IT0=1;
stop=1;
b=0;
c=0xfe;
}
void keyscan(){
if(key==0)
{
delay(10);
if(key==0){
stop=0;
while(!key);
}
}
}
void shan()
{
P1=c;
delay(60);
P1=0xff;
delay(60);
P1=c;
}
void zd() interrupt 0
{
shan();
b++;
c=_crol_(c,1);
switch (b){
case 1:
dula=0;
P0=0x06;
dula=1;
wela=0;
P0=0xc0;
wela=1;
break;
case 2:
dula=0;
P0=0x5b;
dula=1;
wela=0;
P0=0xc0;
wela=1;
break;
case 3:
dula=0;
P0=0x4f;
dula=1;
wela=0;
P0=0xc0;
wela=1;
break;
case 4:
dula=0;
P0=0x66;
dula=1;
wela=0;
P0=0xc0;
wela=1;
break;
case 5:
dula=0;
P0=0x6d;
dula=1;
wela=0;
P0=0xc0;
wela=1;
break;
case 6:
dula=0;
P0=0x7d;
dula=1;
wela=0;
P0=0xc0;
wela=1;
break;
case 7:
dula=0;
P0=0x5b;
dula=1;
wela=0;
P0=0x3e;
wela=1;
dula=0;
P0=0x06;
dula=1;
wela=0;
P0=0x3d;
wela=1;
dula=0;
P0=0x07;
dula=1;
wela=0;
P0=0x3b;
wela=1;
dula=0;
P0=0x06;
dula=1;
wela=0;
P0=0x37;
wela=1;
dula=0;
P0=0x06;
dula=1;
wela=0;
P0=0x2f;
wela=1;
dula=0;
P0=0x7f;
dula=1;
wela=0;
P0=0xdf;
wela=1;
break;
}
stop=1;
}
void main(){
init();
while(1){
display();
keyscan();
}
}
|