Hello
I am old but new here, just found this forum.
I have written several Picbasic Pro programs using 16F873 or later 16F876A, LCD-display and Dallas 1820 temperature sensors. Now I wanted to make a simple thermostat using the attached code with 12F508. I can't get it working. The program starts ok, I see the led flashing for 1 sec, but then I think the program cannot get any result from the sensor. The rom code is ok, tested the same sensor with 16f876A. I think the problem may be, that I cannot use 12F508 registers right. Here is the code and I WANT to use 12F508 if possible. Please help
GPIO.0 is the led pin
GPIO.1 is the data pin
'-----------------------------------------
led var GPIO.0
Tempa Var Word ' Temperature storage
Stat var bit
DQ Var GPIO.1 ' One-wire data pin
TRISIO =%00000010 '???? maybe wrong?
GPIO =%00000000 '???? maybe wrong?
'flash led to see if running
high led
PAUSE 1000
low led
'read 1820
Temp_1:
OWOUT DQ, 1, [$55,$10,$B2,$AD,$D8,$00,$08,$00,$26,$44]
W1:
OWIN DQ, 4, [Stat]' Check for still busy converting
IF Stat = 0 THEN W1' Still busy?, then loop
OWOUT DQ, 1,[$55,$10,$B2,$AD,$D8,$00,$08,$00,$26,$BE]
OWIN DQ, 2, [Tempa.LOWBYTE,Tempa.HIGHBYTE]' Read two bytes, then end communications
If Tempa >= 41 then low led ' if >= 20,5 led off
If Tempa <= 40 then high led ' if <= 20 led on
PAUSE 1000
Goto Temp_1
'-----------------------------------
Bookmarks