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

📄 c51开关分支语句.htm

📁 单片机教程 用c语言实现编程 可以大大缩短我们的开发周期
💻 HTM
📖 第 1 页 / 共 3 页
字号:
                  <P>中断响应(如中断打开),这个时候 TI=1,表明发送已完成,TI 不会由硬件清除,所以这个时候必须</P></DIV>
                  <P align=left><BR style="PAGE-BREAK-BEFORE: auto" 
                  clear=all>&nbsp;</P>
                  <DIV class=Section51>
                  <P>用软件对其清零。</P>
                  <P>RI 接收中断标识位。在模式 0,接收第 8 位结束时,由硬件置位。其它模式中则是在接 
                  收停止位的半中间,由硬件置位。RI=1,申请中断,要求 CPU 取走数据。但在模式 1 中,SM2=1 
                  时,当未收到有效的停止位,则不会对 RI 置位。同样 RI 也必须要靠软件清除。</P>
                  <P>常用的串行口模式 1 是传输 10 个位的,1 位起始位为 0,8 位数据位,低位在先,1 位停止 位为 
                  1。它的波特率是可变的,其速率是取决于定时器 1 或定时器 2 的定时值(溢出速率)。 AT89c51 和 
                  AT89C2051 等 51 系列芯片只有两个定时器,定时器 0 和定时器 1,而定时器 2</P>
                  <P>是 89C52 系列芯片才有的。</P>
                  <P>波特率&nbsp;&nbsp; &nbsp;在使用串行口做通信时,一个很重要的参数就是波特率,只有上下位机的波特率 
                  一样时才能进行正常通信。波特率是指串行端口每秒内能传输的波特位数。有一些开始学习 
                  的朋友认为波特率是指每秒传输的字节数,如标准 &nbsp;9600 &nbsp;会被误认为每秒种能传送 &nbsp;9600 
                  个字节,而实际上它是指每秒能传送 9600 个二进位,而一个字节要 8 个二进位,如用串 口模式 1 
                  来传输那么加上起始位和停止位,每个数据字节就要占用 10 个二进位,9600 波特 率用模式 1 传输时,每秒传输的字节数是 
                  9600÷10=960 字节。51 芯片的串行口工作模式 0 的波特率是固定的,为 fosc/12,以一个 12M 
                  的晶体震荡器来计算,那么它的波特率能达到 1M。 模式 2 的波特率是固定在 fosc/64 或 
                  fosc/32,具体用那一种就取决于 PCON 寄存器中的 SMOD 位,如 SMOD 为 0,波特率为 
                  focs/64,SMOD 为 1,波特率为 focs/32。模式 1 和模式 3 的波 特率是可变的,取决于定时器 1 或 
                  2(52 芯片)的溢出速率。那么我们怎么去计算这两个模 式的波特率设置时相关的寄存器的值呢?能用以下的公式去计算。</P>
                  <P>波特率=(2SMOD÷32)×定时器 1 溢出速率</P>
                  <P>上式中如设置了 PCON 寄存器中的 SMOD 位为 1 时就能把波特率提升 2 倍。通常会使用 定时器 1 
                  工作在定时器工作模式 2 下,这个时候定时值中的 TL1 做为计数,TH1 做为自动重装值&nbsp;&nbsp; 
                  &nbsp;, 这个定时模式下,定时器溢出后,TH1 的值会自动装载到 TL1,再次开始计数,这样能不 
                  用软件去干预,使得定时更准确。在这个定时模式 2 下定时器 1 溢出速率的计算公式如下:</P>
                  <P>溢出速率=(计数速率)/(256-TH1) 上式中的“计数速率”与所使用的晶体振荡器频率有关,在 51 
                  芯片中定时器启动后会</P>
                  <P>在每一个机器周期使定时寄存器 TH 的值增加一,一个机器周期等于十二个振荡周期,所以</P>
                  <P>能得知 51 芯片的计数速率为晶体振荡器频率的 1/12,一个 12M 的晶体震荡器用在 51 芯片上, 那么 51 
                  的计数速率就为 1M。通常用 11.0592M 晶体是为了得到标准的无误差的波特率,那 
                  么为何呢?计算一下就知道了。如我们要得到 9600 的波特率,晶体震荡器为 11.0592M 和 12M,定 时器 1 
                  为模式 2,SMOD 设为 1,分别看看那所要求的 TH1 为何值。代入公式:</P>
                  <P>11.0592M</P>
                  <P>9600=(2÷32)×((11.0592M/12)/(256-TH1))</P>
                  <P>TH1=250&nbsp;&nbsp; &nbsp;//看看是不是和上面实例中的使用的数值一样?</P>
                  <P>12M</P>
                  <P>9600=(2÷32)×((12M/12)/(256-TH1)) TH1≈249.49</P>
                  <P>上面的计算能看出使用 12M 晶体的时候计算出来的 TH1 不为整数,而 TH1 的值只能取</P></DIV>
                  <P align=left><BR style="PAGE-BREAK-BEFORE: auto" 
                  clear=all>&nbsp;</P>
                  <DIV class=Section52>
                  <P>整数,这样它就会有一定的误差存在不能产生精确的 9600 波特率。当然一定的误差是能 在使用中被接受的,就算使用 
                  11.0592M 的晶体振荡器也会因晶体本身所存在的误差使波特</P>
                  <P>率产生误差,但晶体本身的误差对波特率的影响是十分之小的,能忽略不计。</P></DIV><BR><BR><!--推荐--></DIV></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD class=box_common_title align=middle colSpan=2><A 
            href="http://www.5jia1.com/league/blog/show_comm.php?bid=361538">&lt;&lt; 
            上一篇:第十一课 C51复合语句和条件语句</A> | <A 
            href="http://www.5jia1.com/league/blog/show_comm.php?bid=361540">下一篇:第十三课 
            C51循环语句 &gt;&gt; </A></TD></TR>
        <TR class=box_common_content>
          <TD colSpan=2>
            <TABLE width="100%">
              <TBODY>
              <TR>
                <TD align=left><IMG title=人气 src="12.files/icon_click.gif" 
                  align=absMiddle border=0>人气(167)&nbsp; <IMG title=评论 
                  src="12.files/icon_btn_comment.gif" align=absMiddle 
                  border=0>&nbsp;<A 
                  href="http://www.5jia1.com/league/blog/show_comm.php?bid=361539#reply">评论(0)</A> 
                  <IMG title=转贴 src="12.files/icon_repost.gif" align=absMiddle 
                  border=0>&nbsp;转贴<A 
                  onclick=get_refer_list(514465,361539,400,505) 
                  href="javascript:void(0)">(<SPAN id=refer_361539>0</SPAN>)</A> 
                  <IMG title=收藏 src="12.files/icon_btn_favorite.gif" 
                  align=absMiddle border=0>&nbsp;<A onclick=alert_login(); 
                  href="javascript:void(0);"> 收藏</A></TD>
                <TD align=right></TD></TR></TBODY></TABLE></TD></TR>
        <TR class=box_common_content>
          <TD align=right colSpan=2><INPUT 
            onclick="javascript:alert('对不亲,请您登录!');" type=image 
            src="12.files/button_tuijian.gif"> 
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE class=box_spec cellSpacing=1 cellPadding=5 width="98%" align=center 
border=0>
  <TBODY>
  <TR>
    <TD><STRONG>发表评论</STRONG><A name=reply></A></TD>
    <TD align=middle>&nbsp;</TD></TR>
  <TR class=box_spec_content>
    <TD align=middle>&nbsp;</TD>
    <TD>
      <TABLE cellSpacing=0 cellPadding=0 border=0>
        <FORM id=comment name=comment onsubmit="return formsubmit();" 
        action=/league/blog/add_comm.php method=post target=hidden_frame><INPUT 
        id=bid type=hidden value=361539 name=bid> <INPUT id=sid type=hidden 
        name=sid> 
        <TBODY>
        <TR>
          <TD><SPAN 
            class=font_common_title>发表评论</SPAN>(最多可填600个字符,300个汉字)&nbsp;<SPAN 
            class=color_red id=left_num>0</SPAN>/600</TD>
          <TD>&nbsp;</TD></TR>
        <TR>
          <TD><TEXTAREA class=input_box01 onpropertychange="textCounter(comment.content, 600)" name=content rows=10 cols=70></TEXTAREA> 
          </TD>
          <TD vAlign=top>
            <DIV><LABEL>插入表情:</LABEL> 
            <TABLE 
            style="BORDER-RIGHT: #96ae72 1px solid; BORDER-TOP: #96ae72 1px solid; BACKGROUND: #edf8dd; BORDER-LEFT: #96ae72 1px solid; BORDER-BOTTOM: #96ae72 1px solid">
              <TBODY>
              <TR>
                <TD><A onclick="insertSmile('[[::keai::]]');" 
                  href="javascript:void(0)"><IMG title=可爱 height=32 
                  src="12.files/1.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::ciya::]]');" 
                  href="javascript:void(0)"><IMG title=呲牙 height=32 
                  src="12.files/2.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::guilian::]]');" 
                  href="javascript:void(0)"><IMG title=鬼脸 height=32 
                  src="12.files/3.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::deyi::]]');" 
                  href="javascript:void(0)"><IMG title=得意 height=32 
                  src="12.files/4.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::xihuan::]]');" 
                  href="javascript:void(0)"><IMG title=喜欢 height=32 
                  src="12.files/5.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::jie::]]');" 
                  href="javascript:void(0)"><IMG title=饥饿 height=32 
                  src="12.files/6.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::chijing::]]');" 
                  href="javascript:void(0)"><IMG title=吃惊 height=32 
                  src="12.files/7.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::sikao::]]');" 
                  href="javascript:void(0)"><IMG title=思考 height=32 
                  src="12.files/8.gif" width=32 border=0></A></TD></TR>
              <TR>
                <TD><A onclick="insertSmile('[[::haixui::]]');" 
                  href="javascript:void(0)"><IMG title=害羞 height=32 
                  src="12.files/9.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::tongkuliu::]]');" 
                  href="javascript:void(0)"><IMG title=痛哭 height=32 
                  src="12.files/10.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::bizui::]]');" 
                  href="javascript:void(0)"><IMG title=闭嘴 height=32 
                  src="12.files/11.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::kubi::]]');" 
                  href="javascript:void(0)"><IMG title=酷酷 height=32 
                  src="12.files/12.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::liuhan::]]');" 
                  href="javascript:void(0)"><IMG title=流汗 height=32 
                  src="12.files/13.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::konghe::]]');" 
                  href="javascript:void(0)"><IMG title=恐吓 height=32 
                  src="12.files/14.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::gaoxing::]]');" 
                  href="javascript:void(0)"><IMG title=高兴 height=32 
                  src="12.files/15.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::kunjuan::]]');" 
                  href="javascript:void(0)"><IMG title=困倦 height=32 
                  src="12.files/16.gif" width=32 border=0></A></TD></TR>
              <TR>
                <TD><A onclick="insertSmile('[[::yiwen::]]');" 
                  href="javascript:void(0)"><IMG title=疑问 height=32 
                  src="12.files/17.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::zhaoji::]]');" 
                  href="javascript:void(0)"><IMG title=着急 height=32 
                  src="12.files/18.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::nanguo::]]');" 
                  href="javascript:void(0)"><IMG title=难过 height=32 
                  src="12.files/19.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::shenqi::]]');" 
                  href="javascript:void(0)"><IMG title=生气 height=32 
                  src="12.files/20.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::tongku::]]');" 
                  href="javascript:void(0)"><IMG title=痛苦 height=32 
                  src="12.files/21.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::yumen::]]');" 
                  href="javascript:void(0)"><IMG title=郁闷 height=32 
                  src="12.files/22.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::daku::]]');" 
                  href="javascript:void(0)"><IMG title=大哭 height=32 
                  src="12.files/23.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::jingkong::]]');" 
                  href="javascript:void(0)"><IMG title=惊恐 height=32 
                  src="12.files/24.gif" width=32 
            border=0></A></TD></TR></TBODY></TABLE></DIV></TD></TR>
        <TR>
          <TD><BR><INPUT type=hidden value=do name=submit> <INPUT class=btn01 onclick=alert_login(); type=button value=发表评论 name=submit1> 
<INPUT class=btn01 type=reset value=重新填写 name=重置> 
        </TD></TR></FORM></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><!--<table width="100%"  border="0" cellpadding="5" cellspacing="1" class="box_common">
			<tr valign="top">
             <td>&nbsp;</td>
           </tr>
		   <tr><td class="box_content">
		   
		 <A name="reply"></A></td>
		   </tr>
		   </table>--></TD></TR></TABLE></DIV></DIV></DIV>
<TABLE class=module_content cellSpacing=0 cellPadding=0 border=0>
  <TBODY>
  <TR>
    <TD class=corner_lb>
      <DIV class=mainLayer_lb>
      <DIV class=subLayer_lb></DIV></DIV></TD>
    <TD class=corner_cb><IMG height=1 width=1></TD>
    <TD class=corner_rb>
      <DIV class=mainLayer_rb>
      <DIV class=subLayer_rb></DIV></DIV></TD></TR></TBODY></TABLE></DIV></DIV><!--底部公用文件-->
<DIV id=copyright><A href="http://www.5jia1.com/main/aboutus/?t=1" 
target=_blank>关于5jia1</A> | <A 
href="http://www.5jia1.com/personal/member/index.php?member_id=100773" 
target=_blank>客户服务</A> | <A href="http://www.5jia1.com/aboutus/?t=4" 
target=_blank>联系我们</A> | <A 
href="http://www.5jia1.com/league/index.php?gid=329849" target=_blank>意见留言板</A> 
| <A href="http://www.5jia1.com/personal/member/index.php?member_id=100773" 
target=_blank>帮助</A><BR>北京美嘉文化有限公司版权所有&nbsp;&nbsp; Copyright &copy; 2005 5jia1.com 
All rights reserved<BR>京ICP证 050254</DIV>
<SCRIPT src="12.files/urchin.js" type=text/javascript></SCRIPT>

<SCRIPT type=text/javascript>
  _uacct="UA-177986-4";
  urchinTracker();
</SCRIPT>
</CENTER><IFRAME id=hidden_frame name=hidden_frame src="about:blank" 
frameBorder=0 width=0 scrolling=no height=0></IFRAME><IFRAME marginWidth=0 
marginHeight=0 src="12.files/update_online.htm" frameBorder=0 width=0 
scrolling=no height=0></IFRAME><!--default_run//-->
<SCRIPT language=JavaScript type=text/JavaScript>

function set_comment(bid,sid)
{
	document.comment.bid.value = bid;
	document.comment.sid.value = sid;
	
}
function formsubmit()
{
	if (document.comment.content.value.trim() == "")
	{
		showAlert("评论内容不能为空!");
		document.comment.content.focus();
		return false;
	}
	var cdw = check_deny_word(document.comment) ;
	if (cdw != false)
	{
		showAlert(cdw);
		return false;
	}
	return true;
}

// 弹出收藏页面
function add_favorite(uid,url)
{
	window.open("/personal/favorite/add.php?member_id="+uid+"&url="+url,'_blank','width=400,height=220,toolbar=0,locationbar=0,menubar=0,statbar=0'); 
	return false;
}

// 提示登录
function alert_login()
{
	showAlert('对不起,您目前没有权限,请先登录!');
	document.login_form1.account.focus();
}
</SCRIPT>
</BODY></HTML>

⌨️ 快捷键说明

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