Give this a shot:
Code:@ DEVICE PIC16F872, HS_OSC, WDT_OFF, PWRT_ON, LVP_OFF, PROTECT_OFF DEFINE OSC 20 DEFINE LCD_COMMANDUS 3000 DEFINE LCD_DATAUS 250 temperature var word : count_remain var byte : count_per_c var byte dq var portb.2 : ADCON1 = 7 : pause 1000 : lcdout $fe , 1 mainloop: OWOut DQ , 1 , [ $CC , $44 ] waitloop: OWIn DQ, 4, [count_remain] : If count_remain = 0 Then waitloop owout dq, 1, [$cc,$be] owin dq , 0 , [ temperature.lowbyte , temperature.highbyte , skip 4 , count_remain , count_per_c ] temperature = ( ( ( temperature >> 1 ) * 100 ) - 25 ) + ( ( ( count_per_c - count_remain ) * 100 ) / count_per_c ) Lcdout $fe , $80 , DEC3 ( temperature / 100 ) , "." , DEC2 temperature, " C" temperature = ( temperature * / 461 ) + 3200 Lcdout $fe , $c0 , DEC3 ( temperature / 100 ) , "." , DEC2 temperature , " F" Pause 1000 : goto mainloop
Also, in your original code, you show:
define OSC 20
Put all DEFINE's in upper case. It's a bit weird like that.
Your original code was probably still compiled as if it were for a 4 Mhz oscillator, even though you had 'define OSC 20'.




Bookmarks