ݷʱ : 2024/12/23 19:12:45һ µȫĶ
}
void init() { uchar num; lcden=0; write_com(0x38); write_com(0x0c); write_com(0x06); write_com(0x01); write_com(0x80); delay(5); write_com(0x80); for(num=0;num<15;num++) { write_date(table[num]); delay(5);
}
write_com(0x80+0x40); for(num=0;num<15;num++) { write_date(table1[num]);
delay(5);
}
}
void Write1302(uchar dat) {
5
uchar i;
SCLK=0; //SCLKΪд delay1(2); //ȴʹӲ for(i=0;i<8;i++) //д8λ {
DATA=dat&0x01; //ȡdatĵ0λд1302 delay(2); //ȴʹӲ SCLK=1; //д delay1(2); //ȴʹӲ SCLK=0; //SCLKγ
dat>>=1; //datĸλ1λдһλ } }
void WriteSet1302(uchar Cmd,uchar dat) {
RST=0; //ֹݴ
SCLK=0; //ȷдǰSCLK RST=1; //ݴ
delay1(2); //ȴʹӲ Write1302(Cmd); //д Write1302(dat); //д
SCLK=1; //ʱӵƽ֪״̬ RST=0; //ֹݴ }
uchar Read1302(void)
6
{
uchar i,dat;
delay(2); //ȴʹӲ for(i=0;i<8;i++) //8λ {
dat>>=1; //datĸλ1λΪȶֽڵλ if(DATA==1) //1 dat|=0x80; //1ȡдdatλ SCLK=1; //SCLKڸߵƽΪ½ض delay1(2); //ȴ
SCLK=0; //SCLKγ½ delay1(2); //ȴ }
return dat; //ݷ }
uchar ReadSet1302(uchar Cmd) {
uchar dat;
RST=0; //RST
SCLK=0; //ȷдǰSCLK RST=1; //ݴ Write1302(Cmd); //д dat=Read1302(); //
SCLK=1; //ʱӵƽ֪״̬ RST=0; //ֹݴ
7
return dat; //ݷ }
void Init_DS1302(void) {
WriteSet1302(0x8E,0x00); //д״̬Ĵ֣д벻ָ WriteSet1302(0x80,((0/10)<<4|(0))); //дĴ֣дijʼֵ WriteSet1302(0x82,((45/10)<<4|(45))); //дּĴ֣дֵijʼֵ WriteSet1302(0x84,((15/10)<<4|(15))); //дСʱĴ֣дСʱijʼֵ WriteSet1302(0x86,((29/10)<<4|(29))); //дռĴ֣дյijʼֵ WriteSet1302(0x88,((11/10)<<4|(11))); //д¼Ĵ֣дµijʼֵ WriteSet1302(0x8c,((10/10)<<4|(10))); //nian WriteSet1302(0x8a,((4/10)<<4|(4))); }
void DisplaySecond(uchar x) {
uchar i,j; i=x/10; j=x;
write_com(0xc7); write_date(0x30+i); write_date(0x30+j); }
void DisplayMinute(uchar x) {
uchar i,j; i=x/10;
8