这是我的protues仿真图 最大值还不到3v 大家帮我看看程序到底错那了???
#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit ST=P1^0;
sbit EOC=P1^1;
sbit OE=P1^5;
//控制输入
sbit da=P1^2;
sbit db=P1^3;
sbit dc=P1^4;
uchar code dispcode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//共阳数码管段码
void delay()
{
unsigned char a,b;
for(b=1;b>0;b--)
for(a=47;a>0;a--);
}
void start()
{
uchar t=0;
da=t&0x01;
db=t&0x02;
dc=t&0x04;
ST=0;
ST=1;
ST=0;
}
uchar read()
{
uint date=0;
while(EOC==0);
OE=1;
date=P2;
OE=0;
date=(date*500)/256;
return date;
}
void display(a)
{
uchar i;
uchar a1=0,a2=0,a3=0;
a1=a/100;
a2=(a%100)/10;
a3=a%10;
P3=0x10;
P0= dispcode[a1];
delay();
P3=0x20 ;
P0= dispcode[a2];
delay();
P3=0x40 ;
P0= dispcode[a3];
delay();
}
void main()
{ uchar a;
while(1)
{
start();
a= read();
display(a);
}
} |