|
#include"reg51.h"
#define uint unsigned int;
#define uchar unsigned char
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC= p3^2;
sbit CLK=P3^3;
sbit s1=P2^0;
sbit s2= P2^1;
unsigned char code dispcode[]=
{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char disp[2]=(0, 0);
unsigned char getdata;
unsigned int temp;
unsigned char out;
unsigned char wei;
void delay(int);
void display();
void main()
{
s1=1;
s2=1;
//wei=0;
TMOD=0x12;
THO=(256-250);
TL0O=(256-250);
TH1=(65536-6000)/256;
TL1=(65536-6000)%256;
ET0=1;
ET1=1;
EA= 1;
TR1=1;
TRO = 1;
delay(2);
while(1)
{
OE=0;
ST=0;
ST=1;
ST=0;
// delay(2);
while( EOC==0);
OE=1;
getdata=P0;
delay(1);
OE=0;
temp= getdata*2;
disp[0]= temp/100;
disp[1]=temp/10%10;
}
}
void display()
{
wei=0;
s1=0;
Pl=dispcode[ disp[ wei ]]|0x80;
delay(1);
s2=1;
wei=1;
s2=0;
Pl=dispcode[disp[wei]];
delay(1);
s2=1;
}
void tl(void) interrupt 3 using 0
{
display();
TH1=(65536-6000)/256;
TL1=(65536-6000)%256;
}
void t0( void) interrupt 1 using 0
{
CLK=~CLK;
}
void delay(int x)
{
int i,j;
for(i=0;i<x;i++)
for(j=0;j<120;j++);
}
|
|