先附上程序
#include
#define uchar unsigned char
#define uint unsigned int
uchar AD_date,bai,shi,ge,a,b;
uint k;
***it dula=P2^6;
***it wela=P2^7;
***it OE=P3^0;
***it ST=P3^1;
***it EOC=P3^2;
***it CLK=P3^3;
***it ALE=P3^6;
***it channelA=P2^5;
***it channelB=P2^4;
***it channelC=P2^3;
uchar code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint z)//延时大概z毫秒
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(uchar bai,uchar shi,uchar ge,uchar a,uchar b)
{
dula=1;
P0=table[bai];
dula=0;
P0=0xff;
wela=1;
P0=0xfe;
wela=0;
delay(1);
dula=1;
P0=table[shi];
dula=0;
P0=0xff;
wela=1;
P0=0xfd;
wela=0;
delay(1);
dula=1;
P0=table[ge];
dula=0;
P0=0xff;
wela=1;
P0=0xfb;
wela=0;
delay(1);
dula=1;
P0=table[a];
dula=0;
P0=0xff;
wela=1;
P0=0xf7;
wela=0;
delay(1);
dula=1;
P0=table[b];
dula=0;
P0=0xff;
wela=1;
P0=0xef;
wela=0;
delay(1);
}
void AD()
{
ALE=0;
ST=0;
delay(100);
ALE=1;
channelA=0;
channelB=0;
channelC=1;
ALE=0;
ST=1;
ST=0;
while(!EOC)
a=EOC;
b=EOC;
OE=1;
AD_date=P1;
OE=0;
}
void main()
{
TMOD=0x02;//方式2特别适合于用作较精确的脉冲信号发生器
TH0=0xf0;
TL0=0xf0;//8自动重装定时器
EA=1;
ET0=1;
TR0=1;
AD();
k=AD_date;
bai=k/100;
shi=k%100/10;
ge=k%10;
while(1)
{
display(bai,shi,ge,a,b);
}
}
void t0(void) interrupt 1
{
CLK=~CLK;
}
为什么运行之后即使存在电压(用万用表测得在光照条件下会有1.几V的电压)数码管显示一直是0????
那个,ab是我用来看AD0809那个EOC引脚到底变化了没有用的
求求大神们帮忙看下
感激不尽
1
|
|
|
|