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

📄 c51hex文件的生成和单片机最小系统.htm

📁 单片机教程 用c语言实现编程 可以大大缩短我们的开发周期
💻 HTM
📖 第 1 页 / 共 3 页
字号:
			thisform.account.focus();
			return false;
	   }
	   
	   if (password == "")
	   {
		showAlert ("密码不能为空");
		thisform.password.focus();
		return false;
	   }
	   return true;
}
function top_joined(value)
{
	if (value != "")
	{
		var action;
		action = value.split("_");
		if (action[0] == "league")
		{
			window.location.href="/league/index.php?gid=" + action[1];
		}
		if (action[0] == "acti")
		{
			window.location.href="/league/activity/acti_mana_index.php?t_id=" + action[1];
		}

	}
}

function copyurl(url)
{
	try{
		clipboardData.setData('Text',url);
		showAlert('已经把该社团网址复制到系统剪贴板,您可以使用(Ctrl+V或鼠标右键)粘贴功能,通过其他软件记录或发送给您的朋友。')
	}
	catch(e){}
}
function add_favorite(uid, url, name)
{
	window.open("/personal/favorite/add.php?member_id="+uid+"&url="+url+"&name="+name,'_blank','width=400,height=220,toolbar=0,locationbar=0,menubar=0,statbar=0'); 
	return false;
}

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


//申请加入社团
function con_join(con_gid)
{
	showConfirm("您确认加入本社团吗?","window.location.href='/league/apply.php?g_id="+con_gid+"';","");
}


//退出本社团
function con_quiet(con_gid,con_uid)
{
	showConfirm("您确认退出本社团吗?","window.location.href='/league/member/quiet_member.php?g_id="+con_gid+"&q_uid="+con_uid+"';","");
}

</SCRIPT>
<!-- 回复框 -->
<DIV id=background style="DISPLAY: none"></DIV>
<DIV id=postbox 
style="DISPLAY: none; Z-INDEX: 50; LEFT: 769px; WIDTH: 600px; POSITION: absolute; TOP: 271px">
<FORM name=reply_comment action=/league/comment/index.php?gid=514465 method=post 
target=hidden_frame><INPUT id=act type=hidden value=add name=act> <INPUT id=r_id 
type=hidden name=r_id> <INPUT id=t_id type=hidden name=t_id> <INPUT id=f_uid 
type=hidden name=f_uid> 
<TABLE cellSpacing=0 cellPadding=0 width="70%" border=0>
  <TBODY>
  <TR>
    <TD height=13>&nbsp;</TD></TR>
  <TR>
    <TD class=box_common height=26>&nbsp;<SPAN 
      class=font_common_title>回复评论</SPAN></TD></TR></TBODY></TABLE>
<TABLE class=box_common01 cellSpacing=0 cellPadding=0 width="70%">
  <TBODY>
  <TR>
    <TD>
      <TABLE cellSpacing=8 cellPadding=0 width="100%" bgColor=#ffffff 
        border=0><TBODY>
        <TR>
          <TD class=font_common vAlign=top align=right height=63>内容:</TD>
          <TD class=font_common vAlign=top><TEXTAREA class=input_box01 id=input_area name=input_area rows=6 cols=48></TEXTAREA></TD></TR>
        <TR>
          <TD class=font_common vAlign=top align=right width="15%">原文:</TD>
          <TD class=font_common style="LINE-HEIGHT: 18px" vAlign=top 
            width="85%"><SPAN class=gray id=past_type></SPAN></TD></TR>
        <TR>
          <TD class=font_common vAlign=top align=middle colSpan=2><INPUT class=btn01 onclick=javascript:hidden_reply();submit_post(document.reply_comment); type=button value=发表 name=queding> 
            &nbsp;&nbsp; <INPUT class=btn01 onclick=hidden_reply(); type=reset value=取消> 
        </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM></DIV><!-- 回复框 -->
<DIV id=mainBox>
<DIV id=mainBoxBg>
<TABLE class=module_title cellSpacing=0 cellPadding=0 border=0>
  <TBODY>
  <TR>
    <TD class=corner_left></TD>
    <TD class=corner_center><A 
      href="http://www.5jia1.com/league/?gid=514465">首页</A>&nbsp;&gt;&nbsp;<A 
      href="http://www.5jia1.com/league/blog/blog_index.php?gid=514465">社团文集</A>&nbsp;&gt;&nbsp;<A 
      href="http://www.5jia1.com/league/blog/show_comm.php?bid=361224">第二课 
      C51HEX文件的生成和单片机最小系统</A></TD>
    <TD class=corner_right></TD></TR></TBODY></TABLE>
<DIV class=module_content>
<DIV class=module_content_line>
<DIV class=bg>
<TABLE cellSpacing=10 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD align=middle>
      <TABLE class=box_common cellSpacing=1 cellPadding=5 width="100%" 
        border=0><TBODY>
        <TR class=box_common_title>
          <TD colSpan=2>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD width="35%"><B>第二课 C51HEX文件的生成和单片机最小系统</B></TD>
                <TD align=right width="65%">作者: <A 
                  href="http://www.5jia1.com/personal/?member_id=505887" 
                  target=_blank>张文俊</A> &nbsp;&nbsp;2007-08-14 
                  15:11:00&nbsp;&nbsp; </TD></TR></TBODY></TABLE></TD></TR>
        <TR class=box_content>
          <TD vAlign=top align=middle width="10%"><A 
            href="http://www.5jia1.com/personal/?member_id=505887" 
            target=_blank><IMG class=box01 height=98 
            src="2.files/s_0_personal_photo_505887.jpg" width=98 vspace=5 
            border=0></A><BR><IMG height=14 src="2.files/icon_boy.gif" width=14 
            border=0>&nbsp; <A 
            href="http://www.5jia1.com/personal/?member_id=505887" 
            target=_blank>张文俊</A> </TD>
          <TD>
            <TABLE class="font_content  autowrap" cellSpacing=12 cellPadding=0 
            width="100%" border=0>
              <TBODY>
              <TR>
                <TD class=line_h20 style="WIDTH: 790px">
                  <DIV style="OVERFLOW-X: auto; WIDTH: 100%">
                  <TABLE style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" 
                  cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TH vAlign=center align=middle height=32>
                        <H1>第二课 C51HEX文件的生成和单片机最小系统</H1></TH></TR>
                    <TR>
                      <TD align=middle bgColor=#f7f7f7 
                        height=25>作者:佚名&nbsp;&nbsp;&nbsp;&nbsp;来源:本站原创&nbsp;&nbsp;&nbsp;&nbsp;点击数: 
                        183&nbsp;&nbsp;&nbsp;更新时间:2007年07月19日&nbsp;&nbsp;&nbsp;</TD></TR></TBODY></TABLE>
                  <P>上一篇建立了第一个<A href="http://www.51hei.com/" 
                  target=_blank><U><FONT 
                  color=#800080>单片机</FONT></U></A>C语言项目,但为了让编译好的程序能通过编程器写入51芯 
                  片中,要先用编译器生成HEX文件,下面来看看如何用KEIL uVISION2来编译生成用于烧写 
                  芯片的HEX文件。HEX文件格式是Intel公司提出的按地址排列的数据信息,数据宽度为字 节,所有数据使用16进制数字表示, 
                  &nbsp;常用来保存<A href="http://www.51hei.com/" 
                  target=_blank><U><FONT 
                  color=#800080>单片机</FONT></U></A>或其他处理器的目标程序代码。它保 
                  存物理程序存储区中的目标代码映象。一般的编程器都支持这种格式。我们先来打开第一个 
                  项目,打开它的所在目录,找到test.Uv2的文件就能打开先前的项目了。然后右击图2-1 
                  中的1项目文件夹,弹出项目功能菜单,选Options for Target’Target1’,弹出项目选项设置窗口, 
                  同样先选中项目文件夹图标,这个时候在Project菜单中也有一样的菜单可选。打开项目选项窗口, 
                  转到Output选项页图2-2所示,图中1是选择编译输出的路径,2是设置编译输出生成的文件 
                  名,3则是决定是否要创建HEX文件,选中它就能输出HEX文件到指定的路径中。选好了? 
                  好,我们再将它重新编译一次,很快在编译信息窗口中就显示HEX文件创建到指定的路径 
                  中了,如图2-3。这样我们就可用自己的编程器所附带的软件去读取并烧到芯片了,再用实 
                  验板看结果,至于编程器或仿真器品种繁多具体方法就看它的说明书了,这里也不做讨论。</P>
                  <P>(技巧:一、在图2-1中的1里的项目文件树形目录中,先选中对象,再单击它就可对它进 
                  行重命名操作,双击文件图标便可打开文件。二、在Project下拉菜单的最下方有最近编辑过</P>
                  <P>的项目路径保存,这里能快速打开最近在编辑的项目。)</P>
                  <P>图2-1项目功能菜单</P><BR style="PAGE-BREAK-BEFORE: auto" 
clear=all>
                  <DIV class=Section9>
                  <P><IMG style="WIDTH: 550px; CURSOR: pointer" alt=点此在新窗口浏览图片 
                  src="2.files/20077195600112405.jpg" width=550 border=0 
                  &111nload="function anonymous()&#13;&#10;{&#13;&#10;resizepic(this)&#13;&#10;}" 
                  &111nclick="function anonymous()&#13;&#10;{&#13;&#10;window.open(this.src);&#13;&#10;}" 
                  &111nmousewheel="function anonymous()&#13;&#10;{&#13;&#10;return bbimg(this)&#13;&#10;}"></P>
                  <P>图2-2&nbsp;&nbsp; &nbsp;项目选项窗口</P>
                  <P><IMG style="CURSOR: pointer" alt=点此在新窗口浏览图片 
                  src="2.files/20077197225489654.gif" width=423 border=0 
                  &111nload="function anonymous()&#13;&#10;{&#13;&#10;resizepic(this)&#13;&#10;}" 
                  &111nclick="function anonymous()&#13;&#10;{&#13;&#10;window.open(this.src);&#13;&#10;}" 
                  &111nmousewheel="function anonymous()&#13;&#10;{&#13;&#10;return bbimg(this)&#13;&#10;}"></P>
                  <P>图 2-3&nbsp;&nbsp; &nbsp;编译信息窗口</P>
                  <P>或许您已把编译好的文件烧到了芯片上,如果您购买或自制了带串行口输出元件的学习实 验板,那您就能把串行口和 PC 
                  机串行口相联用串行口调试软件或 Windows 的超级终端,将其波特 率设为 
                  &nbsp;1200,就能看到不停输出的“Hello &nbsp;World!”字样。如果您还没有实验板,那这 里先说说 
                  AT89c51 的最小化系统,再以一实例程序验证最小化系统是否在运行,这个最小化 系统也易于自制用于实验。图 2-4 便是 
                  AT89c51 的最小化系统,不过为了让我们能看出它 是在运行的,加了一个电阻和一个 
                  LED,用以显示它的状态,晶体震荡器能根据自己的情况使用, 一般实验板上是用 11.0592MHz 或 
                  12MHz,使用前者的好外是能产生标准的串行口波特率,后 者则一个机器周期为 1 
                  微秒,便于做精确定时。在自己做实验里,注意的是 VCC 是+5V 的, 不能高于此值,不然将损坏<A 
                  href="http://www.51hei.com/" target=_blank><U><FONT 
                  color=#800080>单片机</FONT></U></A>,太低则不能正常工作。在 31 脚要接高电平,这样我们 
                  才能执行片内的程序,如接低电平则使用片外的程序存储器。下面建一个新的项目名为 OneLED 
                  来验证最小化系统是否能工作(所有的例程都可在笔者的主页下面下载到,网址: <A 
                  href="http://www.51hei.com/"><U><FONT 
                  color=#800080>http://www.51hei.com</FONT></U></A> 
                  &nbsp;。程序如下:</P></DIV><BR style="PAGE-BREAK-BEFORE: auto" 
                  clear=all>
                  <DIV class=Section10>
                  <P>#include &nbsp;&lt;AT89X51.h&gt; &nbsp;//预处理命令</P>
                  <P>void &nbsp;main(void) &nbsp;//主函数名</P>
                  <P>{</P>
                  <P>//这是第一种注释方式</P>
                  <P>unsigned &nbsp;int &nbsp;a; &nbsp;//定义变量 a 为 int 类型</P>
                  <P>/* 这是第二种注释方式</P>
                  <P>*/</P>
                  <P>do{ &nbsp;//do &nbsp;while 组成循环</P>
                  <P>for &nbsp;(a=0; &nbsp;a&lt;50000; &nbsp;a++); 
                  &nbsp;//这是一个循环 P1_0 &nbsp;= &nbsp;0; &nbsp;//设 P1.0 口为低电平,点亮 
                  LED for &nbsp;(a=0; &nbsp;a&lt;50000; &nbsp;a++); 
                  &nbsp;//这是一个循环 P1_0 &nbsp;= &nbsp;1; &nbsp;//设 P1.0 口为高电平,熄灭 
                  LED</P>
                  <P>}</P>
                  <P>while(1);</P>
                  <P>}</P>
                  <P><IMG style="CURSOR: pointer" alt=点此在新窗口浏览图片 
                  src="2.files/20077190882850875.gif" width=550 border=0 
                  &111nload="function anonymous()&#13;&#10;{&#13;&#10;resizepic(this)&#13;&#10;}" 
                  &111nclick="function anonymous()&#13;&#10;{&#13;&#10;window.open(this.src);&#13;&#10;}" 

⌨️ 快捷键说明

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