矩阵键盘程序(汇编+lcd显示)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

;P0接LCD;P2接矩阵键盘RSEQUP1.5;确定具体硬件的连接方式RWEQUP1.6;确定具体硬件的连接方式EEQUP1.7;LCD1602引脚ORG0HMAIN:ACALLSTARTMOVP0,#8FH;写入显示起始地址(第一行第一个位置)ACALLENABLE;调用写入命令子程序MOVR0,#2FHMOV2FH,#30HMOVR6,#1ACALLWRITE1D:MOV56H,#0MOVR1,#50HMOV54H,#2FHTEST:;键盘扫描MOVP2,#0F0HMOVA,P2CJNEA,#0F0H,HAVESJMPTESTHAVE:MOVA,#0FEHNEXT:MOVB,AMOVP2,AREAD:MOVA,P2ANLA,#0F0HCJNEA,#0F0H,SCONDMOVA,BRLACJNEA,#0EFH,NEXTSCOND:ACALLDAYMOVA,P2ANLA,#0F0HCJNEA,#0F0H,JSSJMPTESTJS:MOVR2,AMOVA,BANLA,#0FHORLA,R2SON:CJNEA,#0E7H,S1AJMPMAINS1:CJNEA,#0D7H,S4MOVB,#31H;1的ACSII值为31HAJMPYZS4:CJNEA,#0B7H,S7MOVB,#34HAJMPYZS7:CJNEA,#77H,S0MOVB,#37HAJMPYZS0:CJNEA,#0EBH,S2MOVB,#30HAJMPYZS2:CJNEA,#0DBH,S5MOVB,#32HAJMPYZS5:CJNEA,#0BBH,S8MOVB,#35HAJMPYZS8:CJNEA,#7BH,S3MOVB,#38HAJMPYZS3:CJNEA,#0DDH,S6MOVB,#33HAJMPYZS6:CJNEA,#0BDH,S9MOVB,#36HAJMPYZS9:CJNEA,#7DH,TESTMOVB,#39HAJMPYZYZ:MOVA,56HCJNEA,#0,YZ1SJMPYZ2YZ1:CJNE@R1,#10,YZ2AJMPTESTYZ2:CJNER1,#50H,YZ3MOV55H,#0MOV58H,#0MOVA,56HCJNEA,#0,YZ3MOV56H,#1MOV50H,#0MOVR0,#20HYZ3:CJNE@R1,#1,YZ4MOVR0,54HCJNE@R0,#30H,YZ4MOV@R0,#0MOV@R1,#0YZ4:MOVR2,#8YZ5:MOVA,54HSUBBA,R2MOVR0,AMOVA,@R0DECR0MOV@R0,ADECR2INCR0MOVA,R0CJNEA,54H,YZ5MOVR0,54HMOV@R0,BACALLSHOWAJMPTESTSHOW:ACALLSTARTMOVA,#8FHSUBBA,@R1MOVP0,A;写入显示起始地址(第一行第一个位置)ACALLENABLE;调用写入命令子程序MOVA,54HSUBBA,@R1MOVR0,AINC@R1MOVA,@R1MOVR6,AACALLWRITE1RET;LCD1602部分START:MOVP0,#1H;清屏并光标复位ACALLENABLE;调用写入命令子程序MOVP0,#8H;设置显示模式:8位2行5X7点阵ACALLENABLE;调用写入命令子程序MOVP0,#0CH;显示器开、光标关ACALLENABLE;调用写入命令子程序MOVP0,#6H;文字不动,光标自动右移ACALLENABLE;调用写入命令子程序RETENABLE:CLRRS;写入控制命令的子程序CLRRWCLREACALLDELAYSETBERETWRITE1:MOVA,@R0LCALLWRITE2;调用写入数据寄存器子程序INCR0;取码指针加1DJNZR6,WRITE1RETWRITE2:MOVP0,ASETBRS;RS=1CLRRW;RW=0准备写入数据CLRE;E=0执行显示命令ACALLDELAY;判断液晶模块是否忙?(用延时代替)SETBE;E=1RETDELAY:MOVR2,#2FHDL1:MOVR3,#0FHDJNZR3,$DJNZR2,DL1RETDAY:MOVR2,#100;按键延时0.1SDL3:MOVR3,#250DL2:NOPNOPDJNZR3,DL2DJNZR2,DL3RETEND

1 / 4
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功