void delay(int z)
{
int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void write_com(com)
{
lcdrd=0;
lcdwr=0;
lcde =0;
delay(5);
lcde =1;
delay(4);
P2=com;
delay(4);
lcde =0;
}
void write_data(date)
{
lcdrd=1;
lcdwr=0;
lcde =0;
delay(5);
lcde=1;
delay(4);
P2=date;
delay(4);
lcde=0;
}
void write_sfm(char add,char date)
{
char ge,shi;
shi=date/10;
ge=date%10;
write_com(0x80+0x40+add);
write_data(0x30+shi);
write_data(0x30+ge);
}
void init()
{
lcdrd=0;
lcdwr=0;
lcde =0;
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
write_ds(0x0A,0x20);
write_ds(0x0B,0x26);
for(num=0;num<16;num++)
{
write_data(table[num]);
delay(5);
}
write_com(0x80+0x40);
for(num=0;num<16;num++)
{
write_data(table1[num]);
delay(5);
}
write_com(0x80+0x40+0x0e);
write_data(0xdf);
}
void write_ds(uchar add,uchar date)
{
dsds=1;
dsrw=1;
dsas=1;
dscs=0;
P0=add;
dsas=0;
dsrw=0;
P0=date;
dsrw=1;
dsas=1;
dscs=1;
}
char read_ds(uchar add)
{
uchar ds_date;
dsas=1;
dsds=1;
dsrw=1;
dscs=0;
P0=add;
dsas=0;
dsds=0;
ds_date=P0;
dsds=1;
dsas=1;
dscs=1;
return ds_date;
}
void main()
{
init();
while(1)
{
miao=read_ds(0);
write_sfm(8,miao);
}
}
对照郭天祥老师的程序写的
但是秒钟显示9过了就是16,感觉write_ds(0x0B,0x26);这句完全没被执行,是不是没写进去啊?
|