Compile source code dibawah ini dengan Mide 51
S_SET BIT P1.0
M_SET BIT P1.1
H_SET BIT P1.2
SECOND EQU 30H
MINUTE EQU 31H
HOUR EQU 32H
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,-50000/256
MOV TL0,-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,-50000/256
MOV TL0,-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
CLR P3.5
MOV P0,#40H
LCALL DELAY
SETB P3.5
MOV A,MINUTE
MOV B,#10
DIV AB
CLR P3.3
MOVC A,@A+DPTR
MOV P0,A
LCALL DELAY
SETB P3.3
MOV A,B
CLR P3.4
MOVC A,@A+DPTR
MOV P0,A
LCALL DELAY
SETB P3.4
CLR P3.2
MOV P0,#40H
LCALL DELAY
SETB P3.2
MOV A,HOUR
MOV B,#10
DIV AB
CLR P3.0
MOVC A,@A+DPTR
MOV P0,A
LCALL DELAY
SETB P3.0
MOV A,B
CLR P3.1
MOVC A,@A+DPTR
MOV P0,A
LCALL DELAY
SETB P3.1
RET
TABLE: DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH
DELAY: MOV R6,#10
D1: MOV R7,#250
DJNZ R7,$
DJNZ R6,D1
RET
END
Bagi yang kesulitan compile bisa download file hexnya disini
No comments:
Post a Comment