📄 dpjjx28.htm
字号:
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="宋体" LANG="ZH-CN" SIZE=2>若有键被按下,应识别出是哪一个键闭合。方法是对键盘的行线进行扫描。</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>在每组行输出时读取</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>”这一行没有键闭合,否则有键闭合。由此得到闭合键的行值和列值,然后可采用计算法或查表法将闭合键的行值和列值转换成所定义的键值</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>仅作一次处理,必须却除键释放时的抖动。</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>
</FONT>
<P ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0">
<FONT FACE="宋体" LANG="ZH-CN" SIZE=2>	从以上分析得到键盘扫描程序的流程图如图</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">		MOV	A,R1</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>
</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">到本课为止,本站教程暂告一个段落!感谢大家的关心和支持!</font></p>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -