#include
#include
#define uchar unsigned char
#define uint unsigned int
sbit CLK=P1^3;
sbit ST=P1^2;
sbit EOC=P1^1;
sbit OE=P1^0;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay(uint z);
void display(uchar d);
void main()
{
TMOD=0x02;//方法2特别适合于用作较准确的脉冲信号发生器
TH0=0x14;
TL0=0x00;//8主动重装定时器
EA=1;
ET0=1;
TR0=1;
P1=0x3f;//挑选通道三,留意:通道挑选的不相同,显现的成果也将不相同
while(1)
{
ST=0;
ST=1;
ST=0;//start一个高脉冲发动AD0808;
while(!EOC);
OE=1;
display(P3);
OE=0;
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x–)
for(y=110;y>0;y–);
}
void display(uchar d)
{
P2=0xff;
P2=0xf7;
P0=table[d%10];
delay(5);
P2=0xff;
P2=0xfb;
P0=table[d%100/10];
delay(5);
P2=0xff;
P2=0xfd;
P0=table[d/100];
delay(5);
}
void timer0() interrupt 1
{
CLK=~CLK;
}