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

📄 dpjjx26.htm

📁 本单片机教程是平凡老师花了大量时间
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">SETB&#9;RS0</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">MOV&#9;R7,#50</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2">D1:&#9;MOV&#9;R6,#10</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2">D2:&#9;DJNZ&#9;R6,$</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">DJNZ&#9;R7,D1</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">POP&#9;PSW</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">RET</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2">DISPTAB:DB 28H,7EH,0a4H,64H,72H,61H,21H,7CH,20H,60H </font>&#9;</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">END</font></P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="宋体" LANG="ZH-CN">&nbsp;&nbsp; 从上面的例子中可以看出,动态扫描显示必须由</font><FONT FACE="System,黑体" LANG="ZH-CN" size="2">CPU</FONT><font size="2" FACE="宋体" LANG="ZH-CN">不断地调用显示程序,才能保证持续不断的显示。</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="宋体" LANG="ZH-CN">&nbsp; 上面的这个程序可以实现数字的显示,但不太实用,为什么呢?这里仅是显示两个数字,并没有做其他的工作,因此,两个数码管轮流显示</font><font size="2"><FONT FACE="System,黑体" LANG="ZH-CN">1</FONT><FONT FACE="宋体" LANG="ZH-CN">毫秒,没有问题,实际的工作中,当然不可能只显示两个数字,还是要做其他的事情的,这样在二次调用显示程序之间的时间间隔就不一不定了,如果时间间隔比较长,就会使显示不连续。而实际工作中是很难保证所有工作都能在很短时间内完成的。况且这个显示程序也有点“浪费”,每个数码管显示都要占用</FONT><FONT FACE="System,黑体" LANG="ZH-CN">1</FONT></font><font size="2" FACE="宋体" LANG="ZH-CN">个毫秒的时间,这在很多合是不允许的,怎么办呢?我们可以借助于定时器,定时时间一到,产生中断,点亮一个数码管,然后马上返回,这个数码管就会一直亮到下一次定时时间到,而不用调用延时程序了,这段时间可以留给主程序干其他的事。到下一次定时时间到则显示下一个数码管,这样就很少浪费了。</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">Counter&#9;&#9;EQU&#9;59H&#9;;</font><font size="2" FACE="宋体" LANG="ZH-CN">计数器,显示程序通过它得知现正显示哪个数码管</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">FIRST&#9;&#9;EQU&#9;P2.7&#9;;</font><font size="2" FACE="宋体" LANG="ZH-CN">第一位数码管的位控制</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">SECOND &#9;EQU&#9;P2.6&#9;;</font><font size="2" FACE="宋体" LANG="ZH-CN">第二位数码管的位控制</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">DISPBUFF&#9;EQU&#9;5AH&#9;;</font><font size="2"><FONT FACE="宋体" LANG="ZH-CN">显示缓冲区为</FONT><FONT FACE="System,黑体" LANG="ZH-CN">5AH</FONT><FONT FACE="宋体" LANG="ZH-CN">和</FONT></font><font size="2" FACE="System,黑体" LANG="ZH-CN">5BH</font></P><FONT FACE="System,黑体" LANG="ZH-CN">
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">ORG&#9;0000H</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">AJMP&#9;START</font></P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">ORG&#9;000BH&#9;&#9;;</font><font size="2"><FONT FACE="宋体" LANG="ZH-CN">定时器</FONT><FONT FACE="System,黑体" LANG="ZH-CN">T0</FONT></font><font size="2" FACE="宋体" LANG="ZH-CN">的入口</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">AJMP&#9;DISP&#9;&#9;;</font><font size="2" FACE="宋体" LANG="ZH-CN">显示程序</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="System,黑体" LANG="ZH-CN" size="2">ORG&#9;30H</font></P>
<FONT FACE="System,黑体" LANG="ZH-CN" size="2">
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">START:</P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">MOV&#9;SP,#5FH&#9;&#9;;</font><font size="2" FACE="宋体" LANG="ZH-CN">设置堆栈</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="System,黑体" LANG="ZH-CN" size="2">MOV&#9;P1,#0FFH</font></P>
<FONT FACE="System,黑体" LANG="ZH-CN" size="2">
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;MOV&#9;P0,#0FFH</P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">MOV&#9;P2,#0FFH&#9;;</font><font size="2"><FONT FACE="宋体" LANG="ZH-CN">初始化,所显示器,</FONT><FONT FACE="System,黑体" LANG="ZH-CN">LED</FONT></font><font size="2" FACE="宋体" LANG="ZH-CN">灭</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">MOV&#9;TMOD,#00000001B&#9;;</font><font size="2"><FONT FACE="宋体" LANG="ZH-CN">定时器</FONT><FONT FACE="System,黑体" LANG="ZH-CN">T0</FONT><FONT FACE="宋体" LANG="ZH-CN">工作于模式</FONT><FONT FACE="System,黑体" LANG="ZH-CN">1</FONT><FONT FACE="宋体" LANG="ZH-CN">(</FONT><FONT FACE="System,黑体" LANG="ZH-CN">16</FONT><FONT FACE="宋体" LANG="ZH-CN">位定时</FONT><FONT FACE="System,黑体" LANG="ZH-CN">/</FONT></font><font size="2" FACE="宋体" LANG="ZH-CN">计数模式)</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="System,黑体" LANG="ZH-CN" size="2">MOV&#9;TH0,#HIGH(65536-2000)</font></P><FONT FACE="System,黑体" LANG="ZH-CN">
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">MOV&#9;TL0,#LOW(65536-2000)</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">SETB&#9;TR0</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">SETB&#9;EA</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">SETB&#9;ET0</font></P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">MOV&#9;Counter,#0&#9;;</font><font size="2" FACE="宋体" LANG="ZH-CN">计数器初始化</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">MOV&#9;DISPBUFF,#0&#9;;</font><FONT FACE="宋体" LANG="ZH-CN" size="2">第一位始终显示</FONT><font size="2" FACE="System,黑体" LANG="ZH-CN">0</font></P><FONT FACE="System,黑体" LANG="ZH-CN">
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">MOV&#9;A,#0</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2">LOOP:&#9;</font>&#9;</P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">MOV&#9;DISPBUFF+1,A&#9;;</font><FONT FACE="宋体" LANG="ZH-CN" size="2">第二位轮流显示</FONT><font size="2" FACE="System,黑体" LANG="ZH-CN">0-9</font></P><FONT FACE="System,黑体" LANG="ZH-CN">
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">INC&#9;A</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">LCALL&#9;DELAY</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">CJNE&#9;A,#10,LOOP</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;
<font size="2">MOV&#9;A,#0</font></P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">AJMP&#9;LOOP</font><font size="2"><FONT FACE="宋体" LANG="ZH-CN">&#9;</FONT><FONT FACE="System,黑体" LANG="ZH-CN">;</FONT></font><font size="2" FACE="宋体" LANG="ZH-CN">在此中间可以按排任意程序,这里仅作示范。</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">;</font><font size="2" FACE="宋体" LANG="ZH-CN">主程序到此结束</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">DISP:&#9;&#9;;</font><font size="2"><FONT FACE="宋体" LANG="ZH-CN">定时器</FONT><FONT FACE="System,黑体" LANG="ZH-CN">T0</FONT></font><font size="2" FACE="宋体" LANG="ZH-CN">的中断响应程序</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">PUSH&#9;ACC&#9;&#9;;ACC</font><font size="2" FACE="宋体" LANG="ZH-CN">入栈</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">PUSH&#9;PSW&#9;&#9;;PSW</font><font size="2" FACE="宋体" LANG="ZH-CN">入栈</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2" FACE="System,黑体" LANG="ZH-CN">MOV&#9;TH0,#HIGH(65536-2000)&#9;;</font><font size="2"><FONT FACE="宋体" LANG="ZH-CN">定时时间为</FONT><FONT FACE="System,黑体" LANG="ZH-CN">2000</FONT><FONT FACE="宋体" LANG="ZH-CN">个周期,约</FONT><FONT FACE="System,黑体" LANG="ZH-CN">2170</FONT><FONT FACE="宋体" LANG="ZH-CN">微秒(</FONT><FONT FACE="System,黑体" LANG="ZH-CN">11.0592M</FONT></font><font size="2" FACE="宋体" LANG="ZH-CN">)</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="System,黑体" LANG="ZH-CN" size="2">MOV&#9;TL0,#LOW(65536-2000)</font></P>
<FONT FACE="System,黑体" LANG="ZH-CN" size="2">
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">&#9;SETB&#9;FIRST</P>

⌨️ 快捷键说明

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