Shop OBEX P1 Docs P2 Docs Learn Events
i2c read help with a BlinkM — Parallax Forums

i2c read help with a BlinkM

D T CreedD T Creed Posts: 4
edited 2012-06-09 17:10 in Propeller 1
I am new to i2c and thought the best place to start would be with a BlinkM LED from Sparkfun. The protocol is pretty straightforward and I got it working quickly with the help of an old thread by fireHopper on the same subject. Now I would like to read back the values from the BlinkM over i2c. I am attempting to send a command 'g' for Get Current Color which is supposed to respond with three bytes of RGB data. The best I can do is get back $FF, which I assume is reading the pulled up SDA line.
I am using the "minimali2cdriver". I have tried it many ways referring to the i2c spec of:

Send START
Send 7 bit slave address with R/W = 0
Send sub address on the i2c device ( I assume this is the 'g' value)
Send repeated START
Send 7 bit slave address with R/W = 1
Slave should send data
Send a STOP condition to stop the transfer

Hope someone can help out, thanks.


PUB TES
i2c.i2cstart(i2cSCL) 'start condition send SCL pin number
i2c.i2cwrite(i2cSCL, 00_0010) 'send address $01 plus write bit '0'
i2c.i2cwrite(i2cSCL, "n") 'send the command to set color right away, no fade.
i2c.i2cwrite(i2cSCL, $0F) 'value for red channel
i2c.i2cwrite(i2cSCL, $15) 'value for green channel
i2c.i2cwrite(i2cSCL, $50) 'value for blue channel
i2c.i2cstop(i2cSCL) 'stop condition


waitcnt(clkfreq / 10 + cnt)

i2c.i2cstart(i2cSCL) 'send Start condition
i2c.i2cwrite(i2cSCL, 00_0010) 'send address $01 plus write bit '0'
i2c.i2cwrite(i2cSCL, "g") 'send the command to read 24 color bits.
i2c.i2cstart(i2cSCL) 'repeat the start command

(* need to start the read for three bytes here *)


i2c.i2cstop(i2cSCL) 'stop condition

Comments

  • D T CreedD T Creed Posts: 4
    edited 2012-06-09 17:10
    Never mind. I bit-banged an interface based on an i2c manual and then deciphered the object to decide the correct calls. It's working fine now.
Sign In or Register to comment.