四人抢答器程序代码 河北工业大学 单片机课设
发布时间:2021-06-05
发布时间:2021-06-05
嘿嘿
ORG 0
AJMP MAIN
ORG 3
AJMP START
org 13h
AJMP ONE
ORG 1BH
AJMP TIME
ORG 50H
main: SETB EA
SETB EX0
SETB IT0
SETB IT1
SETB EX1
SETB ET1
MOV R7,#0AH ;写入字形码
MOV R1,#50H
MOV DPTR,#TAB
WRITE: CLR A
MOVC A,@A+DPTR
MOV @R1,A
INC R1
INC DPTR
DJNZ R7,WRITE
;****************************屏幕扫描显示
MOV 32H,#0FFH
MOV 4FH,#0C0H
MOV R7,#30H
MOV R0,#52H
MOV R1,#50H
DISP:
MOV A,#8
MOV P2,A
MOV P0,@R1
MOV P0,#0FFH
RR A
MOV P2,A
MOV P0,@R0
MOV P0,#0FFH
RR A
RR A
MOV P2,A
MOV P0,32H ;32H存号码
MOV P0,#0FFH
SJMP DISP
;每隔一定时间减一秒
TIME:
MOV TMOD,#0
MOV TH1,#0
MOV TL1,#0
DJNZ R7,DD
MOV R7,#30H
CJNE R1,#50H,GO
MOV R1,#5AH
DEC R0
CJNE R0,#4FH,GO
SETB EX1;允许抢答
CLR P1.7 ;开灯
CLR TR1;停止计时
MOV R1,#50H;装入初值
MOV R0,#52H
SJMP DD
GO: DEC R1
SETB TR1
DD:
RETI
;开始抢答中断
START: SETB p1.7 ;关灯
setb ex1 ;抢答
MOV 32H,#0FFH ;号码位清除
MOV R7,#30H ;计时
setb tr1
RETI
ONE:
CLR TR1
JB P1.0,TWO
MOV 32H,#0F9H
SJMP BACK
TWO: JB P1.1, THREE
MOV 32H,#0A4H
SJMP BACK
THREE:JB P1.2,FOUR
MOV 32H,#0B0H
SJM
P BACK
FOUR:
MOV 32H,#99H
SJMP BACK
BACK: CLR EX1 ;关闭抢答中断
RETI
TAB :DB 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h
END