Holtek49时钟程序

2006-12-02 12:00:01

技术资料 单片机

include ht49r30a-1.inc
DATA .SECTION 'DATA'
HOU DB ?
MIN DB ?
SEC DB ?
HOU_G DB ?
MIN_G DB ?
SEC_G DB ?
HOU_S DB ?
MIN_S DB ?
SEC_S DB ?
DAY DB ?
DAY_G DB ?
DAY_S DB ?
DIAN DB ?
;-------------------------------------
CODE .SECTION 'CODE'
ORG 000H
JMP START
ORG 004H
RETI
ORG 008H
RETI
ORG 00CH
RETI
ORG 010H
RETI
ORG 014H
JMP RTCINT
ORG 020H
START: MOV A,55H
MOV SEC,A
MOV A,59H
MOV MIN,A
MOV A,23H
MOV HOU,A
MOV A,30H
MOV DAY,A
CLR INTC0
CLR INTC1
SET ERTI
SET EMI
MOV A,07H
MOV RTCC,A
LOOP: CALL DISPLAY
JMP LOOP
DISPLAY: MOV A,01H
MOV BP,A
MOV A,40H
MOV MP1,A
MOV A,SEC_G
CALL DISP_PRO

MOV A,42H
MOV MP1,A
MOV A,SEC_S
CALL DISP_PRO

MOV A,44H
MOV MP1,A
MOV A,MIN_G
CALL DISP_PRO

MOV A,46H
MOV MP1,A
MOV A,MIN_S
CALL DISP_PRO

MOV A,48H
MOV MP1,A
MOV A,HOU_G
CALL DISP_PRO

MOV A,4AH
MOV MP1,A
MOV A,HOU_S
CALL DISP_PRO

MOV A,4CH
MOV MP1,A
MOV A,DAY_G
CALL DISP_PRO

MOV A,4EH
MOV MP1,A
MOV A,DAY_S
CALL DISP_PRO

RET

DISP_PRO: MOV TBLP,A
TABRDL ACC
MOV R1,A
SWAP ACC
INC MP1
MOV R1,A
RET

RTCINT: INC SEC
MOV A,SEC
DAA SEC
MOV A,SEC
XOR A,60H
SZ ACC
JMP RET0
MOV A,00h
MOV SEC,A

INC MIN
MOV A,MIN
DAA MIN
MOV A,MIN
XOR A,60H
SZ ACC
JMP RET0
MOV A,00h
MOV MIN,A

INC HOU
MOV A,HOU
DAA HOU
MOV A,HOU
XOR A,24H
SZ ACC
JMP RET0
MOV A,00H
MOV HOU,A

INC DAY
MOV A,DAY
DAA DAY
MOV A,DAY
XOR A,31H
SZ ACC
JMP RET0
MOV A,01H
MOV DAY,A

RET0: MOV A,SEC
AND A,0FH
MOV SEC_G,A
SWAPA SEC
AND A,0FH
MOV SEC_S,A
MOV A,MIN
AND A,0FH
MOV MIN_G,A
SWAPA MIN
AND A,0FH
MOV MIN_S,A
MOV A,HOU
AND A,0FH
MOV HOU_G,A
SWAPA HOU
AND A,0FH
MOV HOU_S,A
MOV A,DAY
AND A,0FH
MOV DAY_G,A
SWAPA DAY
AND A,0FH
MOV DAY_S,A

RETI

ORG 700H
DISPTAB: DC 03FH,06H,5BH,4FH,66H
DC 6DH,7DH,07H,7FH,6FH
END