?? dpjjx26.htm
字號:
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">SETB	RS0</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">MOV	R7,#50</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2">D1:	MOV	R6,#10</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2">D2:	DJNZ	R6,$</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">DJNZ	R7,D1</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">POP	PSW</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<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>	</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<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"> 從上面的例子中可以看出,動態掃描顯示必須由</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"> 上面的這個程序可以實現數字的顯示,但不太實用,為什么呢?這里僅是顯示兩個數字,并沒有做其他的工作,因此,兩個數碼管輪流顯示</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		EQU	59H	;</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		EQU	P2.7	;</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 	EQU	P2.6	;</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	EQU	5AH	;</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">	
<font size="2">ORG	0000H</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">AJMP	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	000BH		;</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	DISP		;</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	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	SP,#5FH		;</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	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">	MOV	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	P2,#0FFH	;</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	TMOD,#00000001B	;</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	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">	
<font size="2">MOV	TL0,#LOW(65536-2000)</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">SETB	TR0</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">SETB	EA</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">SETB	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	Counter,#0	;</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	DISPBUFF,#0	;</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">	
<font size="2">MOV	A,#0</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2">LOOP:	</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	DISPBUFF+1,A	;</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">	
<font size="2">INC	A</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">LCALL	DELAY</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">CJNE	A,#10,LOOP</font></P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">	
<font size="2">MOV	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	LOOP</font><font size="2"><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 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:		;</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	ACC		;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	PSW		;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	TH0,#HIGH(65536-2000)	;</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	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">	SETB	FIRST</P>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -