51功能寄存器一览表
<p>分享一个51单片机资料</p><p> </p>
<p><span style="color:#000000"><strong>51 </strong></span><span style="color:#000000"><strong>单片机寄存器功能一览表 </strong></span></p>
<p><span style="color:#6d6d6d">21 </span><span style="color:#6d6d6d">个特殊功能寄存器(</span><span style="color:#6d6d6d">52 </span><span style="color:#6d6d6d">系列是 </span><span style="color:#6d6d6d">26 </span><span style="color:#6d6d6d">个)不连续地分布在 </span><span style="color:#6d6d6d">128 </span><span style="color:#6d6d6d">个字节的 </span><span style="color:#6d6d6d">SFR </span><span style="color:#6d6d6d">存储空间中,地址空间为 </span><span style="color:#6d6d6d">80H-FFH</span><span style="color:#6d6d6d">, </span></p>
<p><span style="color:#6d6d6d">在这片 </span><span style="color:#6d6d6d">SFR </span><span style="color:#6d6d6d">空间中,包含有 </span><span style="color:#6d6d6d">128 </span><span style="color:#6d6d6d">个位地址空间,地址也是 </span><span style="color:#6d6d6d">80H-FFH</span><span style="color:#6d6d6d">,但只有 </span><span style="color:#6d6d6d">83 </span><span style="color:#6d6d6d">个有效位地址,可对 </span><span style="color:#6d6d6d">11 </span><span style="color:#6d6d6d">个特殊功能寄 </span></p>
<p><span style="color:#6d6d6d">存器的某些位作位寻址操作(这里介绍一个技巧:其地址能被 </span><span style="color:#6d6d6d">8 </span><span style="color:#6d6d6d">整除的都可以位寻址)。 </span></p>
<p><span style="color:#6d6d6d">在 </span><span style="color:#6d6d6d">51 </span><span style="color:#6d6d6d">单片机内部有一个 </span><span style="color:#6d6d6d">CPU </span><span style="color:#6d6d6d">用来运算、控制,有</span><span style="color:#ff0000">四个并行 </span><span style="color:#ff0000">I/O </span><span style="color:#ff0000">口</span><span style="color:#6d6d6d">,分别是 </span><span style="color:#6d6d6d">P0</span><span style="color:#6d6d6d">、</span><span style="color:#6d6d6d">P1</span><span style="color:#6d6d6d">、</span><span style="color:#6d6d6d">P2</span><span style="color:#6d6d6d">、</span><span style="color:#6d6d6d">P3</span><span style="color:#6d6d6d">,有 </span><span style="color:#ff0000">ROM</span><span style="color:#6d6d6d">,用来存 </span></p>
<p><span style="color:#6d6d6d">放程序,有 </span><span style="color:#6d6d6d">RAM</span><span style="color:#6d6d6d">,用来存放中间结果,此外还有</span><span style="color:#ff0000">定时</span><span style="color:#ff0000">/</span><span style="color:#ff0000">计数器</span><span style="color:#6d6d6d">,</span><span style="color:#ff0000">串行 </span><span style="color:#ff0000">I/O </span><span style="color:#ff0000">口</span><span style="color:#6d6d6d">,</span><span style="color:#ff0000">中断系统</span><span style="color:#6d6d6d">,以及一个内部的</span><span style="color:#ff0000">时钟电路</span><span style="color:#6d6d6d">。在单 </span></p>
<p><span style="color:#6d6d6d">片机中有一些独立的存储单元是用来控制这些器件的,被称之为</span><span style="color:#ff0000">特殊功能寄存器(</span><span style="color:#ff0000">SFR</span><span style="color:#ff0000">)。</span><span style="color:#6d6d6d">这样的特殊功能寄存器 </span><span style="color:#6d6d6d">51 </span><span style="color:#6d6d6d">单 </span></p>
<p><span style="color:#6d6d6d">片机共有 </span><span style="color:#6d6d6d">21 </span><span style="color:#6d6d6d">个并且都是可寻址的列表如下</span><span style="color:#6d6d6d">(</span><span style="color:#6d6d6d">其中带</span><span style="color:#6d6d6d">*</span><span style="color:#6d6d6d">号的为 </span><span style="color:#6d6d6d">52 </span><span style="color:#6d6d6d">系列所增加的特殊功能寄存器): </span></p>
<p><span style="color:#000000"><strong>MCS-51 单片机的特殊功能寄存器 </strong></span></p>
<p><span style="color:#000000">符号 </span></p>
<p><span style="color:#000000">地址 </span></p>
<p><span style="color:#000000">功能介绍 </span></p>
<p><span style="color:#1463c4"><strong>B </strong></span></p>
<p><span style="color:#6d6d6d">F0H B 寄存器 </span></p>
<p><span style="color:#1463c4"><strong>ACC </strong></span></p>
<p><span style="color:#6d6d6d">E0H 累加器 </span></p>
<p><span style="color:#1463c4"><strong>PSW </strong></span></p>
<p><span style="color:#6d6d6d">D0H 程序状态字 </span></p>
<p><span style="color:#000000"><strong>TH2* </strong></span></p>
<p><span style="color:#000000">CDH 定时器/计数器 2(高 8 位) </span></p>
<p><span style="color:#000000"><strong>TL2* </strong></span></p>
<p><span style="color:#000000">CCH 定时器/计数器 2(低 8 位) </span></p>
<p><span style="color:#000000"><strong>RCAP2H* </strong></span></p>
<p><span style="color:#000000">CBH 外部输入(P1.1)计数器/自动再装入模式时初值寄存器高八位 </span></p>
<p><span style="color:#000000"><strong>RCAP2L* </strong></span></p>
<p><span style="color:#000000">CAH 外部输入(P1.1)计数器/自动再装入模式时初值寄存器低八位 </span></p>
<p><span style="color:#1463c4"><strong>T2CON* </strong></span></p>
<p><span style="color:#000000">C8H T2 定时器/计数器控制寄存器 </span></p>
<p><span style="color:#1463c4"><strong>IP </strong></span></p>
<p><span style="color:#6d6d6d">B8H 中断优先级控制寄存器 </span></p>
<p><span style="color:#1463c4"><strong>P3 </strong></span></p>
<p><span style="color:#6d6d6d">B0H P3 口锁存器 </span></p>
<p><span style="color:#1463c4"><strong>IE </strong></span></p>
<p><span style="color:#6d6d6d">A8H 中断允许控制寄存器 </span></p>
<p><span style="color:#1463c4"><strong>P2 </strong></span></p>
<p><span style="color:#6d6d6d">A0H P2 口锁存器 </span></p>
<p><span style="color:#6d6d6d"><strong>SBUF </strong></span></p>
<p><span style="color:#6d6d6d">99H 串行口锁存器 </span></p>
<p><span style="color:#1463c4"><strong>SCON </strong></span></p>
<p><span style="color:#6d6d6d">98H 串行口控制寄存器 </span></p>
<p><span style="color:#1463c4"><strong>P1 </strong></span></p>
<p><span style="color:#6d6d6d">90H P1 口锁存器 </span></p>
<p><span style="color:#6d6d6d"><strong>TH1 </strong></span></p>
<p><span style="color:#6d6d6d">8DH 定时器/计数器 1(高 8 位) </span></p>
<p><span style="color:#6d6d6d"><strong>TH0 </strong></span></p>
<p><span style="color:#6d6d6d">8CH 定时器/计数器 1(低 8 位) </span></p>
<p><span style="color:#6d6d6d"><strong>TL1 </strong></span></p>
<p><span style="color:#6d6d6d">8BH 定时器/计数器 0(高 8 位) </span></p>
<p><span style="color:#6d6d6d"><strong>TL0 </strong></span></p>
<p><span style="color:#6d6d6d">8AH 定时器/计数器 0(低 8 位) </span></p>
<p><span style="color:#1463c4"><strong>TMOD </strong></span></p>
<p><span style="color:#6d6d6d">89H T0、T1 定时器/计数器方式控制寄存器 </span></p>
<p><span style="color:#1463c4"><strong>TCON </strong></span></p>
<p><span style="color:#6d6d6d">88H T0、T1 定时器/计数器控制寄存器 </span></p>
<p><span style="color:#6d6d6d"><strong>DPH </strong></span></p>
<p><span style="color:#6d6d6d">83H 数据地址指针(高 8 位) </span></p>
<p><span style="color:#6d6d6d"><strong>DPL </strong></span></p>
<p><span style="color:#6d6d6d">82H 数据地址指针(低 8 位)</span><span style="color:#6d6d6d"><strong>SP </strong></span></p>
<p><span style="color:#6d6d6d">81H 堆栈指针 </span></p>
<p><span style="color:#1463c4"><strong>P0 </strong></span></p>
<p><span style="color:#6d6d6d">80H P0 口锁存器 </span></p>
<p><span style="color:#1463c4"><strong>PCON </strong></span></p>
<p><span style="color:#6d6d6d">87H 电源控制寄存器 </span></p>
<p><span style="color:#6d6d6d">分别说明如下: </span></p>
<p><span style="color:#6d6d6d"><strong>1</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>ACC---</strong></span><span style="color:#6d6d6d"><strong>是累加器,通常用 </strong></span><span style="color:#6d6d6d"><strong>A </strong></span><span style="color:#6d6d6d"><strong>表示 </strong></span></p>
<p><span style="color:#6d6d6d">这是个什么东西,可不能从名字上理解,它是一个寄存器,而不是一个做加法的东西,为什么给它这么一个名字呢? </span></p>
<p><span style="color:#6d6d6d">或许是因为在运算器做运算时其中一个数一定是在 </span><span style="color:#6d6d6d">ACC </span><span style="color:#6d6d6d">中的缘故吧。它的名字特殊,身份也特殊,稍后在中篇中我们将 </span></p>
<p><span style="color:#6d6d6d">学到指令,可以发现,所有的运算类指令都离不开它。自身带有全零标志 </span><span style="color:#6d6d6d">Z</span><span style="color:#6d6d6d">,若 </span><span style="color:#6d6d6d">A</span><span style="color:#6d6d6d">=</span><span style="color:#6d6d6d">0 </span><span style="color:#6d6d6d">则 </span><span style="color:#6d6d6d">Z</span><span style="color:#6d6d6d">=</span><span style="color:#6d6d6d">1</span><span style="color:#6d6d6d">;若 </span><span style="color:#6d6d6d">A≠0 </span><span style="color:#6d6d6d">则 </span><span style="color:#6d6d6d">z</span><span style="color:#6d6d6d">=</span><span style="color:#6d6d6d">0</span><span style="color:#6d6d6d">。该标志 </span></p>
<p><span style="color:#6d6d6d">常用作程序分枝转移的判断条件。 </span></p>
<p><span style="color:#6d6d6d"><strong>2</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>B--</strong></span><span style="color:#6d6d6d"><strong>一个寄存器 </strong></span></p>
<p><span style="color:#6d6d6d">在做乘、除法时放乘数或除数,不做乘除法时,随你怎么用。 </span></p>
<p><span style="color:#6d6d6d"><strong>3</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>PSW-----</strong></span><span style="color:#6d6d6d"><strong>程序状态字。 </strong></span></p>
<p><span style="color:#6d6d6d">这是一个很重要的东西,里面放了 </span><span style="color:#6d6d6d">CPU </span><span style="color:#6d6d6d">工作时的很多状态,借此,我们可以了解 </span><span style="color:#6d6d6d">CPU </span><span style="color:#6d6d6d">的当前状态,并作出相应的 </span></p>
<p><span style="color:#6d6d6d">处理。它的各位功能请看下表: </span></p>
<p><span style="color:#ffffff"><strong>PSW 程序状态字 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>D7 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>D6 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>D5 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>D4 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>D3 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>D2 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>D1 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>D0 </strong></span></p>
<p><span style="color:#6d6d6d">CY </span></p>
<p><span style="color:#6d6d6d">AC </span></p>
<p><span style="color:#6d6d6d">F0 </span></p>
<p><span style="color:#6d6d6d">RS1 </span></p>
<p><span style="color:#6d6d6d">RS0 </span></p>
<p><span style="color:#6d6d6d">OV </span></p>
<p><span style="color:#6d6d6d">P </span></p>
<p><span style="color:#6d6d6d">下面我们逐一介绍各位的用途 </span></p>
<p><span style="color:#6d6d6d"><strong>CY</strong></span><span style="color:#6d6d6d"><strong>:进位标志。 </strong></span></p>
<p><span style="color:#6d6d6d">8051 </span><span style="color:#6d6d6d">中的运算器是一种 </span><span style="color:#6d6d6d">8 </span><span style="color:#6d6d6d">位的运算器,我们知道,</span><span style="color:#6d6d6d">8 </span><span style="color:#6d6d6d">位运算器只能表示到 </span><span style="color:#6d6d6d">0-255</span><span style="color:#6d6d6d">,如果做加法的话,两数相加可能 </span></p>
<p><span style="color:#6d6d6d">会超过 </span><span style="color:#6d6d6d">255</span><span style="color:#6d6d6d">,这样最高位就会丢失,造成运算的错误,怎么办?最高位就进到这里来。这样就没事了。有进、借位,</span><span style="color:#6d6d6d">CY </span></p>
<p><span style="color:#6d6d6d">=</span><span style="color:#6d6d6d">1</span><span style="color:#6d6d6d">;无进、借位,</span><span style="color:#6d6d6d">CY</span><span style="color:#6d6d6d">=</span><span style="color:#6d6d6d">0 </span></p>
<p><span style="color:#6d6d6d">例:</span><span style="color:#6d6d6d">78H+97H</span><span style="color:#6d6d6d">(</span><span style="color:#6d6d6d">01111000+10010111</span><span style="color:#6d6d6d">) </span></p>
<p><span style="color:#6d6d6d"><strong>AC</strong></span><span style="color:#6d6d6d"><strong>:辅助进、借位</strong></span><span style="color:#6d6d6d"><strong>(</strong></span><span style="color:#6d6d6d"><strong>高半字节与低半字节间的进、借位</strong></span><span style="color:#6d6d6d"><strong>)</strong></span><span style="color:#6d6d6d"><strong>。 </strong></span></p>
<p><span style="color:#6d6d6d">例:</span><span style="color:#6d6d6d">57H+3AH</span><span style="color:#6d6d6d">(</span><span style="color:#6d6d6d">01010111+00111010</span><span style="color:#6d6d6d">) </span></p>
<p><span style="color:#6d6d6d"><strong>F0</strong></span><span style="color:#6d6d6d"><strong>:用户标志位 </strong></span></p>
<p><span style="color:#6d6d6d">由用户(编程人员)决定什么时候用,什么时候不用。 </span></p>
<p><span style="color:#6d6d6d"><strong>RS1</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>RS0</strong></span><span style="color:#6d6d6d"><strong>:工作寄存器组选择位 </strong></span></p>
<p><span style="color:#6d6d6d">通过修改 </span><span style="color:#6d6d6d">PSW </span><span style="color:#6d6d6d">中的 </span><span style="color:#6d6d6d">RS1</span><span style="color:#6d6d6d">、</span><span style="color:#6d6d6d">RS0 </span><span style="color:#6d6d6d">两位的状态,就能任选一个工作寄存器区。这个特点提高了 </span><span style="color:#6d6d6d">MCS-51 </span><span style="color:#6d6d6d">现场保护和 </span></p>
<p><span style="color:#6d6d6d">现场恢复的速度。对于提高 </span><span style="color:#6d6d6d">CPU </span><span style="color:#6d6d6d">的工作效率和响应中断的速度是很有利的。若在一个实际的应用系统中,不需要四组工 </span></p>
<p><span style="color:#6d6d6d">作寄存器,那么这个区域中多余单元可以作为一般的数据缓冲器使用。</span><span style="color:#ffffff"><strong>工作寄存器区选择 </strong></span></p>
<p><span style="color:#000000"><strong>RS1 </strong></span></p>
<p><span style="color:#000000"><strong>RS0 </strong></span></p>
<p><span style="color:#000000"><strong>当前使用的工作寄存器区 R0~R7 </strong></span></p>
<p><span style="color:#000000">0 </span></p>
<p><span style="color:#000000">0 </span></p>
<p><span style="color:#000000">0 区(00~07H) </span></p>
<p><span style="color:#000000">0 </span></p>
<p><span style="color:#000000">1 </span></p>
<p><span style="color:#000000">1 区(08~0Fh) </span></p>
<p><span style="color:#000000">1 </span></p>
<p><span style="color:#000000">0 </span></p>
<p><span style="color:#000000">2 区(10~17h) </span></p>
<p><span style="color:#000000">1 </span></p>
<p><span style="color:#000000">1 </span></p>
<p><span style="color:#000000">3 区(18~1Fh) </span></p>
<p><span style="color:#6d6d6d"><strong>0V</strong></span><span style="color:#6d6d6d"><strong>:溢出标志位 </strong></span></p>
<p><span style="color:#6d6d6d">运算结果按补码运算理解。有溢出,</span><span style="color:#6d6d6d">OV=1</span><span style="color:#6d6d6d">;无溢出,</span><span style="color:#6d6d6d">OV</span><span style="color:#6d6d6d">=</span><span style="color:#6d6d6d">0</span><span style="color:#6d6d6d">。什么是溢出我们后面的章节会讲到。 </span></p>
<p><span style="color:#6d6d6d"><strong>P</strong></span><span style="color:#6d6d6d"><strong>:奇偶校验位 </strong></span></p>
<p><span style="color:#6d6d6d">它用来表示 </span><span style="color:#6d6d6d">ALU </span><span style="color:#6d6d6d">运算结果中二进制数位</span><span style="color:#6d6d6d">“1”</span><span style="color:#6d6d6d">的个数的奇偶性。若为奇数,则 </span><span style="color:#6d6d6d">P=1</span><span style="color:#6d6d6d">,否则为 </span><span style="color:#6d6d6d">0</span><span style="color:#6d6d6d">。运算结果有奇数个 </span><span style="color:#6d6d6d">1</span><span style="color:#6d6d6d">, </span></p>
<p><span style="color:#6d6d6d">P</span><span style="color:#6d6d6d">=</span><span style="color:#6d6d6d">1</span><span style="color:#6d6d6d">;运算结果有偶数个 </span><span style="color:#6d6d6d">1</span><span style="color:#6d6d6d">,</span><span style="color:#6d6d6d">P</span><span style="color:#6d6d6d">=</span><span style="color:#6d6d6d">0</span><span style="color:#6d6d6d">。 </span></p>
<p><span style="color:#6d6d6d">例:某运算结果是 </span><span style="color:#6d6d6d">78H</span><span style="color:#6d6d6d">(</span><span style="color:#6d6d6d">01111000</span><span style="color:#6d6d6d">),显然 </span><span style="color:#6d6d6d">1 </span><span style="color:#6d6d6d">的个数为偶数,所以 </span><span style="color:#6d6d6d">P=0</span><span style="color:#6d6d6d">。 </span></p>
<p><span style="color:#6d6d6d"><strong>4</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>DPTR</strong></span><span style="color:#6d6d6d"><strong>(</strong></span><span style="color:#6d6d6d"><strong>DPH</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>DPL</strong></span><span style="color:#6d6d6d"><strong>)</strong></span><span style="color:#6d6d6d"><strong>--------</strong></span><span style="color:#6d6d6d"><strong>数据指针 </strong></span></p>
<p><span style="color:#6d6d6d">可以用它来访问外部数据存储器中的任一单元,如果不用,也可以作为通用寄存器来用,由我们自已决定如何使用。 </span></p>
<p><span style="color:#6d6d6d">分成 </span><span style="color:#6d6d6d">DPL(</span><span style="color:#6d6d6d">低 </span><span style="color:#6d6d6d">8 </span><span style="color:#6d6d6d">位</span><span style="color:#6d6d6d">)</span><span style="color:#6d6d6d">和 </span><span style="color:#6d6d6d">DPH(</span><span style="color:#6d6d6d">高 </span><span style="color:#6d6d6d">8 </span><span style="color:#6d6d6d">位</span><span style="color:#6d6d6d">)</span><span style="color:#6d6d6d">两个寄存器。用来存放 </span><span style="color:#6d6d6d">16 </span><span style="color:#6d6d6d">位地址值,以便用间接寻址或变址寻址的方式对片外数据 </span></p>
<p><span style="color:#6d6d6d">RAM </span><span style="color:#6d6d6d">或程序存储器作 </span><span style="color:#6d6d6d">64K </span><span style="color:#6d6d6d">字节范围内的数据操作。 </span></p>
<p><span style="color:#6d6d6d"><strong>5</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>P0</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>P1</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>P2</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>P3--------</strong></span><span style="color:#6d6d6d"><strong>输入输出口(</strong></span><span style="color:#6d6d6d"><strong>I/O</strong></span><span style="color:#6d6d6d"><strong>)寄存器 </strong></span></p>
<p><span style="color:#6d6d6d">这个我们已经知道,是四个并行输入</span><span style="color:#6d6d6d">/</span><span style="color:#6d6d6d">输出口(</span><span style="color:#6d6d6d">I/O</span><span style="color:#6d6d6d">)的寄存器。它里面的内容对应着管脚的输出。 </span></p>
<p><span style="color:#6d6d6d"><strong>6</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>IE-----</strong></span><span style="color:#6d6d6d"><strong>中断充许寄存器 </strong></span></p>
<p><span style="color:#6d6d6d">可按位寻址,地址:</span><span style="color:#6d6d6d">A8H </span></p>
<p><span style="color:#ffffff"><strong>IE 中断允许寄存器 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B7 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B6 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B5 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B4 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B3 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B2 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B1 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B0 </strong></span></p>
<p><span style="color:#6d6d6d">EA </span></p>
<p><span style="color:#6d6d6d">- </span></p>
<p><span style="color:#6d6d6d">ET2 </span></p>
<p><span style="color:#6d6d6d">ES </span></p>
<p><span style="color:#6d6d6d">ET1 </span></p>
<p><span style="color:#6d6d6d">EX1 </span></p>
<p><span style="color:#6d6d6d">ET0 </span></p>
<p><span style="color:#6d6d6d">EX0 </span></p>
<p><span style="color:#000000"> </span><span style="color:#9a9a9a"><strong>EA </strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IE.7</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:</span><span style="color:#9a9a9a">EA=0 </span><span style="color:#9a9a9a">时,所有中断禁止(即不产生中断);</span><span style="color:#9a9a9a">EA=1 </span><span style="color:#9a9a9a">时,各中断的产生由个别的允许位决定 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>- </strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IE.6</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:保留 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>ET2</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IE.5</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:定时 </span><span style="color:#9a9a9a">2 </span><span style="color:#9a9a9a">溢出中断</span><span style="color:#000000">允许</span><span style="color:#9a9a9a">(</span><span style="color:#9a9a9a">8052 </span><span style="color:#9a9a9a">用) </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>ES </strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IE.4</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:串行口中断允许(</span><span style="color:#9a9a9a">ES=1 </span><span style="color:#9a9a9a">允许,</span><span style="color:#9a9a9a">ES=0 </span><span style="color:#9a9a9a">禁止) </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>ET1</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IE.3</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:定时 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">中断允许 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>EX1</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IE.2</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:外中断 </span><span style="color:#9a9a9a">INT1 </span><span style="color:#9a9a9a">中断允许 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>ET0</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IE.1</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:定时器 </span><span style="color:#9a9a9a">0 </span><span style="color:#9a9a9a">中断允许 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>EX0</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IE.0</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:外部中断 </span><span style="color:#9a9a9a">INT0 </span><span style="color:#9a9a9a">的中断允许 </span></p>
<p><span style="color:#6d6d6d"><strong>7</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>IP-----</strong></span><span style="color:#6d6d6d"><strong>中断优先级控制寄存器 </strong></span></p>
<p><span style="color:#6d6d6d">可按位寻址,地址位 </span><span style="color:#6d6d6d">B8H </span></p>
<p><span style="color:#ffffff"><strong>IP 中断优先级控制寄存器 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B7 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B6 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B5 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B4 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B3 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B2 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B1 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B0 </strong></span></p>
<p><span style="color:#6d6d6d">- </span></p>
<p><span style="color:#6d6d6d">- </span></p>
<p><span style="color:#6d6d6d">PT2 </span></p>
<p><span style="color:#6d6d6d">PS </span></p>
<p><span style="color:#6d6d6d">PT1 </span></p>
<p><span style="color:#6d6d6d">PX1 </span></p>
<p><span style="color:#6d6d6d">PT0 </span></p>
<p><span style="color:#6d6d6d">PX0 </span></p>
<p><span style="color:#000000"> </span><span style="color:#9a9a9a"><strong>- </strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IP.7</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:保留 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>- </strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IP.6</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:保留 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>PT2</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IP.5</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:定时 </span><span style="color:#9a9a9a">2 </span><span style="color:#9a9a9a">中断优先(</span><span style="color:#9a9a9a">8052 </span><span style="color:#9a9a9a">用) </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>PS </strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IP.4</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:串行口中断优先</span><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>PT1</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IP.3</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:定时 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">中断优先 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>PX1</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IP.2</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:外中断 </span><span style="color:#9a9a9a">INT1 </span><span style="color:#9a9a9a">中断优先 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>PT0</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IP.1</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:定时器 </span><span style="color:#9a9a9a">0 </span><span style="color:#9a9a9a">中断优先 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>PX0</strong></span><span style="color:#9a9a9a"><strong>(</strong></span><span style="color:#9a9a9a"><strong>IP.0</strong></span><span style="color:#9a9a9a"><strong>)</strong></span><span style="color:#9a9a9a">:外部中断 </span><span style="color:#9a9a9a">INT0 </span><span style="color:#9a9a9a">的中断优先 </span></p>
<p><span style="color:#6d6d6d"><strong>8</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>TMOD-----</strong></span><span style="color:#6d6d6d"><strong>定时器控制寄存器 </strong></span></p>
<p><span style="color:#6d6d6d">不按位寻址,地址 </span><span style="color:#6d6d6d">89H </span></p>
<p><span style="color:#ffffff"><strong>TMOD 定时器控制寄存器 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B7 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B6 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B5 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B4 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B3 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B2 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B1 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B0 </strong></span></p>
<p><span style="color:#6d6d6d">GATE </span></p>
<p><span style="color:#6d6d6d">C/T </span></p>
<p><span style="color:#6d6d6d">M1 </span></p>
<p><span style="color:#6d6d6d">M0 </span></p>
<p><span style="color:#6d6d6d">GATE </span></p>
<p><span style="color:#6d6d6d">C/T </span></p>
<p><span style="color:#6d6d6d">M1 </span></p>
<p><span style="color:#6d6d6d">M0 </span></p>
<p><span style="color:#000000"> </span><span style="color:#9a9a9a"><strong>GATE </strong></span><span style="color:#9a9a9a">:定时操作开关控制位,当 </span><span style="color:#9a9a9a">GATE=1 </span><span style="color:#9a9a9a">时,</span><span style="color:#9a9a9a">INT0 </span><span style="color:#9a9a9a">或 </span><span style="color:#9a9a9a">INT1 </span><span style="color:#9a9a9a">引脚为高电平,同时 </span><span style="color:#9a9a9a">TCON </span><span style="color:#9a9a9a">中的 </span><span style="color:#9a9a9a">TR0 </span><span style="color:#9a9a9a">或 </span><span style="color:#9a9a9a">TR1 </span><span style="color:#9a9a9a">控制位为 </span><span style="color:#9a9a9a">1 </span></p>
<p><span style="color:#9a9a9a">时,计时</span><span style="color:#9a9a9a">/</span><span style="color:#9a9a9a">计数器 </span><span style="color:#9a9a9a">0 </span><span style="color:#9a9a9a">或 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">才开始工作。若 </span><span style="color:#9a9a9a">GATE=0</span><span style="color:#9a9a9a">,则只要将 </span><span style="color:#9a9a9a">TR0 </span><span style="color:#9a9a9a">或 </span><span style="color:#9a9a9a">TR1 </span><span style="color:#9a9a9a">控制位设为 </span><span style="color:#9a9a9a">1</span><span style="color:#9a9a9a">,计时</span><span style="color:#9a9a9a">/</span><span style="color:#9a9a9a">计数器 </span><span style="color:#9a9a9a">0 </span><span style="color:#9a9a9a">或 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">就开始工作。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>C/T </strong></span><span style="color:#9a9a9a">:定时器或计数器功能的选择位。</span><span style="color:#9a9a9a">C/T=1 </span><span style="color:#9a9a9a">为计数器,通过外部引脚 </span><span style="color:#9a9a9a">T0 </span><span style="color:#9a9a9a">或 </span><span style="color:#9a9a9a">T1 </span><span style="color:#9a9a9a">输入计数脉冲。</span><span style="color:#9a9a9a">C/T=0 </span><span style="color:#9a9a9a">时为定时器,由 </span></p>
<p><span style="color:#9a9a9a">内部系统时钟提供计时工作脉冲。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a"><strong>M1 </strong></span><span style="color:#9a9a9a"><strong>、</strong></span><span style="color:#9a9a9a"><strong>M0</strong></span><span style="color:#9a9a9a">:</span><span style="color:#9a9a9a">T0</span><span style="color:#9a9a9a">、</span><span style="color:#9a9a9a">T1 </span><span style="color:#9a9a9a">工作模式选择位 </span></p>
<p><span style="color:#ffffff"><strong>M1 、M0:T0、T1 工作模式选择位 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>M1 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>M0 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>工作模式 </strong></span></p>
<p><span style="color:#6d6d6d">0 </span></p>
<p><span style="color:#6d6d6d">0 </span></p>
<p><span style="color:#6d6d6d">方式 0,13 位计数/计时器 </span></p>
<p><span style="color:#6d6d6d">0 </span></p>
<p><span style="color:#6d6d6d">1 </span></p>
<p><span style="color:#6d6d6d">方式,1,16 位计数/计时器 </span></p>
<p><span style="color:#6d6d6d">1 </span></p>
<p><span style="color:#6d6d6d">0 </span></p>
<p><span style="color:#6d6d6d">方式 2,8 位自动加载计数/计时器 </span></p>
<p><span style="color:#6d6d6d">1 </span></p>
<p><span style="color:#6d6d6d">1 </span></p>
<p><span style="color:#6d6d6d">方式 3,仅适用于 T0,定时器 0 分为两个独立的 8 位定时器/计数器 </span></p>
<p><span style="color:#6d6d6d">TH0 及 TL0,T1 在方式 3 时停止工作 </span></p>
<p><span style="color:#6d6d6d"><strong>9</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>TCON-----</strong></span><span style="color:#6d6d6d"><strong>定时器控制寄存器 </strong></span></p>
<p><span style="color:#6d6d6d">可按位寻址,地址位 </span><span style="color:#6d6d6d">88H </span></p>
<p><span style="color:#ffffff"><strong>TCON 定时器控制寄存器 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B7 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B6 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B5 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B4 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B3 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B2 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B1 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B0 </strong></span></p>
<p><span style="color:#6d6d6d">TF1 </span></p>
<p><span style="color:#6d6d6d">TR1 </span></p>
<p><span style="color:#6d6d6d">TF0 </span></p>
<p><span style="color:#6d6d6d">TR0 </span></p>
<p><span style="color:#6d6d6d">IE1 </span></p>
<p><span style="color:#6d6d6d">IT1 </span></p>
<p><span style="color:#6d6d6d">IE0 </span></p>
<p><span style="color:#6d6d6d">IT0 </span></p>
<p><span style="color:#000000"> </span><span style="color:#9a9a9a">TF1</span><span style="color:#9a9a9a">:定时器 </span><span style="color:#9a9a9a">T1 </span><span style="color:#9a9a9a">溢出标志,可由程序查询和清零,</span><span style="color:#9a9a9a">TF1 </span><span style="color:#9a9a9a">也是中断请求源,当 </span><span style="color:#9a9a9a">CPU </span><span style="color:#9a9a9a">响应 </span><span style="color:#9a9a9a">T1 </span><span style="color:#9a9a9a">中断时由硬件清零。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">TF0</span><span style="color:#9a9a9a">:定时器 </span><span style="color:#9a9a9a">T0 </span><span style="color:#9a9a9a">溢出标志,可由程序查询和清零,</span><span style="color:#9a9a9a">TF0 </span><span style="color:#9a9a9a">也是中断请求源,当 </span><span style="color:#9a9a9a">CPU </span><span style="color:#9a9a9a">响应 </span><span style="color:#9a9a9a">T0 </span><span style="color:#9a9a9a">中断时由硬件清零。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">TR1</span><span style="color:#9a9a9a">:</span><span style="color:#9a9a9a">T1 </span><span style="color:#9a9a9a">充许计数控制位,为 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">时充许 </span><span style="color:#9a9a9a">T1 </span><span style="color:#9a9a9a">计数。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">TR0</span><span style="color:#9a9a9a">:</span><span style="color:#9a9a9a">T0 </span><span style="color:#9a9a9a">充许计数控制位,为 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">时充许 </span><span style="color:#9a9a9a">T0 </span><span style="color:#9a9a9a">计数。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">IE1</span><span style="color:#9a9a9a">:外部中断 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">请示源(</span><span style="color:#9a9a9a">INT1</span><span style="color:#9a9a9a">,</span><span style="color:#9a9a9a">P3.3</span><span style="color:#9a9a9a">)标志。</span><span style="color:#9a9a9a">IE1</span><span style="color:#9a9a9a">=</span><span style="color:#9a9a9a">1</span><span style="color:#9a9a9a">,外部中断 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">正在向 </span><span style="color:#9a9a9a">CPU </span><span style="color:#9a9a9a">请求中断,当 </span><span style="color:#9a9a9a">CPU </span><span style="color:#9a9a9a">响应该中断时由硬 </span></p>
<p><span style="color:#9a9a9a">件清</span><span style="color:#9a9a9a">“0”IE1</span><span style="color:#9a9a9a">(边沿触发方式)。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">IT1</span><span style="color:#9a9a9a">:外部中断源 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">触发方式控制位。</span><span style="color:#9a9a9a">IT1</span><span style="color:#9a9a9a">=</span><span style="color:#9a9a9a">0</span><span style="color:#9a9a9a">,外部中断 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">程控为电平触发方式,当 </span><span style="color:#9a9a9a">INT1</span><span style="color:#9a9a9a">(</span><span style="color:#9a9a9a">P3.3</span><span style="color:#9a9a9a">)输入低电平时,置位 </span></p>
<p><span style="color:#9a9a9a">IE1</span><span style="color:#9a9a9a">。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">IE0</span><span style="color:#9a9a9a">:外部中断 </span><span style="color:#9a9a9a">0 </span><span style="color:#9a9a9a">请示源(</span><span style="color:#9a9a9a">INT0</span><span style="color:#9a9a9a">,</span><span style="color:#9a9a9a">P3.2</span><span style="color:#9a9a9a">)标志。</span><span style="color:#9a9a9a">IE0</span><span style="color:#9a9a9a">=</span><span style="color:#9a9a9a">1</span><span style="color:#9a9a9a">,外部中断 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">正在向 </span><span style="color:#9a9a9a">CPU </span><span style="color:#9a9a9a">请求中断,当 </span><span style="color:#9a9a9a">CPU </span><span style="color:#9a9a9a">响应该中断时由硬 </span></p>
<p><span style="color:#9a9a9a">件清</span><span style="color:#9a9a9a">“0”IE0</span><span style="color:#9a9a9a">(边沿触发方式)。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">IT0</span><span style="color:#9a9a9a">:外部中断源 </span><span style="color:#9a9a9a">0 </span><span style="color:#9a9a9a">触发方式控制位。</span><span style="color:#9a9a9a">IT0</span><span style="color:#9a9a9a">=</span><span style="color:#9a9a9a">0</span><span style="color:#9a9a9a">,外部中断 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">程控为电平触发方式,当 </span><span style="color:#9a9a9a">INT0</span><span style="color:#9a9a9a">(</span><span style="color:#9a9a9a">P3.2</span><span style="color:#9a9a9a">)输入低电平时,置位 </span></p>
<p><span style="color:#9a9a9a">IE0</span><span style="color:#9a9a9a">。</span><span style="color:#6d6d6d"><strong>10</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>SCON----</strong></span><span style="color:#6d6d6d"><strong>串行通信控制寄存器 </strong></span></p>
<p><span style="color:#6d6d6d">它是一个可寻址的专用寄存器,用于串行数据的通信控制,单元地址是 </span><span style="color:#6d6d6d">98H</span><span style="color:#6d6d6d">,其结构格式如下: </span></p>
<p><span style="color:#ffffff"><strong>SCON 串行通信控制寄存器 </strong></span></p>
<p><span style="color:#000000"><strong>D7 </strong></span></p>
<p><span style="color:#000000"><strong>D6 </strong></span></p>
<p><span style="color:#000000"><strong>D5 </strong></span></p>
<p><span style="color:#000000"><strong>D4 </strong></span></p>
<p><span style="color:#000000"><strong>D3 </strong></span></p>
<p><span style="color:#000000"><strong>D2 </strong></span></p>
<p><span style="color:#000000"><strong>D1 </strong></span></p>
<p><span style="color:#000000"><strong>D0 </strong></span></p>
<p><span style="color:#000000">SM0 </span></p>
<p><span style="color:#000000">SM1 </span></p>
<p><span style="color:#000000">SM2 </span></p>
<p><span style="color:#000000">REN </span></p>
<p><span style="color:#000000">TB8 </span></p>
<p><span style="color:#000000">RB8 </span></p>
<p><span style="color:#000000">TI </span></p>
<p><span style="color:#000000">RI </span></p>
<p><span style="color:#6d6d6d"><strong>(1)SM0</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>SM1</strong></span><span style="color:#6d6d6d">:串行口工作方式控制位。 </span></p>
<p><span style="color:#6d6d6d">SM0</span><span style="color:#6d6d6d">,</span><span style="color:#6d6d6d">SM1 </span><span style="color:#6d6d6d">工作方式 </span></p>
<p><span style="color:#6d6d6d">00 </span><span style="color:#6d6d6d">方式 </span><span style="color:#6d6d6d">0</span><span style="color:#6d6d6d">-波特率由振荡器频率所定:振荡器频率</span><span style="color:#6d6d6d">/12 </span></p>
<p><span style="color:#6d6d6d">01 </span><span style="color:#6d6d6d">方式 </span><span style="color:#6d6d6d">1</span><span style="color:#6d6d6d">-波特率由定时器 </span><span style="color:#6d6d6d">T1 </span><span style="color:#6d6d6d">或 </span><span style="color:#6d6d6d">T2 </span><span style="color:#6d6d6d">的溢出率和 </span><span style="color:#6d6d6d">SMOD </span><span style="color:#6d6d6d">所定:</span><span style="color:#6d6d6d">2 </span><span style="color:#6d6d6d">SMOD </span><span style="color:#6d6d6d">×(T1 </span><span style="color:#6d6d6d">溢出率</span><span style="color:#6d6d6d">)/32 </span></p>
<p><span style="color:#6d6d6d">10 </span><span style="color:#6d6d6d">方式 </span><span style="color:#6d6d6d">2</span><span style="color:#6d6d6d">-波特率由振荡器频率和 </span><span style="color:#6d6d6d">SMOD </span><span style="color:#6d6d6d">所定:</span><span style="color:#6d6d6d">2 </span><span style="color:#6d6d6d">SMOD </span><span style="color:#6d6d6d">×</span><span style="color:#6d6d6d">振荡器频率</span><span style="color:#6d6d6d">/64 </span></p>
<p><span style="color:#6d6d6d">11 </span><span style="color:#6d6d6d">方式 </span><span style="color:#6d6d6d">3</span><span style="color:#6d6d6d">-波特率由定时器 </span><span style="color:#6d6d6d">T1 </span><span style="color:#6d6d6d">或 </span><span style="color:#6d6d6d">T2 </span><span style="color:#6d6d6d">的溢出率和 </span><span style="color:#6d6d6d">SMOD </span><span style="color:#6d6d6d">所定:</span><span style="color:#6d6d6d">2 </span><span style="color:#6d6d6d">SMOD </span><span style="color:#6d6d6d">×(T1 </span><span style="color:#6d6d6d">溢出率</span><span style="color:#6d6d6d">)/32 </span></p>
<p><span style="color:#6d6d6d"><strong>(2)SM2</strong></span><span style="color:#6d6d6d">:多机通信控制位。</span><span style="color:#6d6d6d">< br> </span><span style="color:#6d6d6d">多机通信是工作于方式 </span><span style="color:#6d6d6d">2 </span><span style="color:#6d6d6d">和方式 </span><span style="color:#6d6d6d">3</span><span style="color:#6d6d6d">,</span><span style="color:#6d6d6d">SM2 </span><span style="color:#6d6d6d">位主要用于方式 </span><span style="color:#6d6d6d">2 </span><span style="color:#6d6d6d">和方式 </span><span style="color:#6d6d6d">3</span><span style="color:#6d6d6d">。接收状态, </span></p>
<p><span style="color:#6d6d6d">当串行口工作于方式 </span><span style="color:#6d6d6d">2 </span><span style="color:#6d6d6d">或 </span><span style="color:#6d6d6d">3</span><span style="color:#6d6d6d">,以及 </span><span style="color:#6d6d6d">SM2=1 </span><span style="color:#6d6d6d">时,只有当接收到第 </span><span style="color:#6d6d6d">9 </span><span style="color:#6d6d6d">位数据(</span><span style="color:#6d6d6d">RB8</span><span style="color:#6d6d6d">)为 </span><span style="color:#6d6d6d">1 </span><span style="color:#6d6d6d">时,才把接收到的前 </span><span style="color:#6d6d6d">8 </span><span style="color:#6d6d6d">位数据送入 </span></p>
<p><span style="color:#6d6d6d">SBUF</span><span style="color:#6d6d6d">,且置位 </span><span style="color:#6d6d6d">RI </span><span style="color:#6d6d6d">发出中断申请,否则会将接受到的数据放弃。当 </span><span style="color:#6d6d6d">SM2=0 </span><span style="color:#6d6d6d">时,就不管第位数据是 </span><span style="color:#6d6d6d">0 </span><span style="color:#6d6d6d">还是 </span><span style="color:#6d6d6d">1</span><span style="color:#6d6d6d">,都难得数据 </span></p>
<p><span style="color:#6d6d6d">送入 </span><span style="color:#6d6d6d">SBUF</span><span style="color:#6d6d6d">,并发出中断申请。 </span></p>
<p><span style="color:#6d6d6d">工作于方式 </span><span style="color:#6d6d6d">0 </span><span style="color:#6d6d6d">时,</span><span style="color:#6d6d6d">SM2 </span><span style="color:#6d6d6d">必须为 </span><span style="color:#6d6d6d">0</span><span style="color:#6d6d6d">。 </span></p>
<p><span style="color:#6d6d6d"><strong>(3)REN</strong></span><span style="color:#6d6d6d">:允许接收位。</span><span style="color:#6d6d6d">< br> REN </span><span style="color:#6d6d6d">用于控制数据接收的允许和禁止,</span><span style="color:#6d6d6d">REN=1 </span><span style="color:#6d6d6d">时,允许接收,</span><span style="color:#6d6d6d">REN=0 </span><span style="color:#6d6d6d">时,禁止接收。 </span></p>
<p><span style="color:#6d6d6d"><strong>(4)TB8</strong></span><span style="color:#6d6d6d">:发送接收数据位 </span><span style="color:#6d6d6d">8</span><span style="color:#6d6d6d">。</span><span style="color:#6d6d6d">< br> </span><span style="color:#6d6d6d">在方式 </span><span style="color:#6d6d6d">2 </span><span style="color:#6d6d6d">和方式 </span><span style="color:#6d6d6d">3 </span><span style="color:#6d6d6d">中,</span><span style="color:#6d6d6d">TB8 </span><span style="color:#6d6d6d">是要发送的</span><span style="color:#6d6d6d">——</span><span style="color:#6d6d6d">即第 </span><span style="color:#6d6d6d">9 </span><span style="color:#6d6d6d">位数据位。在多机通信中同样亦 </span></p>
<p><span style="color:#6d6d6d">要传输这一位,并且它代表传输的地址还是数据,</span><span style="color:#6d6d6d">TB8=0 </span><span style="color:#6d6d6d">为数据,</span><span style="color:#6d6d6d">TB8=1 </span><span style="color:#6d6d6d">时为地址。 </span></p>
<p><span style="color:#6d6d6d"><strong>(5)RB8</strong></span><span style="color:#6d6d6d">:接收数据位 </span><span style="color:#6d6d6d">8</span><span style="color:#6d6d6d">。 </span></p>
<p><span style="color:#6d6d6d">在方式 </span><span style="color:#6d6d6d">2 </span><span style="color:#6d6d6d">和方式 </span><span style="color:#6d6d6d">3 </span><span style="color:#6d6d6d">中,</span><span style="color:#6d6d6d">RB8 </span><span style="color:#6d6d6d">存放接收到的第 </span><span style="color:#6d6d6d">9 </span><span style="color:#6d6d6d">位数据,用以识别接收到的数据特征。 </span></p>
<p><span style="color:#6d6d6d"><strong>(6)TI</strong></span><span style="color:#6d6d6d">:发送中断标志位。 </span></p>
<p><span style="color:#6d6d6d">可寻址标志位。方式 </span><span style="color:#6d6d6d">0 </span><span style="color:#6d6d6d">时,发送完第 </span><span style="color:#6d6d6d">8 </span><span style="color:#6d6d6d">位数据后,由硬件置位,其它方式下,在发送或停止位之前由硬件置位,因此, </span></p>
<p><span style="color:#6d6d6d">TI=1 </span><span style="color:#6d6d6d">表示帧发送结束,</span><span style="color:#6d6d6d">TI </span><span style="color:#6d6d6d">可由软件清</span><span style="color:#6d6d6d">“0”</span><span style="color:#6d6d6d">。 </span></p>
<p><span style="color:#6d6d6d"><strong>(7)RI</strong></span><span style="color:#6d6d6d">:接收中断标志位。 </span></p>
<p><span style="color:#6d6d6d">可寻址标志位。接收完第 </span><span style="color:#6d6d6d">8 </span><span style="color:#6d6d6d">位数据后,该位由硬件置位,在其他工作方式下,该位由硬件置位,</span><span style="color:#6d6d6d">RI=1 </span><span style="color:#6d6d6d">表示帧接收完成。 </span></p>
<p><span style="color:#6d6d6d"><strong>11</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>PCON-----</strong></span><span style="color:#6d6d6d"><strong>电源管理寄存器 </strong></span></p>
<p><span style="color:#6d6d6d">PCON </span><span style="color:#6d6d6d">主要是为 </span><span style="color:#6d6d6d">CHMOS </span><span style="color:#6d6d6d">型单片机的电源控制而设置的专用寄存器,单元地址是 </span><span style="color:#6d6d6d">87H</span><span style="color:#6d6d6d">,其结构格式如下: </span></p>
<p><span style="color:#ffffff"><strong>PCON 电源管理寄存器结构 </strong></span></p>
<p><span style="color:#000000"><strong>D7 </strong></span></p>
<p><span style="color:#000000"><strong>D6 </strong></span></p>
<p><span style="color:#000000"><strong>D5 </strong></span></p>
<p><span style="color:#000000"><strong>D4 </strong></span></p>
<p><span style="color:#000000"><strong>D3 </strong></span></p>
<p><span style="color:#000000"><strong>D2 </strong></span></p>
<p><span style="color:#000000"><strong>D1 </strong></span></p>
<p><span style="color:#000000"><strong>D0 </strong></span></p>
<p><span style="color:#000000">SMOD </span></p>
<p><span style="color:#000000">- </span></p>
<p><span style="color:#000000">- </span></p>
<p><span style="color:#000000">- </span></p>
<p><span style="color:#000000">GF1 </span></p>
<p><span style="color:#000000">GF0 </span></p>
<p><span style="color:#000000">PD </span></p>
<p><span style="color:#000000">IDL </span></p>
<p><span style="color:#6d6d6d">在 </span><span style="color:#6d6d6d">CHMOS </span><span style="color:#6d6d6d">型单片机中,除 </span><span style="color:#6d6d6d">SMOD </span><span style="color:#6d6d6d">位外,其他位均为虚设的,</span><span style="color:#6d6d6d">SMOD </span><span style="color:#6d6d6d">是串行口波特率倍增位,当 </span><span style="color:#6d6d6d">SMOD=1 </span><span style="color:#6d6d6d">时,串 </span></p>
<p><span style="color:#6d6d6d">行口波特率加倍。系统复位默认为 </span><span style="color:#6d6d6d">SMOD=0</span><span style="color:#6d6d6d">。 </span></p>
<p><span style="color:#6d6d6d"><strong>12</strong></span><span style="color:#6d6d6d"><strong>、</strong></span><span style="color:#6d6d6d"><strong>T2CON-----T2 </strong></span><span style="color:#6d6d6d"><strong>状态控制寄存器 </strong></span></p>
<p><span style="color:#ffffff"><strong>T2CON 定时器控制寄存器 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B7 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B6 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B5 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B4 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B3 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B2 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B1 </strong></span></p>
<p><span style="color:#6d6d6d"><strong>B0 </strong></span></p>
<p><span style="color:#6d6d6d">TF2 </span></p>
<p><span style="color:#6d6d6d">EXF2 </span></p>
<p><span style="color:#6d6d6d">RCLK </span></p>
<p><span style="color:#6d6d6d">TCLK </span></p>
<p><span style="color:#6d6d6d">EXEN2 </span></p>
<p><span style="color:#6d6d6d">TR2 </span></p>
<p><span style="color:#6d6d6d">C/T2 </span></p>
<p><span style="color:#6d6d6d">CP/RL2 </span></p>
<p><span style="color:#000000"> </span><span style="color:#9a9a9a">TF2</span><span style="color:#9a9a9a">:</span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">溢出中断标志。</span><span style="color:#9a9a9a">TF2 </span><span style="color:#9a9a9a">必须由用户程序清</span><span style="color:#9a9a9a">“0”</span><span style="color:#9a9a9a">。当 </span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">作为串口波特率发生器时,</span><span style="color:#9a9a9a">TF2 </span><span style="color:#9a9a9a">不会被置</span><span style="color:#9a9a9a">“1”</span><span style="color:#9a9a9a">。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">EXF2</span><span style="color:#9a9a9a">:定时器 </span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">外部中断标志。</span><span style="color:#9a9a9a">EXEN2 </span><span style="color:#9a9a9a">为 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">时,当 </span><span style="color:#9a9a9a">T2EX</span><span style="color:#9a9a9a">(</span><span style="color:#9a9a9a">P1.1</span><span style="color:#9a9a9a">)发生负跳变时置 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">中断标志 </span><span style="color:#9a9a9a">DXF2</span><span style="color:#9a9a9a">,</span><span style="color:#9a9a9a">EXF2 </span><span style="color:#9a9a9a">必须由 </span></p>
<p><span style="color:#9a9a9a">用户程序清</span><span style="color:#9a9a9a">“0”</span><span style="color:#9a9a9a">。</span><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">TCLK</span><span style="color:#9a9a9a">:串行接口的发送时钟选择标志。</span><span style="color:#9a9a9a">TCLK=1 </span><span style="color:#9a9a9a">时,</span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">工作于波特率发生器方式。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">RCLK</span><span style="color:#9a9a9a">:串行接口的接收时钟选择标志位。</span><span style="color:#9a9a9a">RCLK</span><span style="color:#9a9a9a">=</span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">时,</span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">工作于波特率发生器方式。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">EXEN2</span><span style="color:#9a9a9a">:</span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">的外部中断充许标志。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">C/T2</span><span style="color:#9a9a9a">:外部计数器</span><span style="color:#9a9a9a">/</span><span style="color:#9a9a9a">定时器选择位。</span><span style="color:#9a9a9a">C/T2=1 </span><span style="color:#9a9a9a">时,</span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">为外部事件计数器,计数脉冲来自 </span><span style="color:#9a9a9a">T2</span><span style="color:#9a9a9a">(</span><span style="color:#9a9a9a">P1.0</span><span style="color:#9a9a9a">);</span><span style="color:#9a9a9a">C/T2=0 </span><span style="color:#9a9a9a">时,</span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">为 </span></p>
<p><span style="color:#9a9a9a">定时器,振荡脉冲的十二分频信号作为计数信号。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">TR2</span><span style="color:#9a9a9a">:</span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">计数</span><span style="color:#9a9a9a">/</span><span style="color:#9a9a9a">定时控制位。</span><span style="color:#9a9a9a">TR1 </span><span style="color:#9a9a9a">为 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">时充许计数,为 </span><span style="color:#9a9a9a">0 </span><span style="color:#9a9a9a">时禁止计数。 </span></p>
<p><span style="color:#9a9a9a"> </span><span style="color:#9a9a9a">CP/RL2</span><span style="color:#9a9a9a">:捕捉和常数自动再装入方式选择位。为 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">时工作于捕捉方式,为 </span><span style="color:#9a9a9a">0 </span><span style="color:#9a9a9a">时 </span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">工作于常数自动再装入方式。当 </span><span style="color:#9a9a9a">TCLK </span></p>
<p><span style="color:#9a9a9a">或 </span><span style="color:#9a9a9a">RCLK </span><span style="color:#9a9a9a">为 </span><span style="color:#9a9a9a">1 </span><span style="color:#9a9a9a">时,</span><span style="color:#9a9a9a">CP/RL2 </span><span style="color:#9a9a9a">被忽略,</span><span style="color:#9a9a9a">T2 </span><span style="color:#9a9a9a">总是工作于常数自动再装入方式。 </span></p>
<p><span style="color:#6d6d6d">下面对 </span><span style="color:#6d6d6d">T2CON </span><span style="color:#6d6d6d">的 </span><span style="color:#6d6d6d">D0</span><span style="color:#6d6d6d">、</span><span style="color:#6d6d6d">D2</span><span style="color:#6d6d6d">、</span><span style="color:#6d6d6d">D4</span><span style="color:#6d6d6d">、</span><span style="color:#6d6d6d">D5 </span><span style="color:#6d6d6d">几位主要控制 </span><span style="color:#6d6d6d">T2 </span><span style="color:#6d6d6d">的工作方式,下面对这几位的组合关系进行总结 </span></p>
<p><span style="color:#ffffff"><strong>定时器 T2 方式选择 </strong></span></p>
<p><span style="color:#000000"><strong>RCLK+TCLK </strong></span></p>
<p><span style="color:#000000"><strong>CP/RL2 </strong></span></p>
<p><span style="color:#000000"><strong>TR2 </strong></span></p>
<p><span style="color:#000000"><strong>工作方式 </strong></span></p>
<p><span style="color:#000000">0 </span></p>
<p><span style="color:#000000">0 </span></p>
<p><span style="color:#000000">1 </span></p>
<p><span style="color:#000000">16 位常数自动再装入方式 </span></p>
<p><span style="color:#000000">0 </span></p>
<p><span style="color:#000000">1 </span></p>
<p><span style="color:#000000">1 </span></p>
<p><span style="color:#000000">16 位捕捉方式 </span></p>
<p><span style="color:#000000">1 </span></p>
<p><span style="color:#000000">× </span></p>
<p><span style="color:#000000">1 </span></p>
<p><span style="color:#000000">串行口波特率发生器方式 </span></p>
<p><span style="color:#000000">× </span></p>
<p><span style="color:#000000">× </span></p>
<p><span style="color:#000000">0 </span></p>
<p><span style="color:#000000">停止计数</span></p>
<p>现在51系列用的多吗?。。。。。。。。。。。。。。已经好久好久不用了<img height="48" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/smile.gif" width="48" /></p>
页:
[1]