三維坐標(biāo)調(diào)整的單片機(jī)實(shí)驗(yàn)
;;;;;;;;;;;;;;;;;;;;;;;;;
ORG 0H ;程序代碼由地址0開始執(zhí)行
MAIN:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;啟動(dòng)數(shù)據(jù)顯示
SX:JBYX,XX1
JNBYX,$
AJMPB_J
XX1:JBQD,XX2
JNBQD,$
AJMP S_T_D
XX2: LCALL LSLED
AJMP SX
RET
;;;;;;;;;;;;;;;;;;;;;;;;;運(yùn)行時(shí)數(shù)碼管顯示
LSLED:
;LCALLLED1
;LCALL LED2
;RET
MOVP3,#0D0H
LCALL LED_1
INCP3
LCALL LED_2
INCP3
LCALL LED_3
INCP3
LCALL LED_4
INCP3
LCALL LED_5
INCP3
LCALL LED_6
INCP3
LCALL LED_7
INCP3
LCALL LED_8
INCP3
LCALL LED_9
INCP3
LCALL LED_10
INCP3
LCALL LED_11
INCP3
LCALL LED_12
INCP3
LCALL LED_13
INCP3
LCALL LED_14
INCP3
LCALL LED_15
INCP3
LCALL LED_16
INCP3
LCALL LED_17
INCP3
LCALL LED_18
INCP3
LCALL LED_19
INCP3
LCALL LED_20
INCP3
LCALL LED_21
INCP3
LCALL LED_22
INCP3
LCALL LED_23
INCP3
LCALL LED_24
RET
LED1:
MOVLSL,#0D0H
MOVR1,#60H
LED1_1:
MOVXA,@R1
MOVP3,LSL
LCALL LED
INCLSL
INCR1
MOVA,LSL
CJNEA,#0DFH,LED1_1
MOVR1,#30H
MOVA,LSL
CJNEA,#0E7H,LED1_1
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;運(yùn)行數(shù)據(jù)調(diào)用
B_J:JBYX,B_J_0
JNBYX,$
AJMPSX
B_J_0:LCALLL_S_X_L
LCALLB_J_L
LCALLL_S_L_X
LCALLL_S_Y_L
LCALLB_J_L
LCALLL_S_L_Y
LCALLL_S_Z_L
LCALLB_J_L
LCALLL_S_L_Z
MOVYANS,#5;;;;;;;;;;;;;;;;;;;;;加一數(shù)據(jù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C YANS
LCALL LSLED
MOV@R0,LS
LJMP S_T_D_A
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;數(shù)據(jù)判斷
S_L:
SETB SI
SETB SD
JB SI,S_J
JNB SI,$
CJNE A,#9,S_E
MOV A,#9
AJMP S_J
S_E:INC A
S_J:JB SD,S_E3
JNB SD,$
CJNE A,#0,S_E2
MOV A,#0
AJMP S_E3
S_E2: DEC A
S_E3:RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;數(shù)碼管顯示
LED: MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV P1,A
LCALL DELAY1
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LED_1:MOV A,LXQ
LCALL LED
RET
LED_2:MOV A,LXB
LCALL LED
RET
LED_3:MOV A,LXS
LCALL LED
RET
LED_4:MOV A,LXG
LCALL LED
RET
LED_5:MOV A,LYQ
LCALL LED
RET
LED_6:MOV A,LYB
LCALL LED
RET
LED_7: MOV A,LYS
LCALL LED
RET
LED_8:MOV A,LYG
LCALL LED
RET
LED_9:MOV A,LZQ
LCALL LED
RET
LED_10: MOV A,LZB
LCALL LED
RET
LED_11:MOV A,LZS
LCALL LED
RET
LED_12:MOV A,LZG
LCALL LED
RET
LED_13:MOV A,MXQ
LCALL LED
RET
LED_14:MOV A,MXB
LCALL LED
RET
LED_15:MOV A,MXS
LCALL LED
RET
LED_16:MOV A,MXG
LCALL LED
RET
LED_17:MOV A,MYQ
LCALL LED
RET
LED_18:MOV A,MYB
LCALL LED
RET
LED_19: MOV A,MYS
LCALL LED
RET
LED_20:MOV A,MYG
LCALL LED
RET
LED_21:MOV A,MZQ
LCALL LED
RET
LED_22: MOV A,MZB
LCALL LED
RET
LED_23:MOV A,MZS
LCALL LED
RET
LED_24:MOV A,MZG
LCALL LED
RET
TABLE:
DB 0C0H ;"0"
DB 0F9H ;"1"
DB 0A4H ;"2"
DB 0B0H ;"3"
DB 99H ;"4"
DB 92H ;"5"
DB 82H ;"6"
DB 0F8H ;"7"
DB 80H ;"8"
DB 90H ;"9"
DB0FFH
DB0FFH
DB0FFH
DB0FFH
DB0FFH
DB0FFH
DELAY1:
MOV R7,#10
L1: MOV R6,#50
DJNZ R6,$
DJNZ R7,L1
RET
END
評(píng)論