一个简单的秒表程序不知道哪里错了,数码管不能正确显示
求大神改错啊
#include<reg51.h>
code unsigned char a[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40}; //字模0,1,2,3。。。
code unsigned char dispbit[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbF,0x7F};
static unsigned char counter;
void timer1()
{
TMOD = 0x10;
TH1 = 0xB1;
TL1 = 0xE0;
TR1 = 1;
}
void refresh_led()
{
unsigned char i,b[8];
b[0]=counter%10;
b[1]=counter%100/10;
b[2]=counter%1000/100;
b[3]=counter%10000/1000;
b[4]=counter%100000/10000;
b[5]=counter%1000000/100000;
b[6]=counter%10000000/1000000;
b[7]=counter%100000000/10000000;
for(i=0;i<=8;i++)
{
P1=dispbit[i];
P0=a[b[i]];
}
}
main()
{
unsigned char m;
timer1();
while(1)
{
if(TF1==1)
{
TH1 = 0xB1;
TL1 = 0xE0;
TF1 = 0;
m++;
}
if(m==50)
{
counter++;
m=0;
}
refresh_led();
}
}
|