为什么我用AT89C51做的数字温度计proteus仿真图数码管不显示? 50
#include<reg52.h>#include<math.h>#defineucharunsignedcharsbitSTAR=P2^4;sbitEOC=P2^6;s...
#include<reg52.h>
#include<math.h>
#define uchar unsigned char
sbit STAR=P2^4;
sbit EOC=P2^6;
sbit CLOCK=P2^5;
sbit OE=P2^7;
sbit P20=P2^0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P23=P2^3;
uchar dispbuf[6];
uchar code
table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar code
table2[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xdf};
void TimeInitial()
{
TMOD=0x10;
TH1=(65536-200)/256;
TL1=(65536-200)%256;
EA=1;
ET1=1;
TR1=1;
}
void Delay(uchar i)
{
unsigned int j;
for(;i>0;i--)
{
for(j=0;j<125;j++)
{;}
}
}
void t1(void) interrupt 3 using 0
{
TH1=(65536-200)/256;
TL1=(65536-200)%256;
CLOCK=~CLOCK;
}
void Display()//
{
P0=table1[dispbuf[1]];
P20=0;
P21=1;
P22=1;
P23=1;
Delay(10);
P0=0x00;
P0=table2[dispbuf[2]];
P20=1;
P21=0;
P22=1;
P23=1;
Delay(10);
P0=0x00;
P0=table1[dispbuf[1]];
P20=1;
P21=1;
P22=0;
P23=1;
Delay(10);
P0=0x00;
P0=table1[dispbuf[0]];
P20=1;
P21=1;
P22=1;
P23=0;
Delay(10);
P0=0x00;
}
void main()//主函数
{
uchar getdata,temp;
uchar count=0;
uchar i=0;
TimeInitial();
while(1)
{
STAR=0;//关闭转换
OE=0;//关闭输出
STAR=1;//开启转换
STAR=0; //关闭转换
while(EOC==0)
{
OE=1;//开启数据输出允许
Delay(10);
getdata=P1;
OE=0;
temp=getdata*1.0/255*500;
dispbuf[0]=temp%10;
dispbuf[1]=temp/10%10;
dispbuf[2]=temp/100%10;
dispbuf[3]=temp/1000;
Dispay();
}
}
} 展开
#include<math.h>
#define uchar unsigned char
sbit STAR=P2^4;
sbit EOC=P2^6;
sbit CLOCK=P2^5;
sbit OE=P2^7;
sbit P20=P2^0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P23=P2^3;
uchar dispbuf[6];
uchar code
table1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar code
table2[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xdf};
void TimeInitial()
{
TMOD=0x10;
TH1=(65536-200)/256;
TL1=(65536-200)%256;
EA=1;
ET1=1;
TR1=1;
}
void Delay(uchar i)
{
unsigned int j;
for(;i>0;i--)
{
for(j=0;j<125;j++)
{;}
}
}
void t1(void) interrupt 3 using 0
{
TH1=(65536-200)/256;
TL1=(65536-200)%256;
CLOCK=~CLOCK;
}
void Display()//
{
P0=table1[dispbuf[1]];
P20=0;
P21=1;
P22=1;
P23=1;
Delay(10);
P0=0x00;
P0=table2[dispbuf[2]];
P20=1;
P21=0;
P22=1;
P23=1;
Delay(10);
P0=0x00;
P0=table1[dispbuf[1]];
P20=1;
P21=1;
P22=0;
P23=1;
Delay(10);
P0=0x00;
P0=table1[dispbuf[0]];
P20=1;
P21=1;
P22=1;
P23=0;
Delay(10);
P0=0x00;
}
void main()//主函数
{
uchar getdata,temp;
uchar count=0;
uchar i=0;
TimeInitial();
while(1)
{
STAR=0;//关闭转换
OE=0;//关闭输出
STAR=1;//开启转换
STAR=0; //关闭转换
while(EOC==0)
{
OE=1;//开启数据输出允许
Delay(10);
getdata=P1;
OE=0;
temp=getdata*1.0/255*500;
dispbuf[0]=temp%10;
dispbuf[1]=temp/10%10;
dispbuf[2]=temp/100%10;
dispbuf[3]=temp/1000;
Dispay();
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询