資源描述:
《單片機(jī)實(shí)驗(yàn)程序.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、鍵盤(pán)顯示控制程序:ORG0000HJMPMAINMAIN:MOVP0,#0FFHMOVP1,#0FFHKEYDOWN:MOVP1,#0F0HLCALLDELAYMOVA,P1CJNEA,#0F0H,KEYSCANJMPKEYDOWNKEYSCAN:MOVA,#00HMOVP1,#0F0HMOVA,P1CJNEA,#70H,N1MOVR4,#03HJMPNEXTN1:CJNEA,#0B0H,N2MOVR4,#02HJMPNEXTN2:CJNEA,#0D0H,N3MOVR4,#01HJMPNEXTN3:C
2、JNEA,#0E0H,NEXTMOVR4,#00HJMPNEXTNEXT:MOVP1,#00FHMOVA,P1CJNEA,#07H,N4MOVR3,#08HJMPNEXTN4:CJNEA,#0BH,N5MOVR3,#04HJMPNEXTN5:CJNEA,#0DH,DISPLAYMOVR3,#00HJMPDISPLAYDISPLAY:MOVA,R4ADDA,R3MOVDPTR,#LEDTABMOVCA,@A+DPTRMOVP0,ALCALLDELAYLCALLDELAYMOVP0,#0FFHLJMPKE
3、YDOWNLCALLDELAYDELAY:MOVR6,#25HDELAY1:MOVR1,#10LOOP:MOVR2,#250DJNZR2,$DJNZR1,LOOPRETD2:MOVR7,#500DJNZR7,$DJNZR6,D2RETLEDTAB:DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,88H,83HENDORG0000HLJMPMAINORG0100HMAIN:MOVSP,#78HMOV78H,#00HMOV79H,#00HMOV7AH,#00H
4、MOV7BH,#00HMOV7CH,#00HMOV7DH,#00HMOV7EH,#00HKEYI:ACALLKS1CJNEA,#0F0H,LK1ACALLDIRAJMPKEYILK1:ACALLDIRACALLDIRACALLKS1CJNEA,#0F0H,LK2ACALLDIRAJMPKEYILK2:ACALLKS1MOVR2,AORLA,#0FHMOVP3,AMOVA,P3ANLA,#0FHADDA,R2;鍵特征值CJNEA,#0EEH,JZHI1MOVA,#00HPUSH0E0HJZHI1:CJN
5、EA,#0DEH,JZHI2MOVA,#01HPUSH0E0HJZHI2:CJNEA,#0BEH,JZHI3MOVA,#02HPUSH0E0HJZHI3:CJNEA,#7EH,JZHI4MOVA,#03HPUSH0E0HJZHI4:CJNEA,#0EDH,JZHI5MOVA,#04HPUSH0E0HJZHI5:CJNEA,#0DDH,JZHI6MOVA,#05HPUSH0E0HJZHI6:CJNEA,#0BDH,JZHI7MOVA,#06HPUSH0E0HJZHI7:CJNEA,#07DH,JZHI8
6、MOVA,#07HPUSH0E0HJZHI8:CJNEA,#0EBH,JZHI9MOVA,#08HPUSH0E0HJZHI9:CJNEA,#0DBH,KEYIMOVA,#09HPUSH0E0HLJMPKEYIDIR:MOVDPTR,#DEGMOVR0,#79H;數(shù)碼管第一位MOVR3,#0FEH;線選LD1:CLRP2.7CLRP2.6MOVA,@R0MOVCA,@A+DPTRMOVP0,ASETBP2.6CLRP2.6MOVP0,R3SETBP2.7LCALLDELYINCR0MOVA,R3JNBA
7、CC.5,LD2RLAMOVR3,ASJMPLD1LD2:RETDEG:DB3FH,06H,5BH,4FH,66HDB6DH,7DH,07H,7FH,6FHDELY:MOVR7,#02HDL:MOVR6,#0FFHDL6:DJNZR6,DL6DJNZR7,DLRETKS1:MOVP3,#0F0HMOVA,P3ANLA,#0F0HRET;鍵是否按下END能實(shí)現(xiàn):org0000hljmpmainorg0200hmain:init:MOV60H,#10hMOV61H,#10hMOV62H,#10hMOV63
8、H,#10hwait:??acallkeyscan?????????????????????;有鍵按下,轉(zhuǎn)定按鍵位置掃描acalldispsjmp???????wait???????;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<;?????????????????????p1.7p1.6p1.5p1.4?????????????????