;只显示时分 RG_KEY EQU 30H;存储键盘值 RG_KN EQU 33H;存储调节年月日星期的次数按钮。 RG_BT1 EQU 31H;需要显示的数据暂存RAM RG_BT2 EQU 32H RG_TSC EQU 40H;时钟和闹钟暂存RAM,顺序同DS12C887中的RAM RG_ASC EQU 41H RG_TMN EQU 42H;TMN:TIME‘S MINU RG_AMN EQU 43H;AMN:ALARM’S MINUT RG_THR EQU 44H RG_AHR EQU 45H RG_WK EQU 46H RG_DAY EQU 47H RG_MTH EQU 48H RG_YR EQU 49H RG_MS EQU 51H RG_IDL EQU 50H
ORG 0000H LJMP MAIN
ORG 0030H ;Main procedure MAIN: MOV SP,#60H MOV DPTR,#000BH;闹钟中断允许 MOV A,#22H MOVX @DPTR,A MOV DPTR,#000AH;判断是否需要初始化 MOVX A,@DPTR ANL A,#01110000B CJNE A,#20H,INI_MAI LJMP LP1_MAI INI_MAI:LCALL SB_INI LP1_MAI:LCALL SB_RD LCALL SB_DSP AJMP LP1_MAI
SB_INI: PUSH ACC PUSH PSW PUSH DPH PUSH DPL MOV DPTR,#000BH ; register B of DS' MOV A,#0A2H MOVX @DPTR,A ; un-renew,BCD,24hour ;----初始化时钟,11:59
MOV DPTR,#0000H ; addr. of second MOV A,#00H MOVX @DPTR,A INC DPTR ; addr. of S'alarm MOV A,#00H MOVX @DPTR,A INC DPTR ; addr. of minute MOV A,#59H MOVX @DPTR,A INC DPTR ; addr. of M'alarm MOV A,#00H MOVX @DPTR,A INC DPTR ; addr. of hour MOV A,#11H MOVX @DPTR,A INC DPTR ; addr. of H'alarm MOV A,#00H MOVX @DPTR,A ;---初始化星期3(日), 年,月,日2008-2-20 INC DPTR MOV A,#03H MOVX @DPTR,A INC DPTR MOV A,#20H MOVX @DPTR,A INC DPTR MOV A,#02H MOVX @DPTR,A INC DPTR MOV A,#08H MOVX @DPTR,A MOV DPTR,#0032H MOV A,#20H MOVX @DPTR,A MOV DPTR,#000AH ; register A of DS' MOV A,#20H MOVX @DPTR,A ; start timebase INC DPTR ; register B of DS' MOV A,#22H MOVX @DPTR,A ; renew,permit IRQ,. INC DPTR ; register C of DS' MOVX A,@DPTR ; read to clear IRQF INC DPTR MOVX A,@DPTR POP DPL POP DPH POP PSW POP ACC RET SB_RD: PUSH ACC PUSH DPH PUSH DPL ;---读时分的时钟, MOV 23H,#08H RD1: MOV DPTR,#0002H;时钟的分 MOVX A,@DPTR MOV RG_TMN,A MOV DPTR,#0004H;时钟的时 MOVX A,@DPTR MOV RG_THR,A DJNZ 23H,RD1 POP DPL POP DPH POP ACC RET SB_DSP: PUSH ACC PUSH DPH PUSH DPL PUSH PSW MOV R1,#RG_THR MOV R6,#10H ;R6寄存器选择位 MOV R7,#2 LP1_DSP: MOV A,@R1 ANL A,#0F0H SWAP A ORL A,R6 MOV P1,A ;送到P1口 LCALL SB_DLY;调延时子程序 MOV A,R6 RL A MOV R6,A
MOV A,@R1 ANL A,#0FH ORL A,R6 MOV P1,A ;送到P1口 LCALL SB_DLY;调延时子程序 MOV A,R6 RL A MOV R6,A DEC R1 DEC R1 DJNZ R7,LP1_DSP
RT_DSP: POP PSW POP DPL POP DPH POP ACC RET
;=======延时子程序 SB_DLY: MOV 21H,#04 D1: MOV 22H,#200 DJNZ 22H,$ DJNZ 21H,D1 RET
END |