📄 单片机教学.htm
字号:
lang=ZH-CN face=System>10111</FONT><FONT lang=ZH-CN face=宋体>,也就是</FONT><FONT
lang=ZH-CN face=System>0001</FONT><FONT lang=ZH-CN face=宋体>,</FONT><FONT
lang=ZH-CN face=System>0111</FONT><FONT lang=ZH-CN face=宋体>高</FONT><FONT
lang=ZH-CN face=System>4</FONT><FONT lang=ZH-CN face=宋体>位是</FONT><FONT
lang=ZH-CN face=System>0001</FONT><FONT lang=ZH-CN face=宋体>,低</FONT><FONT
lang=ZH-CN face=System>4</FONT><FONT lang=ZH-CN face=宋体>位是</FONT><FONT
lang=ZH-CN face=System>0111</FONT><FONT lang=ZH-CN face=宋体>,交换后是</FONT><FONT
lang=ZH-CN face=System>01110001</FONT><FONT lang=ZH-CN face=宋体>,也就是</FONT><FONT
lang=ZH-CN face=System>71H</FONT><FONT lang=ZH-CN face=宋体>,即</FONT><FONT
lang=ZH-CN face=System>113</FONT><FONT lang=ZH-CN face=宋体>。</FONT></P></DIR>
<P align=justify><FONT lang=ZH-CN face=宋体>练习,已知(</FONT><FONT lang=ZH-CN
face=System>A</FONT><FONT lang=ZH-CN face=宋体>)</FONT><FONT lang=ZH-CN
face=System>=39H</FONT><FONT lang=ZH-CN face=宋体>,执行下列指令后写出每步的结果</FONT></P><FONT
lang=ZH-CN face=System>
<P align=justify>CPL A</P>
<P align=justify>RL A</P>
<P align=justify>CLR C</P>
<P align=justify>RRC A</P>
<P align=justify>SETB C</P>
<P align=justify>RLC A</P>
<P align=justify>SWAP A</P></FONT><FONT lang=ZH-CN face=宋体>
<P align=justify>通过前面的学习,我们已经掌握了相当一部份的指令,大家对这些枯燥的指令可能也有些厌烦了,下面让我们轻松一下,做个实验。</P>
<P align=justify>实验五:</P></FONT><FONT lang=ZH-CN face=宋体 size=3>
<P align=justify>ORG 0000H</P>
<P align=justify>LJMP START</P>
<P align=justify>ORG 30H</P>
<P align=justify>START:</P>
<P align=justify>MOV SP,#5FH</P>
<P align=justify>MOV A,#80H</P>
<P align=justify>LOOP:</P>
<P align=justify>MOV P1,A</P>
<P align=justify>RL A</P>
<P align=justify>LCALL DELAY</P>
<P align=justify>LJMP LOOP</P>
<P align=justify>delay:</P>
<P align=justify>mov r7,#255</P>
<P align=justify>d1: mov r6,#255</P>
<P align=justify>d2: nop</P>
<P align=justify>nop</P>
<P align=justify>nop</P>
<P align=justify>nop</P>
<P align=justify>djnz r6,d2</P>
<P align=justify>djnz r7,d1</P>
<P align=justify>ret</P>
<P align=justify>END</P></FONT><FONT lang=ZH-CN face=宋体>
<P align=justify>先让我们将程序写入片中,装进实验板,看一看现象。</P>
<P align=justify>。</P>
<P align=justify>。</P>
<P align=justify>看到的是一个暗点流动的现象,让我们来分析一下吧。</P></FONT>
<P align=justify><FONT lang=ZH-CN face=宋体>前而的</FONT><FONT lang=ZH-CN
face=System>ORG 0000H</FONT><FONT lang=ZH-CN face=宋体>、</FONT><FONT lang=ZH-CN
face=System>LJMP START</FONT><FONT lang=ZH-CN face=宋体>、</FONT><FONT lang=ZH-CN
face=System>ORG 30H</FONT><FONT lang=ZH-CN face=宋体>等我们稍后分析。从</FONT><FONT
lang=ZH-CN face=System>START</FONT><FONT lang=ZH-CN face=宋体>开始,</FONT><FONT
lang=ZH-CN face=System>MOV SP</FONT><FONT lang=ZH-CN face=宋体>,</FONT><FONT
lang=ZH-CN face=System>#5FH</FONT><FONT lang=ZH-CN
face=宋体>,这是初始化堆栈,在本程序中有无此句无关紧要,不过我们慢慢开始接触正规的编程,我也就慢慢给大家培养习惯吧。</FONT></P>
<P align=justify><FONT lang=ZH-CN face=System>MOV A</FONT><FONT lang=ZH-CN
face=宋体>,</FONT><FONT lang=ZH-CN face=System>#80H</FONT><FONT lang=ZH-CN
face=宋体>,将</FONT><FONT lang=ZH-CN face=System>80H</FONT><FONT lang=ZH-CN
face=宋体>这个数送到</FONT><FONT lang=ZH-CN face=System>A</FONT><FONT lang=ZH-CN
face=宋体>中去。干什么呢?不知道,往下看。</FONT></P>
<P align=justify><FONT lang=ZH-CN face=System>MOV P1</FONT><FONT lang=ZH-CN
face=宋体>,</FONT><FONT lang=ZH-CN face=System>A</FONT><FONT lang=ZH-CN
face=宋体>。将</FONT><FONT lang=ZH-CN face=System>A</FONT><FONT lang=ZH-CN
face=宋体>中的值送到</FONT><FONT lang=ZH-CN face=System>P1</FONT><FONT lang=ZH-CN
face=宋体>端口去。此时</FONT><FONT lang=ZH-CN face=System>A</FONT><FONT lang=ZH-CN
face=宋体>中的值是</FONT><FONT lang=ZH-CN face=System>80H</FONT><FONT lang=ZH-CN
face=宋体>,所以送出去的也就是</FONT><FONT lang=ZH-CN face=System>80H</FONT><FONT lang=ZH-CN
face=宋体>,因此</FONT><FONT lang=ZH-CN face=System>P1</FONT><FONT lang=ZH-CN
face=宋体>口的值是</FONT><FONT lang=ZH-CN face=System>80H</FONT><FONT lang=ZH-CN
face=宋体>,也就是</FONT><FONT lang=ZH-CN face=System>10000000B</FONT><FONT lang=ZH-CN
face=宋体>,通过前面的分析,我们应当知道,此时</FONT><FONT lang=ZH-CN face=System>P1</FONT><FONT
lang=ZH-CN face=宋体>。</FONT><FONT lang=ZH-CN face=System>7</FONT><FONT lang=ZH-CN
face=宋体>接的</FONT><FONT lang=ZH-CN face=System>LED</FONT><FONT lang=ZH-CN
face=宋体>是不亮的,而其它的</FONT><FONT lang=ZH-CN face=System>LED</FONT><FONT lang=ZH-CN
face=宋体>都是亮的,所以就形成了一个“暗点”。继续看,</FONT><FONT lang=ZH-CN face=System>RL
A</FONT><FONT lang=ZH-CN face=宋体>,</FONT><FONT lang=ZH-CN face=System>RL
A</FONT><FONT lang=ZH-CN face=宋体>是将</FONT><FONT lang=ZH-CN
face=System>A</FONT><FONT lang=ZH-CN
face=宋体>中的值进行左移,算一下,移之后的结果是什么?对了,是</FONT><FONT lang=ZH-CN
face=System>01H</FONT><FONT lang=ZH-CN face=宋体>,也就是</FONT><FONT lang=ZH-CN
face=System>00000001B</FONT><FONT lang=ZH-CN face=宋体>,这样,应当是接在</FONT><FONT
lang=ZH-CN face=System>P1</FONT><FONT lang=ZH-CN face=宋体>。</FONT><FONT
lang=ZH-CN face=System>0</FONT><FONT lang=ZH-CN face=宋体>上的</FONT><FONT
lang=ZH-CN face=System>LED</FONT><FONT lang=ZH-CN
face=宋体>不亮,而其它的都亮了,从现象上看“暗点”流到了后面。然后是调用延时程序,这个我们很熟悉了,让这个“暗点”“暗”一会儿。然后又调转到</FONT><FONT
lang=ZH-CN face=System>LOOP</FONT><FONT lang=ZH-CN face=宋体>处(</FONT><FONT
lang=ZH-CN face=System>LJMP LOOP</FONT><FONT lang=ZH-CN
face=宋体>)。请大家计算一下,下面该哪个灯不亮了。。。。。对了,应当是接在</FONT><FONT lang=ZH-CN
face=System>P1</FONT><FONT lang=ZH-CN face=宋体>。</FONT><FONT lang=ZH-CN
face=System>1</FONT><FONT lang=ZH-CN
face=宋体>上灯不亮了。这样依次循环,就形成了“暗点流动”这一现象。</FONT></P><FONT lang=ZH-CN face=宋体>
<P align=justify>问题:</P>
<OL>
<P align=justify>
<LI>如何实现亮点流动?
<P></P>
<P align=justify></P>
<LI>如何改变流动的方向?
<P></P></LI></OL>
<P align=justify>答案:</P>
<P align=justify>1、将A中的初始值改为7FH即可。 </P>
<P align=justify>2、将RL A改为RR A即可。</P>
<P align=center><A href="http://www.onestudy.net/"><FONT
face=黑体>返回“一学网</FONT><FONT face="Times New Roman" color=#000000> </FONT><FONT
face="Times New Roman"><FONT color=#000000>www.</FONT><FONT
color=#ff0000>one</FONT><FONT color=#008000>study</FONT>.net</FONT><FONT
face=黑体> ”首页</FONT></A></P>
<P align=justify> </P>
<P align=justify> </P></FONT></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -