Something like this should work (untested). Note that is "blocking", and that the code will not advance past this until you get 8 high-to-low transitions on the clock.
Code:
GetNextByte:
BitCounter = 0
GetNextBit:
While ClockPin=1:Wend ; Sits here and does nothing while clock pin is high
DataByt.0 = DataPin ; Samples data pin as soon as clock goes low
BitCounter = BitCounter + 1 ; Keeps track of number of bits received
If BitCounter = 8 then goto GotByte ; When we have a byte, get out
DataByt = DataByt << 1 ; Move things over for next bit
WHILE ClockPin=0:WEND ; Sit here while clock is low
Goto GetNextBit ; Grab next bit if we haven't got all 8
GotByte:
...
...
...
END
Bookmarks