您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 制造加工工艺 > AT89C52单片机12864液晶显示程序
#includereg52.h#includeabsacc.h#includeintrins.h#defineucharunsignedchar#defineuintunsignedintucharvalue,shi=23,fen=59,miao=50,SI;ucharcodetable[16]=时分秒;ucharcodetable1[16]=0123456789;voidtime_display(ucharadd,uchardat);sbitrs=P2^4;sbitrw=P2^5;sbite=P2^6;//sbitrst=P2^3;sbits1=P1^0;sbits2=P1^1;sbits3=P1^2;voiddelayu(uintt){while(--t);}voiddelaym(uintt){while(--t){delayu(245);delayu(245);}}voidwrite_com(ucharcom){rs=0;rw=0;e=1;delayu(1);P0=com;delayu(10);e=0;}voidwrite_data(uchardate){rs=1;rw=0;e=1;delayu(1);P0=date;delayu(10);e=0;delayu(2);}voidscy(){if(s1==0){delaym(10);if(s1==0){SI++;while(!s1);ET0=0;}if(SI==1){write_com(0x84);write_com(0x0f);while(s1&s2&s3);}if(SI==2){write_com(0x82);while(s1&s2&s3);}if(SI==3){write_com(0x80);delayu(20);while(s1&s2&s3);}if(SI==4){SI=0;write_com(0x0c);ET0=1;}}if(!SI==0){if(s3==0){delaym(10);if(s3==0){delaym(100);if(SI==1){miao--;if(miao==0){miao=60;time_display(4,miao);write_com(0x84);}}if(SI==2){fen--;if(fen==0){fen=60;time_display(2,fen);write_com(0x82);}}if(SI==3){shi--;if(shi==0){shi=24;time_display(0,shi);//将时间立即改变write_com(0x80);}}}}if(s2==0){delaym(10);if(s2==0){delaym(100);if(SI==1){miao++;if(miao==60){miao=0;time_display(4,miao);write_com(0x84);}}if(SI==2){fen++;if(fen==60){fen=0;time_display(2,miao);write_com(0x82);}}if(SI==3){shi++;if(shi==24){shi=0;time_display(0,miao);write_com(0x80);}}}}}}voidinit(){write_com(0x30);delayu(10);write_com(0x30);delayu(10);write_com(0x0e);delayu(10);write_com(0x01);delayu(1);write_com(0x06);delayu(10);//write_com(0x1a);TMOD=0X01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;TR0=1;EA=1;ET0=1;}voidtime_display(ucharadd,uchardat){ucharge,sh;ge=dat%10;sh=dat/10;write_com(0x80+add);write_data(0x30+sh);write_data(0x30+ge);write_com(0x80+add);}voidtime_deal(){if(value==20){value=0;miao++;if(miao==60){miao=0;fen++;if(fen==60){fen=0;shi++;if(shi==24){shi=0;}}}}if(s1==1){time_display(4,miao);time_display(2,fen);time_display(0,shi);}}voidmain(){uchari;init();write_com(0x80);delayu(100);for(i=0;i12;i++){write_data(table[i]);}while(1){time_deal();scy();}}voidtime0()interrupt1{TH0=(65536-49900)/256;TL0=(65536-50000)%256;value++;}
本文标题:AT89C52单片机12864液晶显示程序
链接地址:https://www.777doc.com/doc-4931219 .html