Sunday, October 21, 2012

7-bit vs 8-bit addresses in I2C

Discovered that my I2C device address was incorrect (at least my understanding).  After getting the compass working, I modified the Quickstarter code a but and hooked up the RGB LED Backpack.  No success, but then reviewed the Arduino  Logic Analyzer capture again.

Found that my 'address' appears to be 0xFE - not 0xFF as expected.  Also noticed that when it works, the LA tool I2C decoder is in 'READ' mode.  That little bit didn't make sense.  I changed the address in my modified compass code and the RGB LED Backpack came to life.

After a very confused Google search session, I contact Pierce at Logos Electromechanical asking puzzled questions.  He clued me in on some subtleties regarding addresses.  The key was this very clean high-level I2C tutorial that he shared.  THANKS!

Turns out the problem was that when I used the bit-bang method, it wasn't accounting for the 'WRITE' bit.  So when the L-A tool picked up the address it showed the address's 2-8 bits and the 'write' bit.  This accounts for the 0xFF = 0xFE on LA.  I need to do some more binary math to convenience myself... 

No comments:

Post a Comment