Aha ...
Code:
' One-wire temperature for Picboard and DS1820
'Ok le 29/08/2004 - 534 lignes
' Define LCD registers and bits
Define LCD_EBIT 1
DQ Var PORTB.4 ' One-wire data pin
Ok Var PORTB.5 ' Led Verte
Waito Var PORTB.6 ' Led Orange
Error Var PORTB.7 ' Led Rouge
temperature Var Word ' Temperature storage
count_remain Var Byte ' Count remaining
count_per_c Var Byte ' Count per degree C
offset Var Word ' 100 * offset réel !!!
offset = 293
PAUSE 500
LCDOUT $FE,1
'*****************************************************************************
' Start temperature conversion
'*****************************************************************************
mainloop: OWOut DQ, 1, [$CC, $44 ]
'*****************************************************************************
' Check for still busy converting ( ~ 4500 fois ... )
'*****************************************************************************
waitloop:
INPUT DQ
If NOT DQ Then waitloop
'*****************************************************************************
' Read the temperature
'*****************************************************************************
OWOut DQ, 1, [$CC, $BE ]
OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
'*****************************************************************************
' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)
'*****************************************************************************
temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)+ offset
Lcdout $fe, 1, DEC (temperature / 100), ".", DEC2 temperature, " ",$DF,"C"
'*****************************************************************************
' Calculate temperature in degrees F to 2 decimal places (not valid for negative temperature)
'*****************************************************************************
temperature = (temperature */ 461) + 3200
Lcdout $fe, $c0, DEC (temperature / 100), ".", DEC2 temperature, " ",$DF,"F"
'*****************************************************************************
' Display about once a second
'*****************************************************************************
Pause 1000
Goto mainloop ' Do it forever
looks we have the same source !!! ... This one works perfectly aboard a 16F84 ...
soo ... let's check the 872 config ... AND,AND,AND :
Wich PbP version do you use ... and has your PBPpic14.lib being modified ???
There was an interesting thread those days about 1Wire and > 8 Mhz Osc ...
see here : http://www.picbasic.co.uk/forum/show...79&postcount=4
Alain
Bookmarks