ds1302液晶顯示
#include
#define uchar unsigned char
#define uint unsigned int
sbit rs=P3^3;
sbit rw=P3^4;
sbit en=P3^5;
sbit bflag=P2^7;
sbit reset=P3^0;
sbit sclk=P3^1;
sbit io=P3^2;
uchar str1[]="date of today is:";
uchar init[]={0x00,0x00,0x21,0x21,0x10,0x01,0x04};//秒,分,時(shí),日,月,星期,年
//
void delay()
{
uchar j;
for(j=250;j>0;j--);
}
//-------------------液晶模塊-----------------//
void en_toggle()
{
en=0;
//_nop_();
delay();
en=1;
delay();
// _nop_();
en=0;
} //注意必須加延時(shí),否則會(huì)出問(wèn)題的
void is_ready()
{
P2=0x00;//設(shè)置為輸入口
rs=0;
rw=1;
en=1;
while(bflag);
en=0;
}
void write_cmd(uchar cmd)
{
is_ready();
rs=0;
rw=0;
P2=cmd;
en_toggle();
}
void write_data(uchar indata)
{
is_ready();
rs=1;
rw=0;
P2=indata;
en_toggle();
_nop_();
}
void write_str(uchar addr,uchar *p)
{
uchar i;
write_cmd(addr);
while(p[i]!=