BIAO EQU 50H
DIS1 EQU 51H
DIS2 EQU 52H
DIS3 EQU 53H
DIS4 EQU 54H
CLK EQU P1.1
DAT EQU P1.2
CE EQU P1.3
CKO EQU P3.1
DAO EQU P3.0
VOL EQU 22H
PRE EQU 55H
;程序开始
ORG 0000H
AJMP MAIN
ORG 0030H
MAIN:
CLR P1.0
MOV R7,#3
WAIT: MOV DIS1,#00000010B ;阻抗检测延时画面
MOV DIS2,#00H
MOV DIS3,#00H
MOV DIS4,#00H
LCALL OUTPUTD
LCALL DELAY
MOV DIS1,#00H
MOV DIS2,#00000010B
MOV DIS3,#00H
MOV DIS4,#00H
LCALL OUTPUTD
LCALL DELAY
MOV DIS1,#00H
MOV DIS2,#00H
MOV DIS3,#00000010B
MOV DIS4,#00H
LCALL OUTPUTD
LCALL DELAY
MOV DIS1,#00H
MOV DIS2,#00H
MOV DIS3,#00H
MOV DIS4,#00000010B
LCALL OUTPUTD
LCALL DELAY
DJNZ R7,WAIT
JB P3.7,HIG
LW: MOV DIS4,#00011100B
MOV PRE,#189
AJMP NORM
HIG: MOV DIS4,#01101110B
MOV PRE,#252
AJMP NORM
NORM: SETB P1.0
MOV VOL,#00H
MOV DIS1,#00H
MOV DIS2,#00H
MOV DIS3,#00H
LCALL OUTPUT
LCALL DISPLAY
SWEEP: MOV 20H,#00H ;位寻址单元清0
CALL JIAN ;判断是否有键按下
MOV A,20H
CJNE A,#00H,YES
AJMP SWEEP
;判键子程序
JIAN:
JB P1.6,SS
SETB 00H
AJMP KK
SS: JB P1.7,KK
SETB 01H
KK: RET
YES: CALL DEL10MS ;按键消抖
MOV A,20H
CJNE A,#01H,RRR
JNB P1.6,UP
AJMP SWEEP
RRR: JNB P1.7,DOWN
AJMP SWEEP
UP: MOV A,VOL
CJNE A,PRE,A1
AJMP SWEEP
A1: INC VOL
MOV A,DIS3
CJNE A,#9,A2
MOV DIS3,#0
MOV A,DIS2
CJNE A,#9,A3
MOV DIS2,#0
INC DIS1
AJMP DDQ
A3: INC DIS2
AJMP DDQ
A2: INC DIS3
DDQ: LCALL DISPLAY
LCALL OUTPUT
LCALL DELY
AJMP SWEEP
DOWN: MOV A,VOL
CJNE A,#00,B1
AJMP SWEEP
B1: DEC VOL
MOV A,DIS3
CJNE A,#0,B2
MOV DIS3,#9
MOV A,DIS2
CJNE A,#0,B3
MOV DIS2,#9
DEC DIS1
AJMP DDQ
B3: DEC DIS2
AJMP DDQ
B2: DEC DIS3
AJMP DDQ
OUTPUT: ; PGA2310控制自发送子程序
MOV A,VOL
CLR CE
LCALL PUT
MOV A,VOL
LCALL PUT
SETB CE
CLR DAT
CLR CLK
RET
PUT: MOV R3,#8
CLR C
PUT1: RLC A
MOV DAT,C
NOP
NOP
NOP
NOP
NOP
SETB CLK
NOP
NOP
NOP
NOP
NOP
CLR CLK
DJNZ R3,PUT1
RET
DISPLAY: ;显示转换
PUSH DIS1
PUSH DIS2
PUSH DIS3
TRAN3: MOV A,DIS3
CJNE A,#00,T1
MOV DIS3,#11111100B
AJMP TRAN2
T1: CJNE A,#01,T2
MOV DIS3,#01100000B
AJMP TRAN2
T2: CJNE A,#02,T3
MOV DIS3,#11011010B
AJMP TRAN2
T3: CJNE A,#03,T4
MOV DIS3,#11110010B
AJMP TRAN2
T4: CJNE A,#04,T5
MOV DIS3,#01100110B
AJMP TRAN2
T5: CJNE A,#05,T6
MOV DIS3,#10110110B
AJMP TRAN2
T6: CJNE A,#06,T7
MOV DIS3,#10111110B
AJMP TRAN2
T7: CJNE A,#07,T8
MOV DIS3,#11100000B
AJMP TRAN2
T8: CJNE A,#08,T9
MOV DIS3,#11111110B
AJMP TRAN2
T9: MOV DIS3,#11110110B
AJMP TRAN2
TRAN2: MOV A,DIS1
CJNE A,#00,TA
MOV A,DIS2
CJNE A,#00,T11
MOV DIS2,#00000000B
AJMP TRAN1
TA: MOV A,DIS2
CJNE A,#00,T11
MOV DIS2,#11111100B
AJMP TRAN1
T11: CJNE A,#01,T12
MOV DIS2,#01100000B
AJMP TRAN1
T12: CJNE A,#02,T13
MOV DIS2,#11011010B
AJMP TRAN1
T13: CJNE A,#03,T14
MOV DIS2,#11110010B
AJMP TRAN1
T14: CJNE A,#04,T15
MOV DIS2,#01100110B
AJMP TRAN1
T15: CJNE A,#05,T16
MOV DIS2,#10110110B
AJMP TRAN1
T16: CJNE A,#06,T17
MOV DIS2,#10111110B
AJMP TRAN1
T17: CJNE A,#07,T18
MOV DIS2,#11100000B
AJMP TRAN1
T18: CJNE A,#08,T19
MOV DIS2,#11111110B
AJMP TRAN1
T19: MOV DIS2,#11110110B
AJMP TRAN1
TRAN1: MOV A,DIS1
CJNE A,#00,T21
MOV DIS1,#00000000B
AJMP OVER
T21: CJNE A,#01,T22
MOV DIS1,#01100000B
AJMP OVER
T22: CJNE A,#02,T23
MOV DIS1,#11011010B
AJMP OVER
T23: CJNE A,#03,T24
MOV DIS1,#11110010B
AJMP OVER
T24: CJNE A,#04,T25
MOV DIS1,#01100110B
AJMP OVER
T25: CJNE A,#05,T26
MOV DIS1,#10110110B
AJMP OVER
T26: CJNE A,#06,T27
MOV DIS1,#10111110B
AJMP OVER
T27: CJNE A,#07,T28
MOV DIS1,#11100000B
AJMP OVER
T28: CJNE A,#08,T29
MOV DIS1,#11111110B
AJMP OVER
T29: MOV DIS1,#11110110B
AJMP OVER
OVER: INC DIS3
LCALL OUTPUTD
LCALL DELY
POP DIS3
POP DIS2
POP DIS1
RET
OUTPUTD:
MOV A,DIS4
LCALL PUTD
MOV A,DIS3
LCALL PUTD
MOV A,DIS2
LCALL PUTD
MOV A,DIS1
LCALL PUTD
RET
PUTD: MOV R3,#8
CLR C
PUTD1: RRC A
MOV DAO,C
NOP
NOP
SETB CKO
NOP
NOP
CLR CKO
DJNZ R3,PUTD1
RET
DELY: MOV R7,#10
DDD: CALL DEL10MS
DJNZ R7,DDD
RET
DEL10MS:
MOV 48H,R7
MOV 49H,R6
MOV R7,#40
DD: MOV R6,#50
DJNZ R6,$
DJNZ R7,DD
MOV R6,49H
MOV R7,48H
RET
DELAY: MOV R5,#250
D11: MOV R4,#250
D21: MOV R3,#4
D31: DJNZ R3,D31
DJNZ R4,D21
DJNZ R5,D11
RET
END
文章评论(0条评论)
登录后参与讨论