?? dpjjx28.htm
字號(hào):
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="宋體" LANG="ZH-CN" SIZE=2>若有鍵被按下,應(yīng)識(shí)別出是哪一個(gè)鍵閉合。方法是對(duì)鍵盤(pán)的行線進(jìn)行掃描。</font><FONT SIZE=2>P1.4-P1.7</FONT><FONT FACE="宋體" LANG="ZH-CN" SIZE=2>按下述</FONT><FONT SIZE=2>4</FONT><FONT FACE="宋體" LANG="ZH-CN" SIZE=2>種組合依次輸出:</font><font size="2"></LI>
</font>
<FONT FACE="宋體" LANG="ZH-CN" SIZE=3>
</p>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
</FONT><FONT SIZE=2>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">P1.7 1 1 1 0</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">P1.6 1 1 0 1</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">P1.5 1 0 1 1</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">P1.4 0 1 1 1</P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="宋體" LANG="ZH-CN" SIZE=2>在每組行輸出時(shí)讀取</FONT><FONT SIZE=2>P1.0-P1.3</FONT><FONT FACE="宋體" LANG="ZH-CN" SIZE=2>,若全為“</FONT><FONT SIZE=2>1</FONT><FONT FACE="宋體" LANG="ZH-CN" SIZE=2>”,則表示為“</FONT><FONT SIZE=2>0</FONT><FONT FACE="宋體" LANG="ZH-CN" SIZE=2>”這一行沒(méi)有鍵閉合,否則有鍵閉合。由此得到閉合鍵的行值和列值,然后可采用計(jì)算法或查表法將閉合鍵的行值和列值轉(zhuǎn)換成所定義的鍵值</font></P>
<FONT FACE="宋體" LANG="ZH-CN" SIZE=3>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
</FONT>
<LI>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="宋體" LANG="ZH-CN" SIZE=2>為了保證鍵每閉合一次</font><FONT SIZE=2>CPU</FONT><FONT FACE="宋體" LANG="ZH-CN" SIZE=2>僅作一次處理,必須卻除鍵釋放時(shí)的抖動(dòng)。</font><font size="2"></LI>
</font></p>
<table width="300" border="0" cellspacing="2" cellpadding="2">
<tr>
<td height="328">
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2"><img src="DPJ282.gif" align="bottom" width="362" height="324"> </font>
</td>
</tr>
<tr>
<td>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<font size="2"><img src="DPJ283.gif" width="362" height="296"></font></td>
</tr>
</table>
<FONT FACE="宋體" LANG="ZH-CN" SIZE=3>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
</font>
</OL>
<FONT FACE="宋體" LANG="ZH-CN" SIZE=2>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">鍵盤(pán)掃描程序:</P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="宋體" LANG="ZH-CN" SIZE=2>	從以上分析得到鍵盤(pán)掃描程序的流程圖如圖</font><font size="2">2</font><FONT FACE="宋體" LANG="ZH-CN" SIZE=2>所示。程序如下</font></P>
<FONT SIZE=2>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">SCAN:	MOV	P1,#0FH</P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT SIZE=2>MOV	A,P1</font></P><FONT SIZE=2>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		ANL	A,#0FH</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		CJNE	A,#0FH,NEXT1</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		SJMP	NEXT3</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">NEXT1:	ACALL	D20MS</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		MOV	A,#0EFH</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">NEXT2:	MOV	R1,A</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		MOV	P1,A</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		MOV	A,P1</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		ANL	A,#0FH</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		CJNE	A,#0FH,KCODE;</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		SETB	C</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		RLC		A</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		JC		NEXT2</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">NEXT3:	MOV	R0,#00H	</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		RET</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">KCODE:	MOV	B,#0FBH</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">NEXT4:	RRC		A</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		INC		B</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		JC		NEXT4</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		MOV	A,R1</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		SWAP	A</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">NEXT5:	RRC		A</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		INC		B</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		INC		B</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		INC		B</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		INC		B</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		JC		NEXT5</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">NEXT6:	MOV	A,P1</P>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		ANL	A,#0FH</P>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT SIZE=2>CJNE	A,#0FH,NEXT6</font></P><FONT SIZE=2>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">		MOV	R0,#0FFH</P>
</FONT><FONT FACE="宋體" LANG="ZH-CN" SIZE=3>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
		</FONT><FONT SIZE=2>RET
</FONT>
<FONT SIZE=3>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
</FONT>
<FONT SIZE=2>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0">鍵盤(pán)處理程序就作這么一個(gè)簡(jiǎn)單的介紹,實(shí)際上,鍵盤(pán)、顯示處理是很復(fù)雜的,它往往占到一個(gè)應(yīng)用程序的大部份代碼,可見(jiàn)其重要性,但說(shuō)到,這種復(fù)雜并不來(lái)自于單片機(jī)的本身,而是來(lái)自于操作者的習(xí)慣等等問(wèn)題,因此,在編寫(xiě)鍵盤(pán)處理程序之前,最好先把它從邏輯上理清,然后用適當(dāng)?shù)乃惴ū硎境鰜?lái),最后再去寫(xiě)代碼,這樣,才能快速有效地寫(xiě)好代碼。</P>
</FONT>
<FONT SIZE=3>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"></P>
</FONT>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">到本課為止,本站教程暫告一個(gè)段落!感謝大家的關(guān)心和支持!</font></p>
</BODY>
</HTML>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -