# include
# include
P1 sbit DQ=^ 3;
Unsigned char a [6]={0 x40, 0 x40, 0 x40, 0 x40, 0 x40, 0 x40};
Unsigned char [] b={0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,9};
Unsigned char code c [10]={x5b x3f 0, 0 x06, 0, 0, x4f x66 0, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f};
Void delay (unsigned char I)
{
While (I -);
}
Void reset1820 ()
{
DQ=1; _nop_ ();
DQ=0;
delay(100);
DQ=1;
Delay (12);
}
Unsigned char rd1820 ()
{
Unsigned char I, d=0;
for (i=0; i<8; I++)
{
DQ=0;
D>=1;
DQ=1; _nop_ ();
If (DQ) d |=0 x80;
Delay (12);
}
return d;
}
Void wr1820 (unsigned char d)
{
unsigned char i;
for(i=0; i<8; I++)
{
DQ=0; _nop_ ();
DQ=d & 0 x01;
Delay (12);
DQ=1;
D>=1;
}
}
Void chag (unsigned char [x], unsigned char [] y)
{
[5] y=0 x39;
Y [0]=0;
If ((x [1] & 0 xf8)==0 xf8)
{
[1]=x ~ x [1];
[0]=x ~ x [0] + 1;
If x (x [0]==0) [1] [1]=x + 1;
Y [0]=0 x40;
}
B y [4]=[x [0] & 0 x0f];
Y [4]=c [4] [y];
X [1]=(x [1] & 0 x0f) <4;
[0] x [0]=(x & 0 xf0)> 4.
[0] x [0]=x | x [1];
Y [1] [0]=x/100;
Y [2]=(x [0] % 100)/10;
Y [3] [10] x [0] %=c | 0 x80;
If ([1] y! Y=0) [1]=c [1] [y];
If ((y [1]. (y=0) | [2].=0))
Y [2]=c [2] [y];
}
Void disp (unsigned char n)
{
Unsigned char I, j;
for(j=0; J
for(i=0; I <6; I++)
{
P1=(P1 & 0 xf8) + I;
X7fff XBYTE [0]=a, [I].
Delay (300);
}
}
}
Void main ()
{
Unsigned char t [2];
While (1)
{
Reset1820 ();
If (DQ==0)
{
Delay (15000);
Wr1820 (0 XCC);
X44 wr1820 (0);
Reset1820 ();
Delay (15000);
Wr1820 (0 XCC);
The xbe wr1820 (0);
T [0]=rd1820 ();
T [1]=rd1820 ();
Delay (15000);
Chag (t, a);
}
Disp (100);
}
}