Đây là code em viết lại cho ds12887 có cả phần báo giờ phút giây! Chaỵ rất ok, Giờ, phút, giây hiển thị tốt, chỉ có khi chỉnh qua báo giờ thì nó lại hiện kỳ quá, suy nghĩ mãi ko sao tìm ra nguyên nhân! Mong ai biết chỉ dùm em!
Mạch em đơn giản dùng port2 quét led, port 1 xuất dữ liệu! Chân IRQ của dallass nối với chân P3.2 của xi xử lý để cho báo giờ! Em sử dụng 8 led 7 đoạn!
Hiện tượng là thế này, khi bình thường chỉ hiển thi giờ phú giây thì ko có vấn đề gì! Nó hiện như sau:
"HH-MM-SS"
Mỗi chữ cái trong dấu ngoặc kép tương ứng với một con led!
Khi bấm nút chuyển qua chỉnh thời gian để báo thức thì nó hiển thì như sau
"xH-xM-xS"
Chữ x là con led tắt ngóm ko hiển thị gì cả tuy rằng em thử và biết là nó vẫn nó vẫn quét đó! Còn các chữ cái khác thì hiển thị bình thường, tăng giảm vẫn ok khi em chỉnh nó từ 0 - 9!
Em ko hiểu code sai chỗ nào! CẦu xin sự gúp đỡ của ai đã làm phần báo thức dùng ds12887, nếu có code tham khảo gì đó thì giúp em luôn nhé!
Đây là code, xin xem giúp em:
Mạch em đơn giản dùng port2 quét led, port 1 xuất dữ liệu! Chân IRQ của dallass nối với chân P3.2 của xi xử lý để cho báo giờ! Em sử dụng 8 led 7 đoạn!
Hiện tượng là thế này, khi bình thường chỉ hiển thi giờ phú giây thì ko có vấn đề gì! Nó hiện như sau:
"HH-MM-SS"
Mỗi chữ cái trong dấu ngoặc kép tương ứng với một con led!
Khi bấm nút chuyển qua chỉnh thời gian để báo thức thì nó hiển thì như sau
"xH-xM-xS"
Chữ x là con led tắt ngóm ko hiển thị gì cả tuy rằng em thử và biết là nó vẫn nó vẫn quét đó! Còn các chữ cái khác thì hiển thị bình thường, tăng giảm vẫn ok khi em chỉnh nó từ 0 - 9!
Em ko hiểu code sai chỗ nào! CẦu xin sự gúp đỡ của ai đã làm phần báo thức dùng ds12887, nếu có code tham khảo gì đó thì giúp em luôn nhé!
Đây là code, xin xem giúp em:
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
; p2 dieu khien 8 led va p3.0, p3.1, p3.2, p3.4, p3.5
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
dwn bit p3.3
up bit p3.4
mode bit p3.5
mode1 bit p3.0
bell bit p3.1
bien_mode equ r2
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
org 000h
jmp main
org 003h
jmp ngat_n0
main: mov bien_mode,#0
lcall khoitaodallass
mov ie,#81h
setb it0
setb bell
tu_dau: lcall doc_data
lcall hex_bcd
lcall bcd_7doan
lcall hien_thi
jb mode,adj
jb mode1,adj_alr
sjmp tu_dau
adj_alr:
ljmp set_alr
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
adj: lcall hien_thi
jb mode,adj
inc bien_mode
cjne bien_mode,#04,loop
mov bien_mode,#0
ljmp tu_dau
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx
loop: mov 67h,#10h
loop3: mov 66h,#0afh
loop1: lcall doc_data
lcall hex_bcd
lcall bcd_7doan
lcall hien_thi
jb up,tang
jb dwn,giam
jb mode,adj
djnz 66h,loop1
cjne bien_mode,#1,tatphut
mov 36h,#0ffh
mov 37h,#0ffh
sjmp tat
tatphut: cjne bien_mode,#02,tatgiay
mov 33h,#0ffh
mov 34h,#0ffh
sjmp tat
tatgiay: mov 30h,#0ffh
mov 31h,#0ffh
tat: mov 66h,#0afh
loop2: lcall hien_thi
jb up,tang
jb dwn,giam
jb mode,adj2
djnz 66h,loop2
djnz 67h,loop3
mov bien_mode,#0
ljmp tu_dau
adj2: ljmp adj
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
tang: mov 78h,#200
tang1: lcall hien_thi
djnz 78h,tang1
cjne bien_mode,#01h,ss1
mov r0,#04h
movx a,@r0
inc a
cjne a,#24,z1
mov a,#0
z1: movx @r0,a
jmp loop
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
ss1: cjne bien_mode,#02h,ss2
mov r0,#02h
movx a,@r0
inc a
cjne a,#60,z1
mov a,#0
jmp z1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
ss2: mov r0,#0h
movx a,@r0
inc a
cjne a,#060,z1
mov a,#0
jmp z1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
giam: mov 78h,#200
giam11: lcall hien_thi
djnz 78h,giam11
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
cjne bien_mode,#01h,sss1
mov r0,#04
movx a,@r0
dec a
cjne a,#0ffh,zz1
mov a,#23
zz1: movx @r0,a
jmp loop
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
sss1: cjne bien_mode,#02h,sss2
mov r0,#02h
movx a,@r0
dec a
cjne a,#0ffh,zz1
mov a,#59
jmp zz1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
sss2: mov r0,#0h
movx a,@r0
dec a
cjne a,#0ffh,zz1
mov a,#59
jmp zz1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
; doan ct cai dat bao thuc
set_alr:
lcall hien_thi_alr
jb mode1,set_alr
jb bell,set_a
setb bell
mov r0,#0ch
movx a,@r0
jmp tu_dau
set_a: inc bien_mode
cjne bien_mode,#4,wait
mov bien_mode,#0
ljmp tu_dau
wait: mov 67h,#10h
wait3: mov 66h,#0ffh
wait1:
lcall doc_data_alr
lcall hex_bcd
lcall bcd_7doan
lcall hien_thi_alr
jb up,tang_alr
jb dwn,giam_alr
jb mode1,set_alr
djnz 66h,wait1
cjne bien_mode,#1,tatphut_alr
mov 36h,#0ffh
mov 37h,#0ffh
sjmp tat_alr
tatphut_alr: cjne bien_mode,#2,tatgiay_alr
mov 33h,#0ffh
mov 34h,#0ffh
sjmp tat_alr
tatgiay_alr: mov 31h,#0ffh
mov 30h,#0ffh
tat_alr: mov 66h,#0ffh
wait2: lcall hien_thi_alr
jb up,tang_alr
jb dwn,giam_alr
jb mode1,set_alr
djnz 66h,wait2
djnz 67h,wait3
mov bien_mode,#0
ljmp tu_dau
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
tang_alr: mov 78h,#200
tang1_alr: lcall hien_thi_alr
djnz 78h,tang1_alr
waitx3:
cjne bien_mode,#01h,ss_alr1
mov r0,#05h
movx a,@r0
inc a
cjne a,#24,z_alr1
mov a,#0
z_alr1: movx @r0,a
jmp wait
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
ss_alr1:
cjne bien_mode,#2,ss_alr2
mov r0,#03h
movx a,@r0
inc a
cjne a,#60,z_alr1
mov a,#0
jmp z_alr1
ss_alr2:
mov r0,#01h
movx a,@r0
inc a
cjne a,#60,z_alr1
mov a,#0
jmp z_alr1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
giam_alr: mov 78h,#200
giam_alr11: lcall hien_thi_alr
djnz 78h,giam_alr11
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
waity3: cjne bien_mode,#01h,sss_alr1
mov r0,#5
movx a,@r0
dec a
cjne a,#0ffh,zz_alr1
mov a,#24
zz_alr1: movx @r0,a
jmp wait
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
sss_alr1: cjne bien_mode,#2,sss_alr2
mov r0,#03h
movx a,@r0
dec a
cjne a,#0ffh,zz_alr1
mov a,#59
jmp zz_alr1
sss_alr2: mov r0,#01h
movx a,@r0
dec a
cjne a,#0ffh,zz_alr1
mov a,#59
jmp zz_alr1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
khoitaodallass: mov r0,#0bh
mov a,#026h
movx @r0,a ;cho phep chinh cai dat gio
mov r0,#0ah
mov a,#020h
movx @r0,a ;cho phep bo dao dong chay
mov r0,#0ch
movx a,@r0
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
doc_data:
mov r0,#00h
movx a,@r0
mov 10h,a
mov r0,#02h
movx a,@r0
mov 11h,a
mov r0,#04h
movx a,@r0
mov 12h,a
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
doc_data_alr:
mov r0,#01h
movx a,@r0
mov 10h,a
mov r0,#03h
movx a,@r0
mov 11h,a
mov r0,#05h
movx a,@r0
mov 12h,a
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
hex_bcd:
mov r0,#10h
mov r1,#20h
hb: mov a,@r0
mov b,#10
div ab
mov @r1,b
inc r1
mov @r1,a
inc r0
inc r1
cjne r0,#13h,hb
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
bcd_7doan:
mov dptr,#codedisp
mov r0,#20h
mov r1,#30h
bc1: mov r7,#02h
bc: mov a,@r0
movc a,@a+dptr
mov @r1,a
inc r0
inc r1
djnz r7,bc
mov @r1,#0bfh
inc r1
cjne r0,#26h,bc1
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
hien_thi:
mov r0,#30h
mov a,#0feh
ht: mov p2,@r0
mov p1,a
lcall delay
mov p1,#0ffh
inc r0
rl a
cjne a,#0feh,ht
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
hien_thi_alr:
mov r0,#30h
mov a,#0feh
ht1: mov p2,@r0
mov p1,a
lcall delay
mov p1,#0ffh
inc r0
rl a
cjne a,#0feh,ht1
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
ngat_n0: clr bell
reti
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
delay: mov 7fh,#50
djnz 7fh,$
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
codedisp:
db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h
end
; p2 dieu khien 8 led va p3.0, p3.1, p3.2, p3.4, p3.5
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
dwn bit p3.3
up bit p3.4
mode bit p3.5
mode1 bit p3.0
bell bit p3.1
bien_mode equ r2
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
org 000h
jmp main
org 003h
jmp ngat_n0
main: mov bien_mode,#0
lcall khoitaodallass
mov ie,#81h
setb it0
setb bell
tu_dau: lcall doc_data
lcall hex_bcd
lcall bcd_7doan
lcall hien_thi
jb mode,adj
jb mode1,adj_alr
sjmp tu_dau
adj_alr:
ljmp set_alr
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
adj: lcall hien_thi
jb mode,adj
inc bien_mode
cjne bien_mode,#04,loop
mov bien_mode,#0
ljmp tu_dau
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx
loop: mov 67h,#10h
loop3: mov 66h,#0afh
loop1: lcall doc_data
lcall hex_bcd
lcall bcd_7doan
lcall hien_thi
jb up,tang
jb dwn,giam
jb mode,adj
djnz 66h,loop1
cjne bien_mode,#1,tatphut
mov 36h,#0ffh
mov 37h,#0ffh
sjmp tat
tatphut: cjne bien_mode,#02,tatgiay
mov 33h,#0ffh
mov 34h,#0ffh
sjmp tat
tatgiay: mov 30h,#0ffh
mov 31h,#0ffh
tat: mov 66h,#0afh
loop2: lcall hien_thi
jb up,tang
jb dwn,giam
jb mode,adj2
djnz 66h,loop2
djnz 67h,loop3
mov bien_mode,#0
ljmp tu_dau
adj2: ljmp adj
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
tang: mov 78h,#200
tang1: lcall hien_thi
djnz 78h,tang1
cjne bien_mode,#01h,ss1
mov r0,#04h
movx a,@r0
inc a
cjne a,#24,z1
mov a,#0
z1: movx @r0,a
jmp loop
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
ss1: cjne bien_mode,#02h,ss2
mov r0,#02h
movx a,@r0
inc a
cjne a,#60,z1
mov a,#0
jmp z1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
ss2: mov r0,#0h
movx a,@r0
inc a
cjne a,#060,z1
mov a,#0
jmp z1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
giam: mov 78h,#200
giam11: lcall hien_thi
djnz 78h,giam11
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
cjne bien_mode,#01h,sss1
mov r0,#04
movx a,@r0
dec a
cjne a,#0ffh,zz1
mov a,#23
zz1: movx @r0,a
jmp loop
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
sss1: cjne bien_mode,#02h,sss2
mov r0,#02h
movx a,@r0
dec a
cjne a,#0ffh,zz1
mov a,#59
jmp zz1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
sss2: mov r0,#0h
movx a,@r0
dec a
cjne a,#0ffh,zz1
mov a,#59
jmp zz1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
; doan ct cai dat bao thuc
set_alr:
lcall hien_thi_alr
jb mode1,set_alr
jb bell,set_a
setb bell
mov r0,#0ch
movx a,@r0
jmp tu_dau
set_a: inc bien_mode
cjne bien_mode,#4,wait
mov bien_mode,#0
ljmp tu_dau
wait: mov 67h,#10h
wait3: mov 66h,#0ffh
wait1:
lcall doc_data_alr
lcall hex_bcd
lcall bcd_7doan
lcall hien_thi_alr
jb up,tang_alr
jb dwn,giam_alr
jb mode1,set_alr
djnz 66h,wait1
cjne bien_mode,#1,tatphut_alr
mov 36h,#0ffh
mov 37h,#0ffh
sjmp tat_alr
tatphut_alr: cjne bien_mode,#2,tatgiay_alr
mov 33h,#0ffh
mov 34h,#0ffh
sjmp tat_alr
tatgiay_alr: mov 31h,#0ffh
mov 30h,#0ffh
tat_alr: mov 66h,#0ffh
wait2: lcall hien_thi_alr
jb up,tang_alr
jb dwn,giam_alr
jb mode1,set_alr
djnz 66h,wait2
djnz 67h,wait3
mov bien_mode,#0
ljmp tu_dau
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
tang_alr: mov 78h,#200
tang1_alr: lcall hien_thi_alr
djnz 78h,tang1_alr
waitx3:
cjne bien_mode,#01h,ss_alr1
mov r0,#05h
movx a,@r0
inc a
cjne a,#24,z_alr1
mov a,#0
z_alr1: movx @r0,a
jmp wait
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
ss_alr1:
cjne bien_mode,#2,ss_alr2
mov r0,#03h
movx a,@r0
inc a
cjne a,#60,z_alr1
mov a,#0
jmp z_alr1
ss_alr2:
mov r0,#01h
movx a,@r0
inc a
cjne a,#60,z_alr1
mov a,#0
jmp z_alr1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
giam_alr: mov 78h,#200
giam_alr11: lcall hien_thi_alr
djnz 78h,giam_alr11
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
waity3: cjne bien_mode,#01h,sss_alr1
mov r0,#5
movx a,@r0
dec a
cjne a,#0ffh,zz_alr1
mov a,#24
zz_alr1: movx @r0,a
jmp wait
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
sss_alr1: cjne bien_mode,#2,sss_alr2
mov r0,#03h
movx a,@r0
dec a
cjne a,#0ffh,zz_alr1
mov a,#59
jmp zz_alr1
sss_alr2: mov r0,#01h
movx a,@r0
dec a
cjne a,#0ffh,zz_alr1
mov a,#59
jmp zz_alr1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
khoitaodallass: mov r0,#0bh
mov a,#026h
movx @r0,a ;cho phep chinh cai dat gio
mov r0,#0ah
mov a,#020h
movx @r0,a ;cho phep bo dao dong chay
mov r0,#0ch
movx a,@r0
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
doc_data:
mov r0,#00h
movx a,@r0
mov 10h,a
mov r0,#02h
movx a,@r0
mov 11h,a
mov r0,#04h
movx a,@r0
mov 12h,a
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
doc_data_alr:
mov r0,#01h
movx a,@r0
mov 10h,a
mov r0,#03h
movx a,@r0
mov 11h,a
mov r0,#05h
movx a,@r0
mov 12h,a
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
hex_bcd:
mov r0,#10h
mov r1,#20h
hb: mov a,@r0
mov b,#10
div ab
mov @r1,b
inc r1
mov @r1,a
inc r0
inc r1
cjne r0,#13h,hb
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
bcd_7doan:
mov dptr,#codedisp
mov r0,#20h
mov r1,#30h
bc1: mov r7,#02h
bc: mov a,@r0
movc a,@a+dptr
mov @r1,a
inc r0
inc r1
djnz r7,bc
mov @r1,#0bfh
inc r1
cjne r0,#26h,bc1
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
hien_thi:
mov r0,#30h
mov a,#0feh
ht: mov p2,@r0
mov p1,a
lcall delay
mov p1,#0ffh
inc r0
rl a
cjne a,#0feh,ht
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
hien_thi_alr:
mov r0,#30h
mov a,#0feh
ht1: mov p2,@r0
mov p1,a
lcall delay
mov p1,#0ffh
inc r0
rl a
cjne a,#0feh,ht1
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
ngat_n0: clr bell
reti
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
delay: mov 7fh,#50
djnz 7fh,$
ret
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx
codedisp:
db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h
end
Comment