eskysky
发布于 2019-12-19 / 12 阅读
0

有加减确认键的24分钟数码管计时程序(汇编)

上次制作了24分钟计时程序(点击跳转),现在再在之前的基础上增加加、减、确认键。 功能:初始状态时数码管显示。按下加一键数码管显示的数字加一,按下减一键数码管显示的数字减一,按下确认键开始计时。计时到23分钟59秒时自动清零,重新计时。 电路图如下: 有加减确认键的24分钟数码管计时电路图 汇编程序代码:
  ORG 0000H
  AJMP MAIN
  ORG 0030H
MAIN:	SETB P1.0;加一键
  SETB P1.1;减一键
  SETB P1.2;确认键
  MOV 30H,#0
  MOV 31H,#0
  MOV 32H,#0
  MOV 33H,#0
  MOV 34H,#5
  ACALL DISP
CX:	JNB P1.0,ADDYI
  JNB P1.1,JIANYI
  JNB P1.2,QUEREN
  AJMP CX

ADDYI:	MOV A,31H
  CJNE A,#2,B4
  MOV A,32H
  CJNE A,#4,B4
  MOV A,31H
  CJNE A,#2,B1
  MOV A,32H
  CJNE A,#4,B1
  MOV 31H,#0
  MOV 32H,#0
  MOV 33H,#0
  MOV 34H,#0
  ACALL DISP
  ACALL XDELAY
  AJMP CX
B4:	MOV A,32H
  CJNE A,#9,B1
  MOV A,33H
  CJNE A,#5,B2
  MOV A,34H
  CJNE A,#9,B3
  INC 31H
  MOV 32H,#0
  MOV 33H,#0
  MOV 34H,#0
  ACALL DISP
  ACALL XDELAY
  AJMP CX
B1:	MOV A,33H
  CJNE A,#5,B2
  MOV A,34H
  CJNE A,#9,B3
  INC 32H
  MOV 33H,#0
  MOV 34H,#0
  ACALL DISP
  ACALL XDELAY
  AJMP CX
B2:	MOV A,34H
  CJNE A,#9,B3
  INC 33H
  MOV 34H,#0
  ACALL DISP
  ACALL XDELAY
  AJMP CX
B3:	INC 34H
  ACALL DISP
  ACALL XDELAY
  AJMP CX

QUEREN:	AJMP QUEREN1

JIANYI:	MOV A,31H
  CJNE A,#0,C1
  MOV A,32H
  CJNE A,#0,C2
  MOV A,33H
  CJNE A,#0,C3
  MOV A,34H
  CJNE A,#0,C4
  MOV 31H,#2
  MOV 32H,#4
  MOV 33H,#9
  MOV 34H,#9
  ACALL DISP
  ACALL XDELAY
  AJMP CX
C1:	MOV A,32H
  CJNE A,#0,C2
  MOV A,33H
  CJNE A,#0,C3
  MOV A,34H
  CJNE A,#0,C4
  DEC 31H
  MOV 32H,#9
  MOV 33H,#9
  MOV 34H,#9
  ACALL DISP
  ACALL XDELAY
  AJMP CX
C2:	MOV A,33H
  CJNE A,#0,C3
  MOV A,34H
  CJNE A,#0,C4
  DEC 32H
  MOV 33H,#9
  MOV 34H,#9
  ACALL DISP
  ACALL XDELAY
  AJMP CX
C3:	MOV A,34H
  CJNE A,#0,C4
  DEC 33H
  MOV 34H,#9
  ACALL DISP
  ACALL XDELAY
  AJMP CX
C4:	DEC 34H
  ACALL DISP
  ACALL XDELAY
  AJMP CX

QUEREN1:MOV A,31H
  CJNE A,#2,A1
  MOV A,32H
  CJNE A,#4,A1
  AJMP MAIN

A1:	INC 34H
  ACALL DELAY
  ACALL DISP
  MOV A,34H
  CJNE A,#9,QUEREN1
  
  INC 33H
  MOV 34H,#0
  MOV A,33H
  CJNE A,#6,QUEREN1
  
  INC 32H
  MOV 33H,#0
  MOV 34H,#0
  ACALL DELAY
  ACALL DISP
  MOV A,32H
  CJNE A,#10,QUEREN1
                               
  INC 31H
  MOV 34H,#0
  MOV 32H,#0
  MOV 33H,#0
  ACALL DELAY
  ACALL DISP
  MOV A,32H
  CJNE A,#10,QUEREN1
  AJMP ABC1

ABC1:	MOV 31H,#0
  MOV 32H,#0
  ACALL DELAY
  AJMP QUEREN1

DISP:	MOV  R0,#30H;显示子程序
  MOV 41H,#5
M1:	MOV DPTR,#TAB
  MOV A,@R0
  MOVC A,@A+DPTR
  MOV 40H,#8
M0:	RLC A
  MOV P2.7,C;给数码管传递数据
   	CLR P2.6
  SETB P2.6;给数码管送上升沿脉冲
 	DJNZ 40H,M0
  INC R0
  DJNZ 41H,M1
  RET

DELAY:	MOV 60H,#40
DEL2:	MOV 61H,#10
DEL1:	MOV 62H,#7DH
DEL0:	NOP
  NOP
  DJNZ 62H,DEL0
  DJNZ 61H,DEL1
  DJNZ 60H,DEL2
  RET

XDELAY:	MOV 63H,#50;消除按键抖动延时子程序
XDEL2:	MOV 64H,#10
XDEL1:	MOV 65H,#7DH
XDEL0:	NOP
  NOP
  DJNZ 65H,XDEL0
  DJNZ 64H,XDEL1
  DJNZ 63H,XDEL2
  RET

TAB: 	DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,67H
  
  END

本文版权归逸云蓝天所有,转载请注明出处并添加本文链接。