Okay than Richard,
That is what I'm effectively doing but no joy!
Interestingly I'm now testing the code on a PIC18F45K20 and sensor works fine on PORTC or PORTD but can't seem to get any readings when configured using ports eithe port A, B or E.
Little stumped as to why the don't work on these ports. Think if I can resolve it working on the 18F45K20 i'll get it working on the 12F509
Have played with setting TRISX in various settings with no luck. Have yet to find the difference between the ports or any specific register that need to be set.
Here's the code...
DEFINE OSC 4 ' ensure 4Mhz is set for comms
Include "modedefs.bas"
#CONFIG
CONFIG FOSC = INTIO67 ; Internal Oscillator, no clock out
CONFIG MCLRE = OFF
#ENDCONFIG
OSCCON=%01010000
temperature VAR WORD ' Temperature storage
x var word
'TRISB = %11111111
'TRISA = %00000000
'led1 var portA.2
'low led1
DQ VAR portD.0 ' One-wire data pin c.0 worked on 45K20
tx VAR portC.3
x=1
mainloop:
OWOUT DQ, 1, [$CC, $44] ' Start temperature conversion
pause 500
OWOUT DQ, 1, [$CC, $BE] ' Read the temperature
OWIN DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE]
temperature = temperature */ 1600
SEROUT2 tx,84,[dec x,"temperature",DEC (temperature / 100), ".", DEC2 temperature,10,13]
x=x+1
GoTo mainloop
Bookmarks