仿真只显示13v
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={ 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
uchar Tcount;
uint wei3,wei2,wei1,wei0,num;
bit timerflag,ADflag;
sbit AD_end =P3^2;
sbit OE=P2^5;
sbit ST=P2^6;
void AD_INT() interrupt 0
{ADflag=1;
AD_end=1;
}
void T0_int()interrupt 1
{TL0|=0xb0;
TH0=0x3c;
if(--Tcount==0)
{Tcount=20;
timerflag=1;}
}
void delay(uint z)
{uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void main()
{
Tcount=20;
TMOD=0x01;
TL0=0xb0;
TH0=0x3c;
IT0=1;
TR0=1;
ET0=1;
EX0=1;
EA=1;
while(1)
{ P2=P2&0xf0|0x07;
P0=table[wei0];
delay(1);
P2=P2&0xf0|0x0b;
P0=table[wei1];
delay(1);
P2=P2&0xf0|0x0d;
P0=table[wei2]|0x80;
delay(1);
P2=P2&0xf0|0x0e;
P0=table[wei3];
delay(1);
if(timerflag==1)
{timerflag=0;
ADflag=0;
ST=1;
ST=0;
while(!ADflag);
{OE=1;
num=P1*20-2500;
wei3=num/1000;
wei2=num%1000/100;
wei1=num%100/10;
wei0=num%10;
OE=0;
ADflag=0;}
}
}
}
|