CNTH equ R5
CNTL equ R4
ten_ms equ 7fh
org 0
ljmp main
org 1bh
ljmp T1ISR
org 30h
main:
mov TMOD,#10h
mov TH1,#high(-10)
mov TL1,#low(-10)
mov IE,#88h
setb TR1
mov CNTL,#87h
mov CNTH,#09h
mov ten_ms,#0
loop: mov a,CNTL
anl a,#0fh
acall disp_led3
mov a,CNTL
anl a,#0f0h
rr a
rr a
rr a
rr a
acall disp_led2
mov a,CNTH
anl a,#0fh
acall disp_led1
jmp loop
T1ISR:
push acc
clr TR1
MOV TH1,#high(-10000)
MOV TL1,#low(-10000)
setb TR1
mov a,ten_ms
cjne a,#100,exit
mov ten_ms,#0
inc CNTL
cjne CNTL,#0,skip
inc CNTH
mov a,CNTL
cjne a,#0BCh,cont1
mov a,CNTH
cjne a,#0Ah,cont1
mov CNTL,#87h
mov CNTH,#9h
cont1:
jmp T1ISR
skip: jmp cont
exit: inc ten_ms
cont: pop acc
reti
disp_led1:
mov p2,#0ffh
mov dptr,#led7s
movc a,@a+dptr
mov p2,a
clr p0.2
acall delay
setb p0.2
ret
disp_led2:
mov p2,#0ffh
mov dptr,#led7s
movc a,@a+dptr
mov p2,a
clr p0.1
acall delay
setb p0.1
ret
disp_led3:
mov p2,#0ffh
mov dptr,#led7s
movc a,@a+dptr
mov p2,a
clr p0.0
acall delay
setb p0.0
ret
delay: mov r6,#100
delay1: mov r7,#255
djnz r7,$
djnz r6,delay1
ret
led7s: db 0C0h, 0F9h, 0A4h, 0B0h, 99h, 92h, 82h, 0f8h, 80h, 90h
db 088h, 83h, 0C6h, 0A1h, 86h, 8Eh
end
nên làm sao chỗ cont 1 để led sáng từ 987 đến ABC là dừng. thứ tự led sáng là 987,988,989,98A...ABC.
CNTL equ R4
ten_ms equ 7fh
org 0
ljmp main
org 1bh
ljmp T1ISR
org 30h
main:
mov TMOD,#10h
mov TH1,#high(-10)
mov TL1,#low(-10)
mov IE,#88h
setb TR1
mov CNTL,#87h
mov CNTH,#09h
mov ten_ms,#0
loop: mov a,CNTL
anl a,#0fh
acall disp_led3
mov a,CNTL
anl a,#0f0h
rr a
rr a
rr a
rr a
acall disp_led2
mov a,CNTH
anl a,#0fh
acall disp_led1
jmp loop
T1ISR:
push acc
clr TR1
MOV TH1,#high(-10000)
MOV TL1,#low(-10000)
setb TR1
mov a,ten_ms
cjne a,#100,exit
mov ten_ms,#0
inc CNTL
cjne CNTL,#0,skip
inc CNTH
mov a,CNTL
cjne a,#0BCh,cont1
mov a,CNTH
cjne a,#0Ah,cont1
mov CNTL,#87h
mov CNTH,#9h
cont1:
jmp T1ISR
skip: jmp cont
exit: inc ten_ms
cont: pop acc
reti
disp_led1:
mov p2,#0ffh
mov dptr,#led7s
movc a,@a+dptr
mov p2,a
clr p0.2
acall delay
setb p0.2
ret
disp_led2:
mov p2,#0ffh
mov dptr,#led7s
movc a,@a+dptr
mov p2,a
clr p0.1
acall delay
setb p0.1
ret
disp_led3:
mov p2,#0ffh
mov dptr,#led7s
movc a,@a+dptr
mov p2,a
clr p0.0
acall delay
setb p0.0
ret
delay: mov r6,#100
delay1: mov r7,#255
djnz r7,$
djnz r6,delay1
ret
led7s: db 0C0h, 0F9h, 0A4h, 0B0h, 99h, 92h, 82h, 0f8h, 80h, 90h
db 088h, 83h, 0C6h, 0A1h, 86h, 8Eh
end
nên làm sao chỗ cont 1 để led sáng từ 987 đến ABC là dừng. thứ tự led sáng là 987,988,989,98A...ABC.