ds18b20,我想改变它的精度,让数码管显示能出更高的精度,谁能帮我把程序改改?
org0000htmplequ29htmphequ28hflag1bit38hdatainbitp3.7main:lcallget_temperlcallcvttmplc...
org 0000h
tmpl equ 29h
tmph equ 28h
flag1 bit 38h
datain bit p3.7
main: lcall get_temper
lcall cvttmp
lcall disp1
ajmp main
init_1820: setb datain
nop
clr datain
mov r1,#3
tsr1: mov r0,#107
djnz r0,$
djnz r1,tsr1
setb datain
nop
nop
nop
mov r0,#25h
tsr2: jnb datain,tsr3
djnz r0,tsr2
clr flag1
sjmp tsr7
tsr3: setb flag1
clr p1.7
mov r0,#117
tsr6: djnz r0,$
tsr7: setb datain
ret
get_temper: setb datain
lcall init_1820
jb flag1,tss2
nop
ret
tss2: mov a,#0cch
lcall write_1820
mov a,#44h
lcall write_1820
acall disp1
lcall init_1820
mov a,#0cch
lcall write_1820
mov a,#0beh
lcall write_1820
lcall read_18200
ret
write_1820:mov r2,#8
clr c
wr1: clr datain
mov r3,#6
djnz r3,$
rrc a
mov datain,c
mov r3,#23
djnz r3,$
setb datain
nop
djnz r2,wr1
setb datain
ret
read_18200:mov r4,#2
mov r1,#29h
re00: mov r2,#8
re01: clr c
setb datain
nop
nop
clr datain
nop
nop
nop
setb datain
mov r3,#9
re10: djnz r3,re10
mov c,datain
mov r3,#23
re20: djnz r3,re20
rrc a
djnz r2,re01
mov @r1,a
dec r1
djnz r4,re00
ret
cvttmp: mov a,tmph
anl a,#80h
jz tmpc1
clr c
mov a,tmpl
cpl a
add a,#1
mov tmpl,a
mov a,tmph
cpl a
addc a,#0
mov tmph,a
mov 73h,#0bh
sjmp tmpc11
tmpc1: mov 73h,#0ah
tmpc11: mov a,tmpl
anl a,#0fh
mov dptr,#tmptab
movc a,@a+dptr
mov 70h,a
mov a,tmpl
anl a,#0f0h
swap a
mov tmpl,a
mov a,tmph
anl a,#0fh
swap a
orl a,tmpl
h2bcd: mov b,#100
div ab
jz b2bcd1
mov 73h,a
b2bcd1: mov a,#10
xch a,b
div ab
mov 72h,a
mov 71h,b
tmpc12: nop
disbcd: mov a,73h
anl a,#0fh
cjne a,#1,disbcd0
sjmp disbcd1
disbcd0: mov a,72h
anl a,#0fh
jnz disbcd1
mov a,73h
mov 72h,a
mov 73h,#0ah
disbcd1: ret
tmptab: db 0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,9
disp1: mov r1,#70h
mov r5,#0feh
play: mov p1,#0ffh
mov a,r5
mov p2,a
mov a,@r1
mov dptr,#tab
movc a,@a+dptr
mov p1,a
mov a,r5
jb acc.1,loop1
clr p1.7
loop1: lcall dl1ms
inc r1
mov a,r5
jnb acc.3,endout
rl a
mov r5,a
sjmp play
endout: mov p1,#0ffh
mov p2,#0ffh
ret
tab: db 0c0h,0f9h,0a4h,0b0h,99h
db 92h,82h,0f8h,80h,90h,0ffh,0bfh
dl1ms: mov r6,#14h
dl1: mov r7,#100
djnz r7,$
djnz r6,dl1
ret
end 展开
tmpl equ 29h
tmph equ 28h
flag1 bit 38h
datain bit p3.7
main: lcall get_temper
lcall cvttmp
lcall disp1
ajmp main
init_1820: setb datain
nop
clr datain
mov r1,#3
tsr1: mov r0,#107
djnz r0,$
djnz r1,tsr1
setb datain
nop
nop
nop
mov r0,#25h
tsr2: jnb datain,tsr3
djnz r0,tsr2
clr flag1
sjmp tsr7
tsr3: setb flag1
clr p1.7
mov r0,#117
tsr6: djnz r0,$
tsr7: setb datain
ret
get_temper: setb datain
lcall init_1820
jb flag1,tss2
nop
ret
tss2: mov a,#0cch
lcall write_1820
mov a,#44h
lcall write_1820
acall disp1
lcall init_1820
mov a,#0cch
lcall write_1820
mov a,#0beh
lcall write_1820
lcall read_18200
ret
write_1820:mov r2,#8
clr c
wr1: clr datain
mov r3,#6
djnz r3,$
rrc a
mov datain,c
mov r3,#23
djnz r3,$
setb datain
nop
djnz r2,wr1
setb datain
ret
read_18200:mov r4,#2
mov r1,#29h
re00: mov r2,#8
re01: clr c
setb datain
nop
nop
clr datain
nop
nop
nop
setb datain
mov r3,#9
re10: djnz r3,re10
mov c,datain
mov r3,#23
re20: djnz r3,re20
rrc a
djnz r2,re01
mov @r1,a
dec r1
djnz r4,re00
ret
cvttmp: mov a,tmph
anl a,#80h
jz tmpc1
clr c
mov a,tmpl
cpl a
add a,#1
mov tmpl,a
mov a,tmph
cpl a
addc a,#0
mov tmph,a
mov 73h,#0bh
sjmp tmpc11
tmpc1: mov 73h,#0ah
tmpc11: mov a,tmpl
anl a,#0fh
mov dptr,#tmptab
movc a,@a+dptr
mov 70h,a
mov a,tmpl
anl a,#0f0h
swap a
mov tmpl,a
mov a,tmph
anl a,#0fh
swap a
orl a,tmpl
h2bcd: mov b,#100
div ab
jz b2bcd1
mov 73h,a
b2bcd1: mov a,#10
xch a,b
div ab
mov 72h,a
mov 71h,b
tmpc12: nop
disbcd: mov a,73h
anl a,#0fh
cjne a,#1,disbcd0
sjmp disbcd1
disbcd0: mov a,72h
anl a,#0fh
jnz disbcd1
mov a,73h
mov 72h,a
mov 73h,#0ah
disbcd1: ret
tmptab: db 0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,9
disp1: mov r1,#70h
mov r5,#0feh
play: mov p1,#0ffh
mov a,r5
mov p2,a
mov a,@r1
mov dptr,#tab
movc a,@a+dptr
mov p1,a
mov a,r5
jb acc.1,loop1
clr p1.7
loop1: lcall dl1ms
inc r1
mov a,r5
jnb acc.3,endout
rl a
mov r5,a
sjmp play
endout: mov p1,#0ffh
mov p2,#0ffh
ret
tab: db 0c0h,0f9h,0a4h,0b0h,99h
db 92h,82h,0f8h,80h,90h,0ffh,0bfh
dl1ms: mov r6,#14h
dl1: mov r7,#100
djnz r7,$
djnz r6,dl1
ret
end 展开
2个回答
东莞市友贸实业有限公司_
2023-11-22 广告
2023-11-22 广告
第五代双倍数据速率DDR5双列直插式内存模块是一种高速、高性能的内存模块,适用于需要高带宽和低延迟的应用场景。与前几代内存模块相比,DDR5双列直插式内存模块具有更高的数据传输速率和更低的功耗,同时提供了更大的内存容量和更高的可靠性。在数据...
点击进入详情页
本回答由东莞市友贸实业有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询