资源描述:
《单片机查表程序设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、$INCLUDE(C8051F020.INC)BIT_COUNTDATA07FHTIMERDATA07EHTIMER1DATA07DHTENDATA07CHDATA_INDATA020HDATA_OUTDATA021HDATA_OUT1DATA022HDATA_OUT2DATA023HDATA_OUT3DATA024HDATA_OUT4DATA025HCLKBITP1.6DATBITP1.7ORG0000HJMPSTARTORG0100HSTART:movWDTCN,#0deh;disablewatchdogtimer
2、movWDTCN,#0adhmovOSCXCN,#67h;enableexternalcrystal;oscillatorat22.1184MHzclrA;waitatleast1msdjnzacc,$;wait~512usdjnzacc,$;wait~512usosc_wait:;pollforXTLVLD-->1mova,OSCXCNjnbacc.7,osc_waitorlOSCICN,#08h;selectexternaloscillatoras;systemclocksourceorlOSCXCN,#80h;e
3、nablemissingclockdetectorCP1INIT:movCPT1CN,#080h;Comparator1ControlRegistermovA,#010h;CPT1CNdjnzACC,$;CPT1CNwaitatleast20usanlCPT1CN,#not(30h)movEIP1,#040hMOVTIMER,#50PORTINIT:movXBR2,#044hmovP0MDOUT,#001hDELAY0:MOVTIMER1,#255DELAY1:DJNZTIMER1,DELAY1DJNZTIMER,DE
4、LAY0ANLP5,#00HMOVDATA_OUT,#10100100BCALLSENDORLP5,#80HMAIN://MOVR0,0X00//SUBBCPT1CN,R0//JNZMAINMOVA,CPT1CN;等待有键按下,发送读键盘指令ANLA,#40HJNZMAINMOVDATA_OUT,#00010101B;CALLSENDCALLRECEIVEANLP5,#80HCALLSEARCHMOVA,R2ANLA,#0FHMOVDATA_OUT2,AMOVA,R2SWAPAANLA,#0FHMOVDATA_OUT1
5、,AMOVA,R3ANLA,#0FHMOVDATA_OUT4,AMOVA,R3SWAPAANLA,#0FHMOVDATA_OUT3,AMOVDATA_OUT,#10100100BCALLSENDMOVDATA_OUT,#11001011BCALLSENDMOVDATA_OUT,DATA_OUT1CALLSENDMOVDATA_OUT,#11001010BCALLSENDMOVDATA_OUT,DATA_OUT2CALLSENDMOVDATA_OUT,#11001001BCALLSENDMOVDATA_OUT,DATA_
6、OUT3CALLSENDMOVDATA_OUT,#11001000BCALLSENDMOVDATA_OUT,DATA_OUT4CALLSEND//MOVB,#10//MOVA,DATA_IN//DIVAB//MOVTEN,A//MOVDATA_OUT,#10100001B//CALLSEND//MOVDATA_OUT,#10100001B//CALLSEND//MOVDATA_OUT,#10000001B//CALLSEND//MOVDATA_OUT,TEN//CALLSEND//MOVDATA_OUT,#100000
7、00B//CALLSEND//MOVDATA_OUT,B//CALLSENDANLP5,#80HWAIT:MOVA,CPT1CN;等待按键放开ANLA,#40HORLA,#00HJZWAITJMPMAINSEND:MOVBIT_COUNT,#8;发送字符子程序ANLP5,#00HCALLLONG_DELAYSEND_LOOP:MOVC,DATA_OUT.7MOVDAT,CSETBCLKMOVA,DATA_OUTRLAMOVDATA_OUT,ACALLSHORT_DELAYCLRCLKCALLSHORT_DELAYDJN
8、ZBIT_COUNT,SEND_LOOPCLRDATRETRECEIVE:MOVBIT_COUNT,#8;接收字符子程序SETBDATCALLLONG_DELAYRECEIVE_LOOP:SETBCLKCALLLONG_DELAYMOVA,DATA_INRLAMOVDATA_IN,AMOVC,DATMOVDATA_IN.0,CCL