I attempt to read ds1621 with pic16f877A, but always reading 00 value;
Where is mistake ? Please .....
' pic16f877a
DEFINE OSC 4
INCLUDE "MYLCD.BAS" ' lcd on portb
CMCON = 7
ADCON1 = 7
SCL VAR PORTD.2
SDA VAR PORTD.3
;( A0,A1,A2 = gnd )
W0 var word
ds var byte
Startconvert var byte
Startconvert = $EE ' Initiates temperature conversion.
ds = %10100000 ' device address
start:
i2cwrite SDA,SCL,ds,$AC,[0] ' Access Config
pause 100
i2cwrite SDA,SCL,ds,Startconvert ' Start Conversion
pause 750
gosub gettemp
lcdout $fe,1
lcdout "Temperature = ",dec2 W0
pause 800
goto start
gettemp:
i2cread SDA,SCL,ds,$AA,[W0] ' Read last converted temperature value from temperature register.
W0 = W0 >> 8
return