ds12c887读不了秒的数据求高手解决
时间:10-02
整理:3721RD
点击:
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P3^5;
sbit rw=P3^6;
sbit en=P3^4;
sbit rd=P3^7;
sbit dscs=P1^4;
sbit dsas=P1^5;
sbit dsrw=P1^6;
sbit dsds=P1^7;
sbit dsirq=P3^3;
sbit wela=P2^6;
sbit dula=P2^7;
uchar miao;
uchar code nyr[]=" 2012-09-01";
uchar code sfm[]=" 00:00: ";
uchar code week[]=" saturday";
uchar code wendu[]="温度";
void delay(uchar ms)
{
uchar x,y;
for(x=ms;x>0;x--)
for(y=110;y>0;y--);
}
void lcd_wcmd(uchar cmd)
{
rs = 0;
rw = 0;
en = 0;
P0 = cmd;
delay(5);
en = 1;
delay(5);
en = 0;
}
void lcd_wdat(uchar dat)
{
rs = 1;
rw = 0;
en = 0;
P0 = dat;
delay(5);
en = 1;
delay(5);
en = 0;
}
void ds_write(uchar add,uchar write)
{
dscs=0;
dsas=1;
dsds=1;
dsrw=1;
P0=add;
dsas=0;
dsrw=0;
P0=write;
dsrw=1;
dsas=1;
dscs=1;
}
uchar read_ds(uchar add)
{
uchar ds_date;
dsas=1;
dsds=1;
dsrw=1;
dscs=0;
P0=add;
dsas=0;
dsds=0;
P0=0xff;
ds_date=P0;
dsds=1;
dsas=1;
dscs=1;
return ds_date;
}
void lcd_init()
{
rd = 1;
lcd_wcmd(0x34);
delay(5);
lcd_wcmd(0x30);
delay(5);
lcd_wcmd(0x0C);
delay(5);
lcd_wcmd(0x01);
}
void lcd_sfm(uchar add,uchar dat)
{
uchar shi,ge;
lcd_wcmd(0x90+add);
shi=dat/10;
ge=dat%10;
lcd_wdat(0x30+shi);
lcd_wdat(0x30+ge);
}
void main()
{
uchar i;
miao=0;
wela=0;
dula=0;
lcd_init();
lcd_wcmd(0x80);
i = 0;
while(nyr != '\0')
{
lcd_wdat(nyr);
i++;
}
lcd_wcmd(0x90);
i=0;
while(sfm != '\0')
{
lcd_wdat(sfm);
i++;
}
lcd_wcmd(0x88 );
i=0;
while(week != '\0')
{
lcd_wdat(week);
i++;
}
lcd_wcmd(0x98);
i=0;
while(wendu!='\0')
{
lcd_wdat(wendu);
i++;
}
while(1)
{
miao=read_ds(0);
lcd_sfm(5,miao);
}
}
液晶用12864,只读秒,数据显示I5,求高手看看程序有没有问题
用仿真器跑一下,看读出数据是否正常,判断是芯片问题还是显示问题
已解决了,是显示的问题
请教你是怎么解决的,我现在同样的问题出现