S_SET BIT P1.5 M_SET BIT P1.6 H_SET BIT P1.7 WS EQU 35H SECOND EQU 29H MINUTE EQU 30H HOUR EQU 31H TCNT EQU 34H ORG 00H SJMP START ORG 0BH LJMP INT_T0 START:MOV DPTR,#TABLE MOV HOUR,#0 MOV MINUTE,#0 MOV SECOND,#0 MOV TCNT,#0 MOV TMOD,#01H MOV TH0,#(65536-50000)/256 MOV TL0,#(65536-50000)MOD 256 MOV IE,#82H SETB TR0 A1:LCALL DISPLAY JNB S_SET,S1 JNB M_SET,S2 JNB H_SET,S3 LJMP A1 S1:LCALL DELAY JB S_SET,A1 INC SECOND MOV A,SECOND CJNE A,#60,J0 MOV SECOND,#0 LJMP K1 S2: LCALL DELAY JB M_SET,A1 K1: INC MINUTE MOV A,MINUTE CJNE A,#60,J1 MOV MINUTE,#0 LJMP K2 S3: LCALL DELAY JB H_SET,A1 K2: INC HOUR MOV A,HOUR CJNE A,#24,J2 MOV HOUR,#0 MOV MINUTE,#0 MOV SECOND,#0 LJMP A1 J0:JB S_SET,A1 LCALL DISPLAY SJMP J0 J1:JB M_SET,A1 LCALL DISPLAY SJMP J1 J2:JB H_SET,A1 LCALL DISPLAY SJMP J2 INT_T0:MOV TH0,#(65536-50000)/256 MOV TL0,#(65536-50000)MOD 256 INC TCNT MOV A,TCNT CJNE A,#20,RETUNE INC SECOND MOV TCNT,#0 MOV A,SECOND CJNE A,#60,RETUNE INC MINUTE MOV SECOND,#0 MOV A,MINUTE CJNE A,#60,RETUNE INC HOUR MOV MINUTE,#0 MOV A,HOUR CJNE A,#24,RETUNE MOV HOUR,#0 MOV MINUTE,#0 MOV SECOND,#0 MOV TCNT,#0 RETUNE: RETI DISPLAY:MOV A,SECOND MOV B,#10 DIV AB CLR P3.6 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.6 MOV A,B CLR P3.7 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.7 MOV A,MINUTE MOV B,#10 DIV AB CLR P3.4 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.4 MOV A,B CLR P3.5 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.5 MOV A,HOUR MOV B,#10 DIV AB CLR P3.2 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.2 MOV A,B CLR P3.3 MOVC A,@A+DPTR MOV P0,A LCALL DELAY SETB P3.3 RET DELAY1: MOV R5,#1 D2: MOV R4,#25 DJNZ R4,$ DJNZ R5,D2 RET DELAY: MOV R6,#10 D1:MOV R7,#250 DJNZ R7,$ DJNZ R6,D1 RET TABLE:DB 3FH,06H,5BH,4FH,66H DB 6DH,7DH,07H,7FH,6FH END |