LED数字钟的设计(电子数字时钟的设计)
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/20 18:13:20
LED数字钟的设计(电子数字时钟的设计)
电子数字时钟的设计
采用单片机(如:AT89C2051)、LED 数码管等设计数字时钟,系统设有5个按键,能实现时间的调整、定时时间的设定,输出等功能
电子数字时钟的设计
采用单片机(如:AT89C2051)、LED 数码管等设计数字时钟,系统设有5个按键,能实现时间的调整、定时时间的设定,输出等功能
LED0 EQU 3AH
LED1 EQU 3BH
LED2 EQU 3CH
LED3 EQU 3DH
LED4 EQU 3EH
LED5 EQU 3FH
CSEC EQU 30H
SEC EQU 31H
MINI EQU 32H
HOUR EQU 33H
SETV BIT 01H
SJH EQU 0C5H
SJL EQU 68H
BCDCODE EQU 35H
CURSHIF EQU 36H
CURTIME EQU 37H
DELms1 EQU 38H
DELms2 EQU 39H
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP TIMECOUNT
ORG 0050H
MAIN:MOV SP,#60H
MOV CSEC,#00H
MOV SEC,#58H
MOV MINI,#59H
MOV HOUR,#23H
MOV BCDCODE,#00H
MOV CURTIME,#00H
MOV DELms1,#00H
MOV DELms2,#00H
CLR SETV
MOV DPTR,#0FF24H ;#7FFFH
MOV A,#80H
MOVX @DPTR,A
MOV TMOD,#01H
MOV TH0,#SJH
MOV TL0,#SJL
SETB EA
SETB ET0
SETB TR0
LOOP0:LCALL CZ
LCALL DISPLAY
LCALL KEYSCAN
JNZ LOOP1
LJMP LOOP0
LOOP1:LCALL KEYRES
LJMP LOOP0
TIMECOUNT:CLR EA
PUSH ACC
PUSH PSW
SETB EA
MOV TH0,#SJH
MOV TL0,#SJL
MOV A,CSEC
ADD A,#1
MOV CSEC,A
CJNE A,#64H,TIMERET
MOV CSEC,#00H
MOV A,SEC
ADD A,#1
DA A
MOV SEC,A
CJNE A,#60H,TIMERET
MOV SEC,#00H
MOV A,MINI
ADD A,#1
DA A
MOV MINI,A
CJNE A,#60H,TIMERET
MOV MINI,#00H
MOV A,HOUR
ADD A,#1
DA A
MOV HOUR,A
CJNE A,#24H,TIMERET
MOV HOUR,#00H
TIMERET:CLR EA
POP PSW
POP ACC
SETB EA
RETI
CZ:SETB RS1
MOV R7,#03H
MOV R0,#SEC
MOV R1,#LED0
LOOP2:MOV A,@R0
ANL A,#0FH
MOV @R1,A
INC R1
MOV A,@R0
ANL A,#0F0H
SWAP A
MOV @R1,A
INC R0
INC R1
DJNZ R7,LOOP2
CLR RS1
RET
DISPLAY:SETB RS0
MOV R4,#00100000B
MOV R5,#06H
MOV R0,#LED5
LOOP3:MOV DPTR,#TAB0
MOV A,@R0
MOVC A,@A+DPTR
MOV DPTR,#0FF22H ; #7FFCH
MOVX @DPTR,A
MOV DPTR,#0FF21H ;#7FFDH
MOV A,R4
MOVX @DPTR,A
MOV DELms1,#1
LCALL DELAY
DEC R0
MOV A,R4
RR A
MOV R4,A
DJNZ R5,LOOP3
CLR RS0
RET
TAB0:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFH
DELAY:MOV DELms2,#250
DEL_HERE:DJNZ DELms2,DEL_HERE
DJNZ DELms1,DELAY
RET
KEYSCAN:MOV A,#7FH
MOV P1,A
MOV A,P1
CPL A
ANL A,#7FH
RET
KEYRES :LCALL CZ
LCALL DISPLAY
LCALL CZ
LCALL DISPLAY
LCALL KEYSCAN
JNZ LOOP4
KEY_RET:RET
LOOP4:PUSH ACC
LOOP4E:LCALL CZ
LCALL DISPLAY
LCALL KEYSCAN
JNZ LOOP4E
POP ACC
JB ACC.0 ,LOOP40
JB ACC.1,LOOP41
JB ACC.2,LOOP42
JB ACC.3 ,LOOP43
JB ACC.6,LOOP46
LJMP KEY_RET
LOOP40:LJMP KEY_SET
LOOP41:LJMP KEY_SHIFT
LOOP42:LJMP KEY_UP
LOOP43:LJMP KEY_DOWN
LOOP46:LJMP KEY_ENTER
KEY_SET:JB SETV,KEY_SET_RET
SETB SETV
CLR TR0
MOV CURSHIF,#HOUR
MOV R0,CURSHIF ;;
MOV CURTIME,@R0
MOV @R0,#0AAH
KEY_SET_RET:LJMP KEY_RET
KEY_SHIFT:JNB SETV,KEY_SHIFT_RET
MOV R0,CURSHIF
CJNE @R0,#0AAH,KEY_SHIFT0
MOV @R0,CURTIME
KEY_SHIFT0:CJNE R0,#SEC,KEY_SHIFT2
KEY_SHIFT1:MOV R0,#HOUR
MOV CURSHIF,R0
MOV CURTIME,@R0
MOV @R0,#0AAH
LJMP KEY_SHIFT_RET
KEY_SHIFT2:DEC R0
MOV CURSHIF,R0
MOV CURTIME,@R0
MOV @R0,#0AAH
KEY_SHIFT_RET:LJMP KEY_RET
KEY_UP:JNB SETV,KEY_UP_RET
MOV R0,CURSHIF
CJNE @R0,#0AAH,KEY_UP0
MOV @R0,CURTIME
KEY_UP0:CJNE R0,#HOUR,KEY_UP2
KEY_UP1:CJNE @R0,#23H,KEY_UP11
KEY_UP11:JC KEY_UP12
MOV @R0,#0
MOV CURTIME,@R0
LJMP KEY_UP_RET
KEY_UP12:MOV A,#1
ADD A,@R0
DA A
MOV @R0,A
;INC @R0
;MOV BCDCODE,@R0
;LCALL CONV_TO_BCD
;MOV @R0,BCDCODE
MOV CURTIME,@R0
LJMP KEY_UP_RET
KEY_UP2:CJNE @R0,#59H,KEY_UP21
KEY_UP21:JC KEY_UP22
MOV @R0,#0
MOV CURTIME,@R0
LJMP KEY_UP_RET
KEY_UP22:MOV A,#1
ADD A,@R0
DA A
MOV @R0,A
;INC @R0
;MOV BCDCODE,@R0
;LCALL CONV_TO_BCD
;MOV @R0,BCDCODE
MOV CURTIME,@R0
KEY_UP_RET:LJMP KEY_RET
KEY_DOWN:JNB SETV,KEY_DOWN_RET
NOP
; MOV R0,CURSHIF
; CJNE @R0,#0AAH,KEY_DOWN0
; MOV @R0,CURTIME
;KEY_DOWN0:CJNE R0,#HOUR,KEY_DOWN2
;KEY_DOWN1:CJNE @R0,#01H,KEY_DOWN11
;KEY_DOWN11:JNC KEY_DOWN12
; MOV @R0,#23H
; LJMP KEY_DOWN_RET
;KEY_DOWN12:;DEC @R0
; MOV BCDCODE,@R0
; LCALL CONV_TO_BCD
; MOV @R0,BCDCODE
; LJMP KEY_DOWN_RET
;KEY_DOWN2:CJNE @R0,#01H,KEY_DOWN21
;KEY_DOWN21:JNC KEY_DOWN22
; MOV @R0,#59H
; LJMP KEY_DOWN_RET
;KEY_DOWN22:;DEC @R0
; MOV BCDCODE,@R0
; LCALL CONV_TO_BCD
; MOV @R0,BCDCODE
KEY_DOWN_RET:LJMP KEY_RET
KEY_ENTER:JNB SETV,KEY_ENTER_RET
MOV R0,CURSHIF
CJNE @R0,#0AAH,KEY_ENTER0
MOV @R0,CURTIME
KEY_ENTER0:CLR SETV
SETB TR0
KEY_ENTER_RET:LJMP KEY_RET
CONV_TO_BCD:PUSH ACC
PUSH B
MOV A,BCDCODE
ANL A,#0F0H
MOV B,#10
MUL AB
ORL BCDCODE,#0FH
ADD A,BCDCODE
DEC A
MOV BCDCODE,A
;
MOV B,#10
DIV AB
ANL A,#0FH
SWAP A
MOV BCDCODE,A
MOV A,B
ANL A,#0FH
ORL BCDCODE,A
; MOV A,BCDCODE
;MOV B,#10
; DIV AB
; ANL A,#0FH
; SWAP A
; MOV BCDCODE,A
;MOV A,B
; ANL A,#0FH
; ORL BCDCODE,A
POP B
POP ACC
RET
END
LED1 EQU 3BH
LED2 EQU 3CH
LED3 EQU 3DH
LED4 EQU 3EH
LED5 EQU 3FH
CSEC EQU 30H
SEC EQU 31H
MINI EQU 32H
HOUR EQU 33H
SETV BIT 01H
SJH EQU 0C5H
SJL EQU 68H
BCDCODE EQU 35H
CURSHIF EQU 36H
CURTIME EQU 37H
DELms1 EQU 38H
DELms2 EQU 39H
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP TIMECOUNT
ORG 0050H
MAIN:MOV SP,#60H
MOV CSEC,#00H
MOV SEC,#58H
MOV MINI,#59H
MOV HOUR,#23H
MOV BCDCODE,#00H
MOV CURTIME,#00H
MOV DELms1,#00H
MOV DELms2,#00H
CLR SETV
MOV DPTR,#0FF24H ;#7FFFH
MOV A,#80H
MOVX @DPTR,A
MOV TMOD,#01H
MOV TH0,#SJH
MOV TL0,#SJL
SETB EA
SETB ET0
SETB TR0
LOOP0:LCALL CZ
LCALL DISPLAY
LCALL KEYSCAN
JNZ LOOP1
LJMP LOOP0
LOOP1:LCALL KEYRES
LJMP LOOP0
TIMECOUNT:CLR EA
PUSH ACC
PUSH PSW
SETB EA
MOV TH0,#SJH
MOV TL0,#SJL
MOV A,CSEC
ADD A,#1
MOV CSEC,A
CJNE A,#64H,TIMERET
MOV CSEC,#00H
MOV A,SEC
ADD A,#1
DA A
MOV SEC,A
CJNE A,#60H,TIMERET
MOV SEC,#00H
MOV A,MINI
ADD A,#1
DA A
MOV MINI,A
CJNE A,#60H,TIMERET
MOV MINI,#00H
MOV A,HOUR
ADD A,#1
DA A
MOV HOUR,A
CJNE A,#24H,TIMERET
MOV HOUR,#00H
TIMERET:CLR EA
POP PSW
POP ACC
SETB EA
RETI
CZ:SETB RS1
MOV R7,#03H
MOV R0,#SEC
MOV R1,#LED0
LOOP2:MOV A,@R0
ANL A,#0FH
MOV @R1,A
INC R1
MOV A,@R0
ANL A,#0F0H
SWAP A
MOV @R1,A
INC R0
INC R1
DJNZ R7,LOOP2
CLR RS1
RET
DISPLAY:SETB RS0
MOV R4,#00100000B
MOV R5,#06H
MOV R0,#LED5
LOOP3:MOV DPTR,#TAB0
MOV A,@R0
MOVC A,@A+DPTR
MOV DPTR,#0FF22H ; #7FFCH
MOVX @DPTR,A
MOV DPTR,#0FF21H ;#7FFDH
MOV A,R4
MOVX @DPTR,A
MOV DELms1,#1
LCALL DELAY
DEC R0
MOV A,R4
RR A
MOV R4,A
DJNZ R5,LOOP3
CLR RS0
RET
TAB0:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFH
DELAY:MOV DELms2,#250
DEL_HERE:DJNZ DELms2,DEL_HERE
DJNZ DELms1,DELAY
RET
KEYSCAN:MOV A,#7FH
MOV P1,A
MOV A,P1
CPL A
ANL A,#7FH
RET
KEYRES :LCALL CZ
LCALL DISPLAY
LCALL CZ
LCALL DISPLAY
LCALL KEYSCAN
JNZ LOOP4
KEY_RET:RET
LOOP4:PUSH ACC
LOOP4E:LCALL CZ
LCALL DISPLAY
LCALL KEYSCAN
JNZ LOOP4E
POP ACC
JB ACC.0 ,LOOP40
JB ACC.1,LOOP41
JB ACC.2,LOOP42
JB ACC.3 ,LOOP43
JB ACC.6,LOOP46
LJMP KEY_RET
LOOP40:LJMP KEY_SET
LOOP41:LJMP KEY_SHIFT
LOOP42:LJMP KEY_UP
LOOP43:LJMP KEY_DOWN
LOOP46:LJMP KEY_ENTER
KEY_SET:JB SETV,KEY_SET_RET
SETB SETV
CLR TR0
MOV CURSHIF,#HOUR
MOV R0,CURSHIF ;;
MOV CURTIME,@R0
MOV @R0,#0AAH
KEY_SET_RET:LJMP KEY_RET
KEY_SHIFT:JNB SETV,KEY_SHIFT_RET
MOV R0,CURSHIF
CJNE @R0,#0AAH,KEY_SHIFT0
MOV @R0,CURTIME
KEY_SHIFT0:CJNE R0,#SEC,KEY_SHIFT2
KEY_SHIFT1:MOV R0,#HOUR
MOV CURSHIF,R0
MOV CURTIME,@R0
MOV @R0,#0AAH
LJMP KEY_SHIFT_RET
KEY_SHIFT2:DEC R0
MOV CURSHIF,R0
MOV CURTIME,@R0
MOV @R0,#0AAH
KEY_SHIFT_RET:LJMP KEY_RET
KEY_UP:JNB SETV,KEY_UP_RET
MOV R0,CURSHIF
CJNE @R0,#0AAH,KEY_UP0
MOV @R0,CURTIME
KEY_UP0:CJNE R0,#HOUR,KEY_UP2
KEY_UP1:CJNE @R0,#23H,KEY_UP11
KEY_UP11:JC KEY_UP12
MOV @R0,#0
MOV CURTIME,@R0
LJMP KEY_UP_RET
KEY_UP12:MOV A,#1
ADD A,@R0
DA A
MOV @R0,A
;INC @R0
;MOV BCDCODE,@R0
;LCALL CONV_TO_BCD
;MOV @R0,BCDCODE
MOV CURTIME,@R0
LJMP KEY_UP_RET
KEY_UP2:CJNE @R0,#59H,KEY_UP21
KEY_UP21:JC KEY_UP22
MOV @R0,#0
MOV CURTIME,@R0
LJMP KEY_UP_RET
KEY_UP22:MOV A,#1
ADD A,@R0
DA A
MOV @R0,A
;INC @R0
;MOV BCDCODE,@R0
;LCALL CONV_TO_BCD
;MOV @R0,BCDCODE
MOV CURTIME,@R0
KEY_UP_RET:LJMP KEY_RET
KEY_DOWN:JNB SETV,KEY_DOWN_RET
NOP
; MOV R0,CURSHIF
; CJNE @R0,#0AAH,KEY_DOWN0
; MOV @R0,CURTIME
;KEY_DOWN0:CJNE R0,#HOUR,KEY_DOWN2
;KEY_DOWN1:CJNE @R0,#01H,KEY_DOWN11
;KEY_DOWN11:JNC KEY_DOWN12
; MOV @R0,#23H
; LJMP KEY_DOWN_RET
;KEY_DOWN12:;DEC @R0
; MOV BCDCODE,@R0
; LCALL CONV_TO_BCD
; MOV @R0,BCDCODE
; LJMP KEY_DOWN_RET
;KEY_DOWN2:CJNE @R0,#01H,KEY_DOWN21
;KEY_DOWN21:JNC KEY_DOWN22
; MOV @R0,#59H
; LJMP KEY_DOWN_RET
;KEY_DOWN22:;DEC @R0
; MOV BCDCODE,@R0
; LCALL CONV_TO_BCD
; MOV @R0,BCDCODE
KEY_DOWN_RET:LJMP KEY_RET
KEY_ENTER:JNB SETV,KEY_ENTER_RET
MOV R0,CURSHIF
CJNE @R0,#0AAH,KEY_ENTER0
MOV @R0,CURTIME
KEY_ENTER0:CLR SETV
SETB TR0
KEY_ENTER_RET:LJMP KEY_RET
CONV_TO_BCD:PUSH ACC
PUSH B
MOV A,BCDCODE
ANL A,#0F0H
MOV B,#10
MUL AB
ORL BCDCODE,#0FH
ADD A,BCDCODE
DEC A
MOV BCDCODE,A
;
MOV B,#10
DIV AB
ANL A,#0FH
SWAP A
MOV BCDCODE,A
MOV A,B
ANL A,#0FH
ORL BCDCODE,A
; MOV A,BCDCODE
;MOV B,#10
; DIV AB
; ANL A,#0FH
; SWAP A
; MOV BCDCODE,A
;MOV A,B
; ANL A,#0FH
; ORL BCDCODE,A
POP B
POP ACC
RET
END
LED数字钟的设计(电子数字时钟的设计)
数字时钟温度设计
题目二:电子时钟的设计 设计任务:1. 用8个7段LED数码管作为显示设备,设计时钟功能;(40) 2. 可以分别
数字电子日历的设计与制作
EDA设计数字时钟设计一个含有时/分/秒的时钟设计要求:1.具有'秒','分','时'时钟显示功能,在6个LED上显示小
基于MCS-51单片机的数字时钟系统设计
谁有没有multisim设计出的数字时钟啊?
翻译"基于MCS-51单片机的数字时钟系统设计"
设计数字时钟电路原理图
求数字时钟设计 电路图
eda 数字时钟我也是学电子的.能把你的EDA课程设计给我发一份吗?设计一个数字钟设计一个能显示1/10秒、秒、分、时的
数字定时时钟的电路图我要设计一个电路,第一部分是数字时钟,首先能够将现在的时间通过LED灯显示出来,其次能够定时,到达预