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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 基于STC單片機的PCF8563讀寫程序

          基于STC單片機的PCF8563讀寫程序

          作者: 時間:2016-11-22 來源:網(wǎng)絡(luò) 收藏

          #include
          #include
          #define PCF8563 0xA2
          #define SUBADDR 0x02

          本文引用地址:http://www.ex-cimer.com/article/201611/319702.htm


          extern bit ISendStr(unsigned char ,unsigned char ,unsigned char *,unsigned char );
          extern bit IRcvStr(unsigned char,unsigned char,unsigned char *,unsigned char);
          extern void initialize_UART(void);
          extern void s_send(unsigned char );


          void DelayNS(unsigned int dly)
          { unsigned int i;

          for(; dly>0; dly--)
          for(i=0; i<5000; i++)
          _nop_();
          }
          //main

          main()
          {
          unsigned char p[7]={0x30,0x59,0x15,0x20,0x02,0x06,0x00};
          //2000 年6 月20 日星期3 15 點 59 分30 秒<倒序>
          unsigned char q[7];
          unsigned i;
          bit bp;

          initialize_UART();

          //寫PCF8563各個時間寄存器

          for(i=0;i<7;i++)
          {
          bp=ISendStr(PCF8563,SUBADDR+i,p+i,1);
          }

          while(1)
          {
          //讀PCF8563各時鐘寄存器
          for(i=0;i<7;i++)
          { bp=IRcvStr(PCF8563,SUBADDR+i,q+i,1);
          }
          //屏蔽無效位
          q[0]&=0x7F;//second
          q[1]&=0x7F;//minute
          q[2]&=0x3F;//hour
          q[3]&=0x3F;//day
          q[4]&=0x07;//week
          q[5]&=0x1F;//month
          q[6]&=0xFF;//year
          //送顯示器顯示
          for(i=7;i>0;i--)
          { s_send(q[i-1]);
          }

          DelayNS(200);
          }

          }
          說明:使用這個程序,請包含我的上一篇文章中的文件,使用其提供的函數(shù)!

          該程序主要完成了對8563(IIC接口的實時時鐘)的寄存器讀寫。

          設(shè)置初值后開始計時,并讀回當前時間值,送回顯示器利用串口調(diào)試助手顯示結(jié)果!




          關(guān)鍵詞: STC單片機PCF8563讀寫程

          評論


          技術(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); })();