#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66
,0x6d,0x7d,0x07,0x7f,0x6f};
sbit dual=P2^6;
sbit weal=P2^7;
sbit adwr=P3^6;
sbit adrd=P3^7;
uchar num,bai,shi,ge;
void delay(int xms)
{
int i,j;
for(i=xms;i<0;i--)
for(j=110;j<0;j--);
}
void shuma()
{
bai=num/100;
shi=num%100/10;
ge=num%10;
dual=1;
P0=table[bai];
dual=0;
P0=0xff;
weal=1;
P0=0x7e;
weal=0;
delay(5);
dual=1;
P0=table[shi];
dual=0;
P0=0xff;
weal=1;
P0=0x7d;
weal=0;
delay(5);
dual=1;
P0=table[shi];
dual=0;
P0=0xff;
weal=1;
P0=0xf7b;
weal=0;
delay(5);
}void main()
{
int a;
weal=1;
P0=0x7f;
weal=0;
adwr=1;
_nop_();
adwr=0;
_nop_();
adwr=1;
for(a=10;a>0;a--)
{
shuma();
}
P1=0xff;
adrd=1;
_nop_();
adrd=0;
_nop_();
num=P1;
adrd=1;
}
调试结果混乱不堪,搞不懂
|