⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcf8563的c51程序设计※51单片机c程序※单片机吧台 __   http--www_mcu8_cn       .htm

📁 fft的工业级的EP9315的开发板的所有驱动程序
💻 HTM
📖 第 1 页 / 共 4 页
字号:
                      <TD></TD></TR>
                    <TR>
                      <TD vAlign=center height=54>
                        <DIV align=center><FONT color=#993300>发表时间:2005-08-19 
                        23:20:30 浏览人数:94 发布者:administrator</FONT></DIV></TD></TR>
                    <TR>
                      <TD><SPAN id=post1>
                        <DIV align=center>作者:网络 &nbsp; 
                        文章出处:网络</DIV><BR><BR>&nbsp; &nbsp; 
                        PCF8563是一款低功耗的CMOS实时时钟/日历芯片,它提供一个可编程时钟输出,一个中断输出和掉电检测器,所有的地址和数据通过I2C总线接口串行传递。最大总线速度为400Kbits/s,每次读写数据后,内嵌的字地址寄存器会自动增加。<BR><BR><B>特性</B><BR>&nbsp; 
                        &nbsp; 低工作电流:典型值为0.25μA(VDD=3.0V,Tamb=25 ℃时);<BR>&nbsp; 
                        &nbsp; 世纪标志;<BR>&nbsp; &nbsp; 
                        大工作电压范围:1.0~5.5V;<BR>&nbsp; &nbsp; 低休眠电流;典型值为0.25μA 
                        (VDD=3.0V, Tamb=25 ℃);<BR>&nbsp; &nbsp; 400KHz 
                        的I2C总线接口(VDD=1.8~5.5V 时);<BR>&nbsp; &nbsp; 
                        可编程时钟输出频率为:32.768KHz,1024Hz,32Hz,1Hz;<BR>&nbsp; &nbsp; 
                        报警和定时器;<BR>&nbsp; &nbsp; 掉电检测器;<BR>&nbsp; &nbsp; 
                        内部集成的振荡器电容;<BR>&nbsp; &nbsp; 片内电源复位功能;<BR>&nbsp; &nbsp; 
                        I2C 总线从地址:读:0A3H;写:0A2H;<BR>&nbsp; &nbsp; 
                        开漏中断引脚。<BR><BR><B>应用</B><BR>&nbsp; &nbsp; 
                        移动电话;<BR>&nbsp; &nbsp; 便携仪器;<BR>&nbsp; &nbsp; 
                        传真机;<BR>&nbsp; &nbsp; 电池供电产品。 
                        <BR><BR>/**————————————————————<BR>〖说明〗I2C总线驱动程序(用两个普通IO模拟I2C总线)<BR>包括100Khz(T=10us)的标准模式(慢速模式)选择,<BR>和400Khz(T=2.5us)的快速模式选择,<BR>默认11.0592Mhz的晶振。<BR><BR>—————————————————————*/<BR>#ifndef 
                        SDA<BR>#define SDA P0_0<BR>#define SCL 
                        P0_1<BR>#endif<BR><BR>extern uchar 
                        SystemError;<BR>#define uchar unsigned char<BR>#define 
                        uint unsigned int<BR>#define Byte unsigned 
                        char<BR>#define Word unsigned int<BR>#define bool 
                        bit<BR>#define true 1<BR>#define false 0<BR><BR>#define 
                        SomeNOP(); 
                        _nop_();_nop_();_nop_();_nop_();<BR>/**------------------------------------------------------------------<BR>调用方式:void 
                        I2CStart(void) 
                        函数说明:私有函数,I2C专用<BR>---------------------------------------------------------------------*/<BR>void 
                        I2CStart(void)<BR>{<BR>EA=0;<BR>SDA=1; SCL=1; 
                        SomeNOP();//INI<BR>SDA=0; SomeNOP(); 
                        //START<BR>SCL=0;<BR>}<BR><BR>/*--------------------------------------------------------------------------------<BR>调用方式:void 
                        I2CStop(void) ﹫2001/07/0 
                        4<BR>函数说明:私有函数,I2C专用<BR>---------------------------------------------------------------------------------*/<BR>void 
                        I2CStop(void)<BR>{<BR>SCL=0; SDA=0; SomeNOP(); 
                        //INI<BR>SCL=1; SomeNOP(); SDA=1; 
                        //STOP<BR>EA=1;<BR>}<BR><BR>/*--------------------------------------------------------------------------------<BR>调用方式:bit 
                        I2CAck(void) ﹫2001/07/0 
                        4<BR>函数说明:私有函数,I2C专用,等待从器件接收方的应答<BR>---------------------------------------------------------------------------------*/<BR>bool 
                        WaitAck(void)<BR>{<BR>uchar 
                        errtime=255;//因故障接收方无ACK,超时值为255。<BR>SDA=1;SomeNOP();<BR>SCL=1;SomeNOP();<BR>while(SDA) 
                        <BR>{ errtime--; <BR>&nbsp; if (!errtime) <BR>&nbsp; { 
                        I2CStop();<BR>&nbsp; SystemError=0x11;<BR>&nbsp; return 
                        false;<BR>&nbsp; }<BR>}<BR>SCL=0;<BR>return 
                        true;<BR>}<BR>/**--------------------------------------------------------------------------------<BR>调用方式:void 
                        SendAck(void) ﹫2001/07/0 
                        4<BR>函数说明:私有函数,I2C专用,主器件为接收方,从器件为发送方时,应答信号。<BR>---------------------------------------------------------------------------------*/<BR>void 
                        SendAck(void)<BR>{<BR>SDA=0; SomeNOP();<BR>SCL=1; 
                        SomeNOP();<BR>SCL=0;<BR>}<BR><BR>/*--------------------------------------------------------------------------------<BR>调用方式:void 
                        SendAck(void) ﹫2001/07/0 
                        4<BR>函数说明:私有函数,I2C专用,主器件为接收方,从器件为发送方时,非应答信号。<BR>--------------------------------------------------------------------------------*/<BR>void 
                        SendNotAck(void)<BR>{<BR>SDA=1; SomeNOP();<BR>SCL=1; 
                        SomeNOP();<BR>SCL=0;<BR>}<BR>/*--------------------------------------------------------------------------------<BR>调用方式:void 
                        I2CSend(uchar ch) ﹫2001/07/0 
                        5<BR>函数说明:私有函数,I2C专用<BR>---------------------------------------------------------------------------------*/<BR>void 
                        I2CSendByte(Byte ch)<BR>{<BR>uchar i=8;<BR>while 
                        (i--)<BR>{<BR>SCL=0;_nop_();<BR>SDA=(bit)(ch&amp;0x80); 
                        <BR>ch&lt;&lt;=1; SomeNOP();<BR>SCL=1; 
                        SomeNOP();<BR>}<BR>SCL=0;<BR>}<BR><BR>/*----------------------------------------------------------------<BR>调用方式:uchar 
                        I2CReceive(void) ﹫2001/07/0 
                        5<BR>函数说明:私有函数,I2C专用<BR>---------------------------------------------------------------------------------*/<BR>Byte 
                        I2CReceiveByte(void)<BR>{<BR>uchar i=8;<BR>Byte 
                        ddata=0;<BR>SDA=1;<BR>while 
                        (i--)<BR>{<BR>ddata&lt;&lt;=1;<BR>SCL=0;SomeNOP();<BR>SCL=1;SomeNOP();<BR>ddata|=SDA;<BR>}<BR>SCL=0;<BR>return 
                        ddata;<BR>}<BR><BR>//开始PCF8563T驱动程序<BR>/*--------------------------------------------------------------------------------<BR>调用方式:void 
                        GetPCF8563(uchar firsttype,uchar count,uchar *buff) 
                        ﹫2001/08/0 
                        7<BR>函数说明:读取时钟芯片PCF8563的时间,设置要读的第一个时间类型firsttype,并设置读取的字节 
                        数,则会一次把时间读取到buff中。顺序是:<BR>0x02:秒/0x03:分/0x04:小时/0x05:日/0x06:星期/0x07:月(世纪)/0x08:年<BR>---------------------------------------------------------------------------------*/<BR>void 
                        GetPCF8563(uchar firsttype,uchar count,uchar 
                        *buff)<BR>{<BR>uchar 
                        i;<BR>I2CStart();<BR>I2CSendByte(0xA2);<BR>WaitAck();<BR>I2CSendByte(firsttype);<BR>WaitAck();<BR>I2CStart();<BR>I2CSendByte(0xA3);<BR>WaitAck();<BR><BR>for 
                        (i=0;i&lt;count;i++)<BR>{<BR>buff(i)=I2CReceiveByte();<BR>if 
                        (i!=count-1) 
                        SendAck();//除最后一个字节外,其他都要从MASTER发应答。<BR>}<BR><BR>SendNotAck();<BR>I2CStop();<BR>}<BR><BR><BR>/*--------------------------------------------------------------------------------<BR>调用方式:void 
                        SetPCF8563(uchar timetype,uchar value) ﹫2001/08/0 
                        7<BR>函数说明:调整时钟。timetype是要改的时间类型,value是新设置的时间值(BCD格式)。<BR>0x02:秒/0x03:分/0x04:小时/0x05:日/0x06:星期/0x07:月(世纪)/0x08:年<BR>---------------------------------------------------------------------------------*/<BR>void 
                        SetPCF8563(uchar timetype,uchar 
                        value)<BR>{<BR>I2CStart();<BR>I2CSendByte(0xA2);<BR>WaitAck();<BR>I2CSendByte(timetype);<BR>WaitAck();<BR>I2CSendByte(value);<BR>WaitAck();<BR>I2CStop();<BR>}<BR>/*--------------------------------------------------------------------------------<BR>调用方式:void 
                        SetAlarmHour(uchar count) ﹫2001/08/0 
                        7<BR>函数说明:设置报警闹钟在一天的第count点报警。例如:count=23,则在晚上11点报警。<BR>---------------------------------------------------------------------------------*/<BR>void 
                        SetAlarm(uchar alarmtype,uchar 
                        count)<BR>{<BR>SetPCF8563(0x01,0x02);<BR>SetPCF8563(alarmtype,count);<BR>}<BR><BR>/*--------------------------------------------------------------------------------<BR>调用方式:void 
                        CleanAlarm(void) ﹫2001/08/0 
                        7<BR>函数说明:清除所有报警设置。<BR>---------------------------------------------------------------------------------*/<BR>void 
                        CleanAlarm(void)<BR>{<BR>SetPCF8563(0x01,0x00);<BR>SetPCF8563(0x09,0x80);<BR>SetPCF8563(0x0A,0x80);<BR>SetPCF8563(0x0B,0x80);<BR>SetPCF8563(0x0C,0x80);<BR>// 
                        SetPCF8563(0x0D,0x00);<BR>// 
                        SetPCF8563(0x0E,0x03);<BR>}<BR><BR>/*--------------------------------------------------------------------------------<BR>调用方式:uchar 
                        read1380(uchar command )<BR>函数说明:read1380()返回当前时间, 
                        command指要返回的时间类型。<BR>秒:81H 分钟:83H 小时:85H 日期:87H 星期:89H 
                        星期几:8BH 年:8D 
                        H<BR>---------------------------------------------------------------------------------*/<BR>uchar 
                        read1380 (uchar command)<BR>{<BR>uchar 
                        time;<BR>GetPCF8563(command,1,&amp;time);<BR>return 
                        time;<BR>}<BR><BR>/*--------------------------------------------------------------------------------<BR>调用方式:void 
                        write1380(uchar command ,uchar time 
                        )<BR>函数说明:write1380()往HT1380写命令和数据,command是命令字, 
                        time是后写入的数据<BR>---------------------------------------------------------------------------------*/<BR>void 
                        write1380(uchar command ,uchar 
                        time)<BR>{<BR>SetPCF8563(command,time);<BR>}<BR>/*--------------------------------------------------------------------------------<BR>调用方式:void 
                        time_display(uchar x0,uchar y0 
                        )<BR>函数说明:time_display()在指定的x0,y0坐标,以00:00:00格式显示当前时间。<BR>---------------------------------------------------------------------------------*/<BR>//uchar 
                        time[]="00:11:11";<BR><BR>void time_display(uchar 
                        x0,uchar y0,bit type) //液晶时间显示<BR>{<BR>uchar 
                        time[]="00:00:00";<BR>uchar con[3];<BR>uchar 
                        time_type;<BR>GetPCF8563(0x02,3,con);<BR>time[0]=(con[2]&gt;&gt;4)+'0';<BR>time[1]=(con[2]&amp;0x0f)+'0';<BR>time[3]=(con[1]&gt;&gt;4)+'0';<BR>time[4]=(con[1]&amp;0x0f)+'0';<BR>time[6]=(con[0]&gt;&gt;4)+'0';<BR>time[7]=(con[0]&amp;0x0f)+'0';<BR>time[8]=0;<BR>if(type==1)<BR>{<BR>time_type=0xff;<BR>}<BR>else<BR>{<BR>time_type=0;<BR>}<BR>dipchar0(x0,y0,F57,1,time_type,time);<BR>}<BR><BR></SPAN></TD></TR>
                    <TR>
                      <TD>&nbsp;</TD></TR>
                    <TR>
                      <TD>
                        <DIV align=center></DIV></TD></TR>
                    <TR>
                      <TD>
                        <DIV align=right>【<A href="javascript:doZoom(18)">大</A> 
                        <A href="javascript:doZoom(14)">中</A> <A 
                        href="javascript:doZoom(12)">小</A>】【<A 
                        href="javascript:doPrint()">打印</A>】【<A 
                        href="javascript:window.close()">关闭</A>】【<A id=Maiweb1 
                        style="CURSOR: hand" href="javascript:ft(1)">繁体</A>】 
                        <INPUT type=hidden value=1 name=h1> 
                  </DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
          <SCRIPT 
          src="PCF8563的C51程序设计※51单片机C程序※单片机吧台 __   http--www_mcu8_cn        Powered by http--www_mcu8_cn.files/bencandy.js"></SCRIPT>
        </TR><!---->
        <TR>
          <TD class=head1 bgColor=#0099cc>
            <TABLE cellSpacing=0 cellPadding=0 width="100%">
              <TBODY>
              <TR>
                <TD width="24%"><FONT color=#000000><IMG 
                  src="PCF8563的C51程序设计※51单片机C程序※单片机吧台 __   http--www_mcu8_cn        Powered by http--www_mcu8_cn.files/1.gif"></FONT> 
                  <FONT color=#000000>网友回复</FONT></TD>
                <TD width="76%">
                  <DIV align=right><A 
                  href="http://www.avrarm.com/down/post.php?fid=17"><FONT 
                  color=#000000>新发表</FONT></A> - <A 
                  href="http://www.avrarm.com/down/post.php?id=140&amp;job=reply"><FONT 
                  color=#000000>续页发表</FONT></A> <!---->- <A 
                  href="http://www.avrarm.com/down/bencandy.php?id=140#"><FONT 
                  color=#000000>返回页顶</FONT></A></DIV></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD 
          style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 0px solid; BORDER-LEFT: #cccccc 1px solid"><!----></TD></TR>
        <TR>
          <TD class=head1 bgColor=#0099cc><FONT color=#000000><IMG 
            src="PCF8563的C51程序设计※51单片机C程序※单片机吧台 __   http--www_mcu8_cn        Powered by http--www_mcu8_cn.files/1.gif"> 
            发表回复</FONT></TD></TR>
        <TR>
          <TD 
          style="BORDER-RIGHT: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; BORDER-BOTTOM: #cccccc 1px solid">
            <FORM name=FORM_q 
            action=post.php?rid=251&amp;action=reply&amp;steps=1&amp;page=1 
            method=post>
            <TABLE cellSpacing=0 width="100%">
              <TBODY>
              <TR>
                <TD width="12%">标题:</TD>
                <TD width="88%"><INPUT onkeydown=quickpost() size=53 
                  name=atc_title> </TD></TR>
              <TR>
                <TD width="12%">内容:</TD>
                <TD width="88%"><TEXTAREA onkeydown=quickpost() name=atc_content rows=5 cols=60></TEXTAREA> 
                </TD></TR>
              <TR>
                <TD width="12%">&nbsp;</TD>
                <TD width="88%"><INPUT class=button type=submit value=发表评论 name=Submit> 
                </TD></TR>
              <TR>
                <TD width="12%">&nbsp;</TD>
                <TD 
    width="88%"></TD></TR></TBODY></TABLE></FORM></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!----><!---->
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TD align=middle></TD></TR></TBODY></TABLE>
<TABLE class=tablewidth2 
style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; BORDER-BOTTOM: #cccccc 1px solid" 
height=27 cellSpacing=0 cellPadding=0 width=770 align=center border=0>
  <TBODY>
  <TR>
    <TD bgColor=#f9f9f9 height=2></TD></TR>
  <TR>
    <TD bgColor=#c5cfd9 height=1></TD></TR>
  <TR>
    <TD bgColor=#ffffff height=1></TD></TR>
  <TR>
    <TD noWrap align=middle width="100%" bgColor=#f0f1f3 height=22>
      <DIV align=center><FONT color=#000000><A 
      href="http://www.avrarm.com/down/index.php"><FONT color=#000000>首 
      页</FONT></A> <A 
      href="http://www.avrarm.com/down/bencandy.php?id=140#"><FONT 
      color=#000000>网站介绍</FONT></A> <A 
      href="http://www.avrarm.com/down/list.php?fid=1"><FONT color=#000000>MCU 
      文章</FONT></A> <A href="http://www.avrarm.com/down/list.php?fid=16"><FONT 
      color=#000000>MCU 源码</FONT></A> <A 
      href="http://www.avrarm.com/down/list.php?fid=28"><FONT 
      color=#000000>下载中心</FONT></A> <A 
      href="http://www.avrarm.com/down/list.php?fid=3"><FONT 
      color=#000000>支持论坛</FONT></A> <A 
      href="http://www.avrarm.com/down/bencandy.php?id=140#"><FONT 
      color=#000000>关于我们</FONT></A> <A 
      href="http://www.avrarm.com/down/bencandy.php?id=140#"><FONT 
      color=#000000>联系我们</FONT></A> </FONT></DIV></TD></TR></TBODY></TABLE>
<TABLE class=tablewidth 
style="BORDER-RIGHT: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; BORDER-BOTTOM: #cccccc 1px solid" 
cellSpacing=0 cellPadding=5 width=770 align=center border=0>
  <TBODY>
  <TR>
    <TD class=bottom bgColor=#e8e8e8 height=65>
      <DIV align=center>@本站部分内容来自网上,仅供学习使用,其版权归原网站所有,若有争议,本站立即删除@ 
      <BR>@本站原创内容未经本站或作者本人同意,其他媒体一律不得转载@ <BR>Copyright @ <A 
      href="http://www.avrarm.com/"><FONT color=red>www.mcu8.cn</FONT></A> all 
      rights reserved <BR>粤ICP备<A 
      href="http://www.miibeian.gov.cn/">05117278</A>号<BR>Powered by <A 
      href="http://www.php168.com/" target=_blank><FONT>PHP168.com</FONT></A> <A 
      href="http://www.mmcbbs.com/"><FONT>v3.1</FONT></A> 
  <!----></DIV></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD>
      <DIV align=center></DIV></TD></TR></TBODY></TABLE><!----></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -