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

📄 c51数据类型.htm

📁 单片机教程 用c语言实现编程 可以大大缩短我们的开发周期
💻 HTM
📖 第 1 页 / 共 3 页
字号:
                  <P>while(1);</P>
                  <P>}</P>
                  <P>同样编译烧写,上电运行您就能看到结果了。很明显 D1 点亮的时间长于 D2 点亮的时间。</P>
                  <P>这里必须要讲的是,当定义一个变量为特定的数据类型时,在程序使用该变量不应使它的值 超过数据类型的值域。如本例中的变量 
                  b 不能赋超出 0~255 的值,如 for (b=0; b&lt;255; b++) 改为 for &nbsp;(b=0; 
                  &nbsp;b&lt;256; &nbsp;b++),编译是能通过的,但运行时就会有问题出现,就是说 b 的 值永远都是小于 
                  256 的,所以无法跳出循环执行下一句 P1_1 = 1,从而造成死循环。同理 a 的值不应超出 0~65535。</P>
                  <P>3. long 长整型</P>
                  <P>long 长整型长度为四个字节,用于存放一个四字节数据。分有符号 long 长整型 signed long 
                  和无符号长整型 unsigned &nbsp;long,默认值为 signed &nbsp;long 类型。signed 
                  &nbsp;int 表示 
                  的数值范围是-2147483648~+2147483647,字节中最高位表示数据的符号,“0”表示正 
                  数,“1”表示负数。unsigned &nbsp;long 表示的数值范围是 0~4294967295。</P>
                  <P>4. float 浮点型</P>
                  <P>float 浮点型在十进制中具有 7 位有效数字,是符合 IEEE-754 标准的单精度浮点型数 
                  据,占用四个字节。因浮点数的结构较复杂在以后的章节中再做详细的讨论。</P>
                  <P>5.*&nbsp;&nbsp; &nbsp;指针型 
                  指针型本身就是一个变量,在这个变量中存放的指向另一个数据的地址。这个指针变量 
                  要占据一定的内存单元,对不一样的处理器长度也不尽相同,在 c51 中它的长度一般为 1~</P>
                  <P>3 个字节。指针变量也具有类型,在以后的课程中有专门一课做探讨,这里就不多说了。</P>
                  <P>6. bit 位标量</P>
                  <P>bit 位标量是 c51 编译器的一种扩充数据类型,利用它可定义一个位标量,但不能定义 
                  位指针,也不能定义位数组。它的值是一个二进制位,不是 0 就是 1,类似一些高级语 言中的 Boolean 类型中的 
                  True 和 False。</P>
                  <P>7. sfr 特殊功能寄存器</P>
                  <P>sfr 也是一种扩充数据类型,点用一个内存单元,值域为 0~255。利用它能访问 51 <A 
                  href="http://www.5jia1.com/" target=_blank><U><FONT 
                  color=#800080>单片机</FONT></U></A>内部的所有特殊功能寄存器。如用 sfr P1 = 0x90 
                  这一句定 P1 为 P1 端口在片内 的寄存器,在后面的语句中用以用 P1 = 255(对 P1 
                  端口的所有引脚置高电平)之类的 语句来操作特殊功能寄存器。</P>
                  <P>8.sfr16 &nbsp;16 位特殊功能寄存器</P>
                  <P>sfr16 占用两个内存单元,值域为 0~65535。sfr16 和 sfr 一样用于操作特殊功能寄存 
                  器,所不一样的是它用于操作占两个字节的寄存器,如定时器 T0 和 T1。</P>
                  <P>9. sbit 可录址位</P>
                  <P>sbit 同样是 单片机c语言 中的一种扩充数据类型,利用它能访问芯片内部的 RAM 
                  中的可寻址</P></DIV><BR style="PAGE-BREAK-BEFORE: auto" clear=all>
                  <DIV class=Section15>
                  <P>位或特殊功能寄存器中的可寻址位。如先前定义了</P>
                  <P>sfr &nbsp;P1 &nbsp;= &nbsp;0x90; &nbsp;//因 P1 
                  端口的寄存器是可位寻址的,所以能定义</P>
                  <P>sbit &nbsp;P1_1 &nbsp;= &nbsp;P1^1;&nbsp;&nbsp; 
                  &nbsp;//P1_1 为 P1 中的 P1.1 引脚</P>
                  <P>//同样我们能用 P1.1 的地址去写,如 sbit &nbsp;P1_1 &nbsp;= &nbsp;0x91; 
                  这样在以后的程序语句中就能用 P1_1 来对 P1.1 引脚进行读写操作了。通常这些能 
                  直接使用系统供给的预处理文件,里面已定义好各特殊功能寄存器的简单名字,直接引 
                  用能省去一点时间,我自己是一直用的。当然您也能自己写自己的定义文件,用您 
认为好记的名字。</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=361224">&lt;&lt; 
            上一篇:第二课 C51HEX文件的生成和单片机最小系统</A> | <A 
            href="http://www.5jia1.com/league/blog/show_comm.php?bid=361241">下一篇:第四课 
            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="3.files/icon_click.gif" 
                  align=absMiddle border=0>人气(50)&nbsp; <IMG title=评论 
                  src="3.files/icon_btn_comment.gif" align=absMiddle 
                  border=0>&nbsp;<A 
                  href="http://www.5jia1.com/league/blog/show_comm.php?bid=361231#reply">评论(0)</A> 
                  <IMG title=转贴 src="3.files/icon_repost.gif" align=absMiddle 
                  border=0>&nbsp;转贴<A 
                  onclick=get_refer_list(514465,361231,400,505) 
                  href="javascript:void(0)">(<SPAN id=refer_361231>0</SPAN>)</A> 
                  <IMG title=收藏 src="3.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="3.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=361231 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="3.files/1.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::ciya::]]');" 
                  href="javascript:void(0)"><IMG title=呲牙 height=32 
                  src="3.files/2.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::guilian::]]');" 
                  href="javascript:void(0)"><IMG title=鬼脸 height=32 
                  src="3.files/3.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::deyi::]]');" 
                  href="javascript:void(0)"><IMG title=得意 height=32 
                  src="3.files/4.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::xihuan::]]');" 
                  href="javascript:void(0)"><IMG title=喜欢 height=32 
                  src="3.files/5.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::jie::]]');" 
                  href="javascript:void(0)"><IMG title=饥饿 height=32 
                  src="3.files/6.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::chijing::]]');" 
                  href="javascript:void(0)"><IMG title=吃惊 height=32 
                  src="3.files/7.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::sikao::]]');" 
                  href="javascript:void(0)"><IMG title=思考 height=32 
                  src="3.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="3.files/9.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::tongkuliu::]]');" 
                  href="javascript:void(0)"><IMG title=痛哭 height=32 
                  src="3.files/10.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::bizui::]]');" 
                  href="javascript:void(0)"><IMG title=闭嘴 height=32 
                  src="3.files/11.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::kubi::]]');" 
                  href="javascript:void(0)"><IMG title=酷酷 height=32 
                  src="3.files/12.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::liuhan::]]');" 
                  href="javascript:void(0)"><IMG title=流汗 height=32 
                  src="3.files/13.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::konghe::]]');" 
                  href="javascript:void(0)"><IMG title=恐吓 height=32 
                  src="3.files/14.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::gaoxing::]]');" 
                  href="javascript:void(0)"><IMG title=高兴 height=32 
                  src="3.files/15.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::kunjuan::]]');" 
                  href="javascript:void(0)"><IMG title=困倦 height=32 
                  src="3.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="3.files/17.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::zhaoji::]]');" 
                  href="javascript:void(0)"><IMG title=着急 height=32 
                  src="3.files/18.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::nanguo::]]');" 
                  href="javascript:void(0)"><IMG title=难过 height=32 
                  src="3.files/19.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::shenqi::]]');" 
                  href="javascript:void(0)"><IMG title=生气 height=32 
                  src="3.files/20.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::tongku::]]');" 
                  href="javascript:void(0)"><IMG title=痛苦 height=32 
                  src="3.files/21.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::yumen::]]');" 
                  href="javascript:void(0)"><IMG title=郁闷 height=32 
                  src="3.files/22.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::daku::]]');" 
                  href="javascript:void(0)"><IMG title=大哭 height=32 
                  src="3.files/23.gif" width=32 border=0></A></TD>
                <TD><A onclick="insertSmile('[[::jingkong::]]');" 
                  href="javascript:void(0)"><IMG title=惊恐 height=32 
                  src="3.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="3.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="3.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 + -