给位大神,小弟大一学生刚接触51单片机三天,在学用LED前三个灯亮做读秒器时发现后三个灯有微弱的无规则变化的数字在亮,不知道为什么,请求解答,C语言如下,谢谢各位
#include<reg52.h>
#define x 1
sbit Dula=P2^6;
sbit Wela=P2^7;
unsigned char num;
void main()
{
void delayms(unsigned char t);
unsigned char code table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned char i,a,b,c;
i=0;
num=0;
EA=1;
ET0=1;
TMOD=0x01;
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
TR0=1;
while(1)
{
a=i/100;
b=(i%100)/10;
c=i%10;
Wela=1;
Dula=0;
P0=0xfe;;
Wela=0;
Dula=1;
P0=table1[a];
delayms(x);
Wela=1;
Dula=0;
P0=0xfd;
Wela=0;
Dula=1;
P0=table1[b];
delayms(x);
Wela=1;
Dula=0;
P0=0xfb;
Wela=0;
Dula=1;
P0=table1[c];
delayms(x);
if(num==20)
{
i++;
num=0;
}
}
}
void exter0() interrupt 1
{
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
num++;
}
void delayms(unsigned char t)
{
unsigned char i,j;
for(i=t;i>0;i--)
for(j=110;j>0;j--);
}
------解决思路----------------------
接触51单片机三天,就要做电路了,不得不佩服