mấy anh chỉ dùm e để delay bằng ic 555 chỉnh nhịp cho led thì phải viêt chổ nào. code e đây ah:
OUT0 BIT P2.0
OUT1 BIT P2.1
OUT2 BIT P2.2
OUT3 BIT P2.3
OUT4 BIT P2.4
OUT5 BIT P2.5
OUT6 BIT P2.6
OUT7 BIT P2.7
ORG 0
MOV 100, #1
MOV P0, #0
MOV P1, #0
MOV P2, #0
MOV P3, #0
;-------------------------
CAPNHAT:
CALL CT1
JMP CAPNHAT
;-----------------------------------
CT1:
MOV DPTR, #BD
T:
MOV A, #0
MOVC A, @A + DPTR
MOV 40, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 41, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 42, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 43, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 44, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 45, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 46, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 47, A
INC DPTR
CALL TRE1
MOV R4, DPH
CJNE R4, #HIGH(KT), TTEMP
MOV R4, DPL
CJNE R4, #LOW(KT), TTEMP
RET
TTEMP: JMP T
;---------------------
LEDOUT:
PUSH DPH
PUSH DPL
MOV DPTR, #MUC
MOV R2, DPH
MOV R3, DPL
CHUA1:
TIEP1:
MOV A, 40
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT0,C
MOV A, 41
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT1,C
MOV A, 42
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT2,C
MOV A, 43
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT3,C
MOV A, 44
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT4,C
MOV A, 45
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT5,C
MOV A, 46
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT6,C
MOV A, 47
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT7,C
INC 100
MOV R6, 100
CJNE R6, #9, TIEP
MOV 100, #1
MOV DPH, R2
MOV DPL, R3
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
MOV R2, DPH
MOV R3, DPL
CJNE R2, #HIGH(EV), CHUA
CJNE R3, #LOW(EV), CHUA
POP DPL
POP DPH
RET
;-----------------
TIEP:
JMP TIEP1
CHUA:
JMP CHUA1
;-------------------
GETBIT:
MOV R7, 100
CX:
RLC A
DJNZ R7, CX
RET
;------------------------
TRE:
MOV 105, #200
D2:
MOV 106, #250
D1:
DEC 106
MOV R4, 106
CJNE R4, #0, D1
DEC 105
MOV R5, 105
CJNE R5, #0, D2
RET
;----------------------
TRE1:
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
RET
;---------------------------------------------
MUC:
DB 00000000B, 10000000B, 11000000B, 11100000B, 11110000B, 11111000B, 11111100B, 11111110B, 11111111B, 11111111B
DB 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B
DB 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 10000000B
DB 11000000B, 11100000B, 11110000B, 11111000B, 11111100B, 11111110B, 11111111B, 11111111B, 11111111B, 11111111B
DB 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B
EV:
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
;--------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------------------------------------
BD:
; P1
;------------------------------------- -
; SANG LAN DAN
DB 29, 00, 00, 00, 00, 00, 00, 29
DB 00, 29, 00, 00, 00, 00, 29, 29
DB 00, 00, 29, 00, 00, 29, 29, 29
DB 29, 00, 00, 00, 29, 29, 29, 29
DB 00, 29, 00, 29, 29, 29, 29, 29
DB 00, 00, 29, 29, 29, 29, 29, 29
;------nhapnhay--------------
DB 29, 00, 00, 29, 29, 29, 29, 29
;-----------------------------------
DB 00, 29, 00, 00, 00, 00, 00, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
DB 29, 00, 00, 00, 00, 00, 00, 00
DB 00, 29, 00, 29, 29, 29, 29, 29
DB 00, 00, 29, 00, 00, 00, 00, 00
;--------------------------------
;------donled-----------------
DB 29, 00, 00, 00, 00, 00, 00, 29
DB 00, 29, 00, 00, 00, 00, 29, 00
DB 00, 00, 29, 00, 00, 29, 00, 00
DB 29, 00, 00, 00, 29, 00, 00, 00
DB 00, 29, 00, 29, 00, 00, 00, 00
DB 00, 00, 29, 29, 00, 00, 00, 00
DB 29, 00, 00, 29, 00, 00, 00, 29
DB 00, 29, 00, 29, 00, 00, 29, 00
DB 00, 00, 29, 29, 00, 29, 00, 00
DB 29, 00, 00, 29, 29, 00, 00, 00
DB 00, 29, 00, 29, 29, 00, 00, 00
DB 00, 00, 29, 29, 29, 00, 00, 00
DB 29, 00, 00, 29, 29, 00, 00, 29
DB 00, 29, 00, 29, 29, 00, 29, 00
DB 00, 00, 29, 29, 29, 29, 00, 00
DB 29, 00, 29, 29, 29, 29, 00, 00
DB 00, 29, 00, 29, 29, 29, 00, 00
DB 00, 00, 29, 29, 29, 29, 00, 00
DB 29, 00, 00, 29, 29, 29, 00, 29
DB 00, 29, 00, 29, 29, 29, 29, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
;------------------------------------
;---chay sole
DB 29, 00, 00, 00, 00, 00, 00, 29
DB 00, 29, 00, 00, 00, 00, 29, 00
DB 00, 00, 29, 00, 00, 29, 00, 29
DB 29, 00, 00, 00, 29, 00, 29, 00
DB 00, 29, 00, 29, 00, 29, 00, 29
DB 00, 00, 29, 29, 29, 00, 29, 00
DB 29, 00, 00, 29, 29, 29, 00, 29
DB 00, 29, 00, 29, 29, 29, 29, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
;....chay o giua chay ra......
DB 29, 00, 00, 00, 00, 29, 00, 00
DB 00, 29, 00, 00, 29, 29, 29, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
DB 29, 00, 00, 00, 00, 29, 00, 00
DB 00, 29, 00, 00, 29, 29, 29, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
;-----------------------------------------------------------------------
KT:
END
OUT0 BIT P2.0
OUT1 BIT P2.1
OUT2 BIT P2.2
OUT3 BIT P2.3
OUT4 BIT P2.4
OUT5 BIT P2.5
OUT6 BIT P2.6
OUT7 BIT P2.7
ORG 0
MOV 100, #1
MOV P0, #0
MOV P1, #0
MOV P2, #0
MOV P3, #0
;-------------------------
CAPNHAT:
CALL CT1
JMP CAPNHAT
;-----------------------------------
CT1:
MOV DPTR, #BD
T:
MOV A, #0
MOVC A, @A + DPTR
MOV 40, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 41, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 42, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 43, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 44, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 45, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 46, A
INC DPTR
MOV A, #0
MOVC A, @A + DPTR
MOV 47, A
INC DPTR
CALL TRE1
MOV R4, DPH
CJNE R4, #HIGH(KT), TTEMP
MOV R4, DPL
CJNE R4, #LOW(KT), TTEMP
RET
TTEMP: JMP T
;---------------------
LEDOUT:
PUSH DPH
PUSH DPL
MOV DPTR, #MUC
MOV R2, DPH
MOV R3, DPL
CHUA1:
TIEP1:
MOV A, 40
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT0,C
MOV A, 41
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT1,C
MOV A, 42
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT2,C
MOV A, 43
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT3,C
MOV A, 44
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT4,C
MOV A, 45
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT5,C
MOV A, 46
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT6,C
MOV A, 47
MOVC A, @A+DPTR
CALL GETBIT
CALL GETBIT
CALL GETBIT
CALL GETBIT
MOV OUT7,C
INC 100
MOV R6, 100
CJNE R6, #9, TIEP
MOV 100, #1
MOV DPH, R2
MOV DPL, R3
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
INC DPTR
MOV R2, DPH
MOV R3, DPL
CJNE R2, #HIGH(EV), CHUA
CJNE R3, #LOW(EV), CHUA
POP DPL
POP DPH
RET
;-----------------
TIEP:
JMP TIEP1
CHUA:
JMP CHUA1
;-------------------
GETBIT:
MOV R7, 100
CX:
RLC A
DJNZ R7, CX
RET
;------------------------
TRE:
MOV 105, #200
D2:
MOV 106, #250
D1:
DEC 106
MOV R4, 106
CJNE R4, #0, D1
DEC 105
MOV R5, 105
CJNE R5, #0, D2
RET
;----------------------
TRE1:
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
CALL LEDOUT
RET
;---------------------------------------------
MUC:
DB 00000000B, 10000000B, 11000000B, 11100000B, 11110000B, 11111000B, 11111100B, 11111110B, 11111111B, 11111111B
DB 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B
DB 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 10000000B
DB 11000000B, 11100000B, 11110000B, 11111000B, 11111100B, 11111110B, 11111111B, 11111111B, 11111111B, 11111111B
DB 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B, 11111111B
EV:
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
DB 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B, 00000000B
;--------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------------------------------------
BD:
; P1
;------------------------------------- -
; SANG LAN DAN
DB 29, 00, 00, 00, 00, 00, 00, 29
DB 00, 29, 00, 00, 00, 00, 29, 29
DB 00, 00, 29, 00, 00, 29, 29, 29
DB 29, 00, 00, 00, 29, 29, 29, 29
DB 00, 29, 00, 29, 29, 29, 29, 29
DB 00, 00, 29, 29, 29, 29, 29, 29
;------nhapnhay--------------
DB 29, 00, 00, 29, 29, 29, 29, 29
;-----------------------------------
DB 00, 29, 00, 00, 00, 00, 00, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
DB 29, 00, 00, 00, 00, 00, 00, 00
DB 00, 29, 00, 29, 29, 29, 29, 29
DB 00, 00, 29, 00, 00, 00, 00, 00
;--------------------------------
;------donled-----------------
DB 29, 00, 00, 00, 00, 00, 00, 29
DB 00, 29, 00, 00, 00, 00, 29, 00
DB 00, 00, 29, 00, 00, 29, 00, 00
DB 29, 00, 00, 00, 29, 00, 00, 00
DB 00, 29, 00, 29, 00, 00, 00, 00
DB 00, 00, 29, 29, 00, 00, 00, 00
DB 29, 00, 00, 29, 00, 00, 00, 29
DB 00, 29, 00, 29, 00, 00, 29, 00
DB 00, 00, 29, 29, 00, 29, 00, 00
DB 29, 00, 00, 29, 29, 00, 00, 00
DB 00, 29, 00, 29, 29, 00, 00, 00
DB 00, 00, 29, 29, 29, 00, 00, 00
DB 29, 00, 00, 29, 29, 00, 00, 29
DB 00, 29, 00, 29, 29, 00, 29, 00
DB 00, 00, 29, 29, 29, 29, 00, 00
DB 29, 00, 29, 29, 29, 29, 00, 00
DB 00, 29, 00, 29, 29, 29, 00, 00
DB 00, 00, 29, 29, 29, 29, 00, 00
DB 29, 00, 00, 29, 29, 29, 00, 29
DB 00, 29, 00, 29, 29, 29, 29, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
;------------------------------------
;---chay sole
DB 29, 00, 00, 00, 00, 00, 00, 29
DB 00, 29, 00, 00, 00, 00, 29, 00
DB 00, 00, 29, 00, 00, 29, 00, 29
DB 29, 00, 00, 00, 29, 00, 29, 00
DB 00, 29, 00, 29, 00, 29, 00, 29
DB 00, 00, 29, 29, 29, 00, 29, 00
DB 29, 00, 00, 29, 29, 29, 00, 29
DB 00, 29, 00, 29, 29, 29, 29, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
;....chay o giua chay ra......
DB 29, 00, 00, 00, 00, 29, 00, 00
DB 00, 29, 00, 00, 29, 29, 29, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
DB 29, 00, 00, 00, 00, 29, 00, 00
DB 00, 29, 00, 00, 29, 29, 29, 00
DB 00, 00, 29, 29, 29, 29, 29, 29
;-----------------------------------------------------------------------
KT:
END
Comment