My guess is that this code will work......
Code:
@ device pic12F675, protect_off, mclr_off
define OSC 4
DEFINE OSCCAL_1K 1 'Set OSCCAL for 1K device
DataPin VAR GPIO.0 'DOCI on the PIR
PIRdata VAR WORD
i VAR BYTE
ANSEL = 0 'No AD on 12F675
CMCON = %00010111 'Digital pins - no comparator
WPU = 0 'No pullups
WHILE 1 'Do forever
HIGH GPIO.1 'Set a pin to time the reading
GOSUB ReadPIR 'Call the Sub
LOW GPIO.1 'Reset a pin to time the reading
PAUSE 10 'Just something to sync the scope
WEND
ReadPIR:
INPUT DataPin 'Let PIR control the Datapin
PIRdata = 0 'Use this time to let Datapin settle
WHILE DataPin = 0 : WEND 'Wait for PIR to indicate "new data"
PAUSEUS 25 'Wait for PIR to fiddle with the data
FOR i = 14 to 0 STEP -1 'Loop to get 15bits
LOW DataPin 'Force Datapin Low
HIGH Datapin 'Force Datapin High
INPUT Datapin 'Let PIR control the Datapin
' You may need a short pause here if you have long wires to the PIR
PIRdata.0(i) = Datapin 'Sample the datapin
NEXT
LOW DataPin 'Force Datapin Low
INPUT Datapin 'Let PIR control the Datapin
RETURN
END
... it compiles and runs as expected. Only problem is that i don't have a PIR to verify it with, it does however look OK on a scope. If i have interpreted the datasheet correctly you should be flying.
/Ingvar
Bookmarks