I'm using a PIC18F2680 at 32mhz
I'm struggling with communicating with a DS18B20 sensor.
I plugged my Saleae Logic analyser into the system and can see there is a glitch in the OWOUT $33 rom command at about 2.2ms.
So the result is garbage..
The DS18B20 does respond to the reset request though just prior to the above.
Code:
DEFINE OSC 32 '8mhz Clock (x4 = 32mhz)
OSCCON = %01110000 'Internal 32 mhz Osc and stable
OSCTUNE = %01000000 'Enable PLL 8mhz x 4
WDTCON = %00010101 'Set watchdog Timer for 1 second
CCP1CON= %00001100 'CCP1 Module PWM Mode
HLVDCON= %00000000 'HLVCON Disabled
T1CON = %00110000 '$30 = Prescaler 1:8, TMR1 OFF
TRISA = %00000011 'SET PORTA0.1,2 AS INPUT, REST AS OUTPUTS
TRISB = %00001000 'SET PORTB.3 AS INPUT REST AS OUTPUTS
TRISC = %10000000 'SET PORTC.7 AS INPUT REST AS OUTPUTS
DQ var PORTC.4 'One-wire Data-Pin "DQ" on PortC.4
MainLoop:
OWOUT DQ, 1, [$33] ' Issue Read ROM command
OWIN DQ, 0, [STR ID\8]' Read 64-bit device data into the 8-byte array "ID"
lcdout LCM,LCL,LCM,L12,"Fam ",HEX2 ID[0],"h"
lcdout LCM,L22,"Ser ",HEX2 ID[1],HEX2 ID[2],HEX2 ID[3],HEX2 ID[4],HEX2 ID[5],HEX2 ID[6],"h"
lcdout LCM,L32,"CRC ",HEX2 ID[7],"h"
PAUSE 500 '500ms second pause, replace sensor for next read
lcdout LCM,LCL
goto MainLoop

See the weird glitch in the $33 bits being sent..
Any ideas.
Bookmarks