<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 12864液晶顯示實(shí)時(shí)時(shí)鐘

          12864液晶顯示實(shí)時(shí)時(shí)鐘

          作者: 時(shí)間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
          DS1302是美國(guó)DALLAS公司推出的一種高性能、低功耗的實(shí)時(shí)時(shí)鐘芯片,附加31字節(jié)靜態(tài)RAM,采用SPI三線接口與CPU進(jìn)行同步通信,并可采用突發(fā)方式一次傳送多個(gè)字節(jié)的時(shí)鐘信號(hào)和RAM數(shù)據(jù)。實(shí)時(shí)時(shí)鐘可提供秒、分、時(shí)、日、星期、月和年,一個(gè)月小與31天時(shí)可以自動(dòng)調(diào)整,且具有閏年補(bǔ)償功能。

          下面是一段鐘的程序:

          本文引用地址:http://www.ex-cimer.com/article/201611/323551.htm
          /***************************************************************************************時(shí)間:2012.11.30晶振:11.0592MHz芯片:STC89C52RC功能描述:在12864上顯示年、月、日、星期、時(shí)、分和秒等時(shí)間信息***************************************************************************************/ #include#define uchar unsigned charsbit CLK=P1^4;        //DS1302引腳定義sbit IO=P1^5;sbit CE=P1^6;sbit ACC0=ACC^0;sbit ACC7=ACC^7;sbit RS=P2^4;         //12864引腳定義        數(shù)據(jù)口為P0sbit RW=P2^5;sbit EN=P2^6;sbit PSB=P2^1;sbit RET=P2^3;void Input_1byte(uchar TD)	//DS1302輸入一字節(jié)數(shù)據(jù){uchar i;ACC=TD;for(i=8;i>0;i--){IO=ACC0;CLK=1;CLK=0;ACC=ACC>>1;}}uchar Output_1byte(void)       //DS1302輸出一字節(jié)數(shù)據(jù){uchar i;for(i=8;i>0;i--){ACC=ACC>>1;ACC7=IO;CLK=1;CLK=0;}return(ACC);}void Write_DS1302(uchar add,uchar dat)//向DS1302寫{CE=0;CLK=0;CE=1;Input_1byte(add);Input_1byte(dat);CE=0;}uchar Read_DS1302(uchar add)	//從DS1302讀{uchar inf;	  //信息臨時(shí)存儲(chǔ)變量CE=0;CLK=0;CE=1;Input_1byte(add);inf=Output_1byte();CE=0;return(inf);}/**********************DS1302初始化*****************************/void init_1302(){if(Read_DS1302(0xd1)==0x55)               //判斷內(nèi)存單元的內(nèi)容,是否進(jìn)行初始化{        return;  }     else {Write_DS1302(0x8e,0x00); //關(guān)閉寫保護(hù)Write_DS1302(0x90,0x00); //電池充電設(shè)置Write_DS1302(0x80,0x00); //秒Write_DS1302(0x82,0x54); //分Write_DS1302(0x84,0x20); //時(shí)Write_DS1302(0x86,0x30); //日Write_DS1302(0x88,0x11); //月Write_DS1302(0x8a,0x05); //星期Write_DS1302(0x8c,0x12); //年Write_DS1302(0xd0,0x55); //寫RAMWrite_DS1302(0x8e,0x80); //打開寫保護(hù)  }}/**********************延時(shí)函數(shù)*****************************/void DelayUs2x(unsigned char t){   while(--t);}void DelayMs(unsigned char t){while(t--){//大致延時(shí)1mSDelayUs2x(245);DelayUs2x(245);}}/**********************12864判忙*****************************/void check_busy(){RS=0;RW=1;EN=1;while((P0&0x80)==0x80);EN=0;}				   
          				
                      
                          
          			
          							
          上一頁 1 2 下一頁

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();