资源描述:
《单片机按键显示程序及原理图.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、1.KEYLED---按键一位显示ORG0000HLJMPMAINORG0030HMAIN:mova,#010hmov50h,amain1:LCALLLEDLCALLKEYSJMPMAIN1KEY:LCALLKSJNZK1LCALLDELAYLJMPK5K1:LCALLDELAYLCALLDELAYLCALLKSJNZK2LJMPK5K2:MOVR2,#0FEHMOVR4,#00HK3:MOVA,R2MOVP2,AMOVA,P2ANLA,#0F0HSWAPAJBACC.0,L1MOVA,#00HLJMPLKL1:JBACC.1
2、,L2MOVA,#04HLJMPLKL2:JBACC.2,L3MOVA,#08HLJMPLKL3:JBACC.3,NEXTMOVA,#0CHLK:ADDA,R4PUSHACCK4:LCALLDELAYLCALLKSJNZK4POPACCmov50h,aK5:RETNEXT:INCR4MOVA,R2JNBACC.3,K5RLAMOVR2,ALJMPK3KS:MOVA,#0F0HMOVP2,AMOVA,P2CPLAANLA,#0F0HSWAPARETLED:mova,50hmovr1,Amovp3,#0efhLED1:MOVA,r
3、1movdptr,#tableMOVcA,@a+dptrmovp0,aLCALLDELAYRETDELAY:movr5,#10HD0:MOVR6,#0FAHD1:DJNZR6,D1djnzr5,D0RETtable:db0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h,88h,83h,0C6h,0A1h,86h,8Eh,0chEND2.KEYLEDINT1---按键4位显示,中断ORG0000HLJMPMAINorg0013hljmpsubint1org001bhljmpsubt1ORG
4、0030HMAIN:mova,#010hmov50h,amov51h,#0hmov52h,#0hmov53h,#0chmov54h,#0hmov55h,#4clrp1.2setbp1.5CLRRS0CLRRS1//SETBRS0movr7,#20CLRRS0movtl0,#00hmovth0,#00hmovtl1,#0B0hmovth1,#3chmovtmod,#11hmovie,#8chmovtcon,#04h//setbtr0setbtr1clrp1.0main1:movR0,#4fhmovR2,#0F7hmain2:mo
5、vR3,#04Hmain3:movA,R2RLAmovR2,AINCR0LCALLLEDDJNZR3,main3SJMPMAIN1LED:mova,@R0movr1,Amovp3,r2LED1:MOVA,r1movdptr,#tableMOVcA,@a+dptrmovp0,aLCALLDELAYRETDELAY:movr5,#4HD0:MOVR6,#0faHD1:DJNZR6,D1djnzr5,D0RETtable:db0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h,88h,83h,0
6、C6h,0A1h,86h,8Eh,0chsubint1:pushaccinc54hdec55hmova,55hcjnea,#00h,subint10mov55h,#4cplp1.5cplp1.2subint10:popaccretisubt1:movtl1,#0B0hmovth1,#3Chpushacc//SETBRS0decr7cjner7,#00h,subt10mova,54hmovb,#4divab//mulmov54h,#00hmovr7,#20movb,#0ahdivabmov50h,bmovb,#0ahdivabm
7、ov51h,bmovb,#0ahdivabmov52h,bmovb,#0ahdivabmov53h,bcplp1.4subt10://CLRRS0popaccreti2.中断脉宽调制PWMOrg0000hljmpmainorg000bhljmpsubt0org0030hmain:mov50h,#0hmov51h,#10hmov52h,#80hmov53h,#00hmovtl0,#00hmovth0,#00hmovtmod,#01hmovie,#82hsetbtr0lp1:sjmplp1subt0:movtl0,#00hmovt
8、h0,#00hinc50hmova,53hcjneA,#0,lp2mova,50hcjnea,51H,lp4mov50h,#00hmov53h,#01hSETBp1.3SJMPLP4LP2:mova,50hcjnea,52H,lp4mov50h,#00hmov53h,#00h