AT89C51单片机的六路抢答器程序设计

2025-01-24 05:35:16
推荐回答(1个)
回答1:

FALSE1: ACALL BARK ;按键发声
MOV R3,#01H
AJMP ERROR
FALSE2: ACALL BARK
MOV R3,#02H
AJMP ERROR
FALSE3: ACALL BARK
MOV R3,#03H
AJMP ERROR
FALSE4: ACALL BARK
MOV R3,#04H
AJMP ERROR
FALSE5: ACALL BARK
MOV R3,#05H
AJMP ERROR
FALSE6: ACALL BARK
MOV R3,#06H
AJMP ERROR

;=====INT0(抢答时间R1调整程序)=====
INT0SUB:MOV A,R1
MOV B,#0AH
DIV AB
MOV R5,A
MOV R4,B
MOV R3,#0AH
ACALL DISPLAY ;先在两个时间LED上显示R1
JNB P3.4,INC0 ;P3.4为+1s键,如按下跳到INCO
JNB P3.5,DEC0 ;P3.5为-1s键,如按下跳到DECO
JNB P1.7,BACK0 ;P3.1为确定键,如按下跳到BACKO
AJMP INT0SUB
INC0: MOV A,R1
CJNE A,#63H,ADD0 ;如果不是99,R2加1,如果加到99了,R1就置0,重新加起。
MOV R1,#00H
ACALL DELAY1
AJMP INT0SUB
ADD0: INC R1
ACALL DELAY1
AJMP INT0SUB
DEC0: MOV A,R1
JZ SETR1 ;如果R1为0, R1就置99,
DEC R1
ACALL DELAY1
AJMP INT0SUB
SETR1: MOV R1,#63H
ACALL DELAY1
AJMP INT0SUB
BACK0: RETI
;=====INT1(回答时间R2调整程序)=====
INT1SUB:
MOV A,R2
MOV B,#0AH
DIV AB
MOV R5,A
MOV R4,B
MOV R3,#0AH
ACALL DISPLAY
JNB P3.4,INC1
JNB P3.5,DEC1
JNB P1.7,BACK1
AJMP INT1SUB
INC1: MOV A,R2
CJNE A,#63H,ADD1
MOV R2,#00H
ACALL DELAY1
AJMP INT1SUB
ADD1: INC R2
ACALL DELAY1
AJMP INT1SUB
DEC1: MOV A,R2
JZ SETR2
DEC R2
ACALL DELAY1
AJMP INT1SUB
SETR2: MOV R2,#63H
ACALL DELAY1
AJMP INT1SUB
BACK1: RETI