Datasheet
Jon Waddington
87
temp := readtc ' read the temperature
showc(temp) ' display in °C
else
case status
%00 : text.str(string("-- Bus short"))
%01 : text.str(string("-- Bus interference"))
%11 : text.str(string("-- No device"))
waitcnt(cnt +100_000_000)
ow.finalize
PRI readtc | tc
'' Reads temperature from DS1820
'' -- returns degrees C in 0.1 degree units
ow.reset
ow.write(SKIP_ROM)
ow.write(CVRT_TEMP)
repeat ' let conversion finish
tc := ow.rdbit
until (tc == 1)
ow.reset
ow.write(SKIP_ROM)
ow.write(RD_SPAD)
tc := ow.read ' lsb of temp
tc |= ow.read << 8 ' msb of temp
ow.reset
'tc := ~~tc * 5 ' extend sign, 0.1° units
return tc
PRI showc (tc) | t', dp
'' Show the temperature
tc <<= 16
if (tc < 0)
text.str(string("-"))
||tc
tc >>= 16
'dp := (tc & $0F) * 625
t := tc >> 4
text.dec(t)
'text.str(string("."))
'if dp == 625 AND (tc << 16) < 0
' text.str(string("0"))
'text.dec(dp))
text.out($B0)
text.out($43)
PRI tout : tempout | bit
{{reserved for outside temperature}}
XB.API_Rxtime(100)
if xb.rxident <> $FF










