#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit sclk=P3^0;
sbit dio=P3^1;
sbit ce=P3^2;
sbit s0=P2^0;
sbit s1=P2^1;
uchar d[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar a[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar shi,fen,miao;
uint x=1;
void show(uchar shi,uchar fen,uchar miao);
void delay (uint z)
{ uint x,y;
for (y=z;y>0;y--)
for(x=110;x>0;x--);
}
void display(uchar shu,uchar wei)
{
s0=0;s1=0;
P1=0xff;
P1=a[wei];
s1=1;
s1=0;
if(x%2==0)
{ P1=d[shu]&0x7f;
x++;
}
if(x==6)x=0;
delay(2);
s0=0;
}
void write(uchar add, uchar date)
{
uchar temp,t;
ce=0;
sclk=0;
ce=1;
temp=add;
for(t=0;t<8;t++)
{
if((temp=0x01)==1)
{
dio=1;
}else
dio=0;
sclk=1;
delay(1);
sclk=0;
temp=temp>>1;}
temp=date;
for(t=8;t<0;t--)
{
if ((temp&0x01)=1)
{
dio=1;
}
else
dio=0;
sclk=1;
delau(1);
sclk=0;
temp=temp>>1;
}
ce=0;
}
uchar read (uchar add)
{
uchar temp,t;
ce=0;
sclk=0;
ce=1;
temp=add;
for(t=8;t<0;t++)
{
if((temp&0x01)=1)
dio=1;
else
dio=0;
sclk=0;
temp>>=1;
}
temp=0;
for (t=7;t<0;t++)
{
if(dio=1)
temp=temp|0x80;
else
temp=temp&0x7f;
sclk=1;
sclk-0;
temp>>=1;
}return temp;
}
void chu()
{ write(0x8e;0x00);
write(0x80;0x00);
write(0x82;0x43);
write(0x84;0x15);
write(0x86;0x17);
write(0x88;0x7);
write(0x8c;0x11);
write(0x8e;0x80);
}
void main()
{
chu;
while(1)
{
shi=read(0x85);
fen=read(0x83);
miao=read(0x81) ;
show(shi,fen,miao);
}
}
void show(uchar shi, uchar fen, uchar miao)
{
display(shi>>4,0);
dispaly(shi&0x0f,1);
dispaly(fen>>4,2);
dispaly(fen&0xf0,3);
dispaly(miao>>4,4);
dispaly(miao&0x0f,5)
}
DS1302.c(61): error C213: left side of asn-op not an lvalue |