基于51单片机电子万年历课程设计论文内容摘要:

ad_byte() { RST=1。 for(i=8。 i0。 i) { ACC7=IO。 SCLK=1。 SCLK=0。 ACC=ACC1。 } return(ACC)。 } void write_1302(uchar add,uchar dat) { RST=0。 SCLK=0。 RST=1。 write_byte(add)。 write_byte(dat)。 SCLK=1。 RST=0。 } uchar read_1302(uchar add) { uchar temp。 RST=0。 SCLK=0。 RST=1。 write_byte(add)。 temp=read_byte()。 SCLK=1。 RST=0。 return(temp)。 } /*进制转换, BCD 转十进制 */ uchar BCD_Decimal(uchar bcd) { uchar Decimal。 Decimal=bcd4。 return(Decimal=Decimal*10+(bcdamp。 0x0F))。 } /* ds1302 初始化 */ void ds1302_init() { RST=0。 SCLK=0。 write_1302(0x8e,0x00)。 write_1302(0x8e,0x80)。 } /* 向液晶 写入年月日时分秒及星期 */ void write_sfm(uchar add,uchar dat) { uchar shi,ge。 ge=dat%10。 shi=dat/10。 write_(0x80+0x40+add)。 write_date(0x30+shi)。 write_date(0x30+ge)。 } void write_nyr(uchar add,uchar dat) { uchar shi,ge。 ge=dat%10。 shi=dat/10。 write_(0x80+add)。 write_date(0x30+shi)。 write_date(0x30+ge)。 } void write_week(uchar week) { write_(0x80+0x0c)。 switch(week) { case 1:write_date(39。 M39。 )。 write_date(39。 O39。 )。 write_date(39。 N39。 )。 break。 case 2:write_date(39。 T39。 )。 write_date(39。 U39。 )。 write_date(39。 E39。 )。 break。 case 3:write_date(39。 W39。 )。 write_date(39。 E39。 )。 write_date(39。 D39。 )。 break。 case 4:write_date(39。 T39。 )。 write_date(39。 H39。 )。 write_date(39。 U39。 )。 break。 case 5:write_date(39。 F39。 )。 write_date(39。 R39。 )。 write_date(39。 I39。 )。 break。 case 6:write_date(39。 S39。 )。 write_date(39。 A39。 )。 write_date(39。 T39。 )。 break。 case 7:write_date(39。 S39。 )。 write_date(39。 U39。 )。 write_date(39。 N39。 )。 break。 } } void keyscan() { uchar temp。 if(s1==0) { delay(5)。 if(s1==0) { while(!s1)。 flag++。 } if(flag==1) //分 { write_(0x80+0x40+4)。 write_(0x0f)。 temp=(fen)/10*16+(fen)%10。 write_1302(0x8e,0x00)。 write_1302(0x82,0x80|temp)。 write_1302(0x8e,0x80)。 } if(flag==2) //时 { write_(0x80+0x40+1)。 } if(flag==3) //星期 { write_(0x80+12)。 } if(flag==4) //日 { write_(0x80+9)。 } if(flag==5) //月 { write_(0x80+6)。 } if(flag==6) //年 { write_(0x80+3)。 } if(flag==7) { write_(0x80+0x40+10)。 } if(flag==8) { flag=0。 write_(0x0c)。 } } if(flag!=0) { if(s2==0) { delay(5)。 if(s2==0) { while(!s2)。 if(flag==1) { fen++。 if(fen==60) fen=0。 write_sfm(4,fen)。 temp=(fen)/10*16+(fen)%10。 write_1302(0x8e,0x00)。 write_1302(0x82,temp)。 write_1302(0x8e,0x80)。 write_(0x80+0x40+4)。 } if(flag==2) { shi++。 if(shi==24) shi=0。 write_sfm(1,shi)。 temp=(shi)/10*16+(shi)%10。 write_1302(0x8e,0x00)。 write_1302(0x84,temp)。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。