This works for me using DS18B20
Code:
DQ VAR PORTA.5 'One-wire data pin for Ds18B20
GIE VAR INTCON.7
temperature VAR WORD ' Temperature storage
'*******************************************************************************
'Get and display the temperature
GIE = 0
owin DQ, 1, [],NoDevice ' pole 1 wire bus - if no responce then device not pressent
OWOUT DQ, 1, [$CC, $44] ' Start temperature conversion
OWOUT DQ, 1, [$CC, $BE] ' Read the temperature
OWIN DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE]
GIE = 1 ' turn interupts back on
temperature = temperature */ 1600
lcdout $FE,$D4+0,"TEMP ",dec(temperature / 100),$DF,"C"
NoDevice:
lcdout $FE,$D4+0,"TEMP N/C "
GIE = 1
goto main
Bookmarks