资源描述:
《lcd带温度显示万年历》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、LCD带温度显示万年历LCD带温度显示万年历(2009-4-515:02:00)【收藏】【评论】【打印】【关闭】标签:1#include#include#defineucharunsignedchar#defineuintunsignedint#defineLCD_DataP2#defineBusy0x80//用于检测LCD状态字中的Busy标识sbitDQ=P1^3;sbitlcdrs=P3^5;//数据命令选择端(H/L)sbitlcdrw=P3^6;//读写选择端(H/L)sbitlcde=P
2、3^7;//使能信号sbitSCL2=P1^0;//SCL2定义为P1口的第3位脚,连接DS1302SCL和ADC0831SCL脚sbitSDA2=P1^1;//SDA2定义为P1口的第4位脚,连接DS1302SCL和ADC0831SDA脚sbitRST=P1^2;//DS1302片选脚sbitkey0=P0^0;//定义三个按键sbitkey1=P0^1;//加按键sbitkey2=P0^2;//减按键sbitH1=P0^3;sbitL=P0^4;bitpresence;ucharcodecdis2[]={".C"};ucharbuzy
3、c,funtion_flag=0,temp_num;charshi,fen,miao,nian,yue,ri,xin;ucharbeep;unsignedchardatatemp_data[2]={0x00,0x00};unsignedchardatadisplay[5]={0x00,0x00,0x00,0x00,0x00};unsignedcharcodeditab[16]={0x00,0x01,0x01,0x02,0x03,0x03,0x04,0x04,0x05,0x06,0x06,0x07,0x08,0x08,0x09,0x09};
4、unsignedcharcodemytab[8]={0x0C,0x12,0x12,0x0C,0x00,0x00,0x00,0x00};unsignedcharl_tmpdate[8]={0x00,59,12,19,2,8,2};//显示初值unsignedcharl_tmpdisplay[8]={0x40,0x40,0x40,0x40,0x40,0x40,0x40,0};//待显示的数codeunsignedcharwrite_rtc_address[7]={0x80,0x82,0x84,0x86,0x88,0x8c,0x8a};//13
5、02写入地址codeunsignedcharread_rtc_address[7]={0x81,0x83,0x85,0x87,0x89,0x8d,0x8b};//1302读出地址codeunsignedchartable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40,0x00};//共阴数码管0-9'-''熄灭‘表uchardate1[]="MON";uchardate2[]="TUE";uchardate3[]="WED";uchardate4[]="THU";uch
6、ardate5[]="FRI";uchardate6[]="SAT";uchardate7[]="SUN";#definedelayNOP();{_nop_();_nop_();_nop_();_nop_();};/*****************************************************************************************************字节写入子函数:将要写入的数字先右移一位,是最低位溢出,然后在scl2的一个上升沿数据被写入DS1302,注意数据的写入时从低
7、位到高位*****************************************************************************************************/voidWrite_Ds1302_Byte(unsignedchardate){ucharj,temp;temp=date;for(j=0;j<8;j++){temp=temp>>1;//将数据右移一位使最低位溢出SDA2=CY;//将待写入数据最低位写入数据缓冲SCL2=0;SCL2=1;//在scl的上升延写入数据}}/***
8、************************************************************************************************