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

📄 c51ds1202.html

📁 C51例程代码
💻 HTML
字号:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>单片机编程世界——编程实战---C51</title><meta name="GENERATOR" content="Microsoft FrontPage 3.0"></head><body background="image\weave.gif"><div align="center"><center><table border="0" width="494" height="128" cellpadding="0">  <tr>    <td width="494" height="35" align="center">/*********************************************************/<br>    <br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DS1202.C: DS1202     real time clock chip BIOS <br>    <br>    &nbsp; 易兵<br>    1999-10-20<br>    /*********************************************************/</td>  </tr>  <tr>    <td width="494" height="1491"><br>    <br>    /* Bit Address Assignment*/<br>    sbit RTC_RST= 0x95; /* P1.5 */<br>    sbit RTC_CLK= 0x96; /* P1.6 */<br>    sbit RTC_DIO= 0x97; /* P1.7 */<br>    <br>    <font color="#FF00FF">void RtcDelay(void)</font>; /* Photo type of routine */<br>    <font color="#FF00FF">void RtcDelay()</font><br>    {<br>    &nbsp;&nbsp;&nbsp; xdata unsigned char i;<br>    &nbsp;&nbsp;&nbsp; for (i=0;i&lt;50;i++);<br>    }<br>    <br>    <font color="#FF00FF">void RtcWrite(char, char);</font> /* Photo type of routine */<br>    <font color="#FF00FF">void RtcWrite(char command, char byte_data)</font><br>    { <br>    &nbsp;&nbsp;&nbsp; xdata unsigned char i;<br>    &nbsp;&nbsp;&nbsp; command=((command&lt;&lt;1)&amp;0xfe)|0x80; <br>    &nbsp;&nbsp;&nbsp; RTC_CLK= 0;<br>    &nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp; RTC_RST= 0;<br>    &nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp; RTC_RST= 1;<br>    &nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp; for (i=0;i&lt;8;i++)<br>    &nbsp;&nbsp; { <br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_CLK=0;<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_DIO=((command&gt;&gt;i) &amp; 0x01);<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_CLK=1;<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp; }<br>    &nbsp;&nbsp;&nbsp; for (i=0;i&lt;8;i++)<br>    &nbsp;&nbsp; { <br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_CLK=0;<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_DIO=((byte_data&gt;&gt;i)&amp; 0x01); <br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_CLK=1;<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp; }<br>    &nbsp;&nbsp; RTC_RST=0; <br>    &nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp; RTC_CLK=0;<br>    &nbsp;&nbsp; RtcDelay(); <br>    &nbsp;&nbsp; RTC_RST=1;<br>    &nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp; RTC_CLK=1;<br>    &nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp; RTC_RST=0;<br>    &nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp; RTC_CLK=0;<br>    &nbsp;&nbsp; RtcDelay();<br>    }<br>    <br>    <font color="#FF00FF">char RtcRead(char);</font> /* Photo type of routine */<br>    <font color="#FF00FF">char RtcRead(char command)</font><br>    { <br>    &nbsp;&nbsp;&nbsp; xdata unsigned char i,j;<br>    &nbsp;&nbsp;&nbsp; command=(command&lt;&lt;1)|0x81;<br>    &nbsp;&nbsp;&nbsp; RTC_CLK=0;<br>    &nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp; RTC_RST= 0;<br>    &nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp; RTC_RST= 1;<br>    &nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp; for (i=0;i&lt;8;i++)<br>    &nbsp;&nbsp; { <br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_CLK=0;<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_DIO=((command&gt;&gt;i) &amp; 0x01);<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_CLK=1;<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp; }<br>    &nbsp;&nbsp; RTC_DIO=1;<br>    &nbsp;&nbsp; RTC_CLK=0;<br>    &nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp; for (i=0;i&lt;8;i++)<br>    &nbsp; { <br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RTC_CLK=1;<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (RTC_DIO==1)<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j=(j&gt;&gt;1)|0x80;<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j=(j&gt;&gt;1)&amp;0x7f;<br>    &nbsp;&nbsp;&nbsp;&nbsp; RTC_CLK=0;<br>    &nbsp;&nbsp;&nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp; }<br>    &nbsp;&nbsp; RTC_RST=0;<br>    &nbsp;&nbsp; RTC_DIO=0;<br>    &nbsp;&nbsp; RtcDelay();<br>    &nbsp;&nbsp; return (j);<br>    }<br>    <br>    <font color="#FF00FF">void RtcSetup(char, char);</font> /* Photo type of routine */<br>    <font color="#FF00FF">void RtcSetup(char command, char byte_data)</font><br>    { <br>    &nbsp;&nbsp;&nbsp; RtcWrite(0x07,0x00);<br>    &nbsp;&nbsp;&nbsp; RtcWrite(command,byte_data);<br>    &nbsp;&nbsp;&nbsp; RtcWrite(0x07,0x80);<br>    }<br>    </td>  </tr>  <tr>    <td width="494" height="13" align="center">1999-10-20</td>  </tr>  <tr>    <td width="494" height="51" align="center"><a href="http://mcu21cn.yeah.net">《单片机编程世界》</a></td>  </tr></table></center></div><p align="center"><a href="c51program.htm" target="_self">返回</a></p></body></html>

⌨️ 快捷键说明

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