Page 1 of 1

Need binary i2c dump for GY-271 compass

Posted: Mon Oct 26, 2015 4:16 am
by mikorians
This is for my own education in I2C.
I've been learning about bit bashing and I've (for laughs) been using an old parallax BS2.
I developed some i2c protocols for it, but something in my conversation is out of order/missing.
I'm wondering what I should be sending/receiving.
I know the following should be true:
It's address:1E
To configure for continuous:
(Start)$1E $02 $00(Stop)
To read the six bytes I send:
(Start)$1E $03(stop)
(Start)$1E $06 and get 48 bits.
But it keeps sending back:
$DFEF F7FB FDFE
:(

Re: Need binary i2c dump for GY-271 compass

Posted: Mon Oct 26, 2015 4:25 am
by mikorians
Some of the code I had borrowed:

start
high SDA_PIN
high SCL_PIN
debug "START"
debug $0d
low SDA_PIN 'bring SDA low while clock is high
low SCL_PIN
return

sstop
low SDA_PIN
high SCL_PIN
pause 10
high SDA_PIN 'bring SDA high while clock is high
debug "STOP"
debug $0d
return
'(I also sometimes put a high SCL_PIN before calling sstop)

out_byte ' shift out o_byte beginning with most sig bit

low SDA_PIN

for n=0 to 7
b= (o_byte >> 7) & 1
if (b=1) then out_one
SDA_DIR=OUT
debug "0"
_clk
high SCL_PIN
pause 100
low SCL_PIN
pause 100
o_byte=o_byte << 1
next

SDA_DIR=IN
return
out_one
SDA_DIR=IN
debug "I"
goto _clk