I2C 101

Embedded Labs has come out with a very detailed I2C 101  tutorial, that you should check out if you have any questions on the system. I2C is a short distance serial interface that only requires 2 bus lines. Keep in mind that as wires go down complexity goes up. While there are more than a few I2C devices out there in the wild, and the 2 wire system does make wiring a breeze sometimes, the information required to make use of it often seems confusing to someone who is just starting with it.

The tutorial covers basic theory, stop / start conditions, addressing, data transfer, and acknowledgment plus illustrations. A couple of specific examples are given in the form of a 24LC512 serial eeprom, and a DS1631 digital thermometer complete with code.

15 thoughts on “I2C 101

  1. I2C is great, and really useful when you are using multiple Microcontrolers and need to share information.
    Using standard i2c devices (compass, eeprom etc) is easy as the slaves already are coded.

    In a pic the i2c Master is already done, maquing several pic´s act as slaves, that’s the tricky part.
    Even mode difficult is your making a network whit several masters.

  2. Having designed a system using I2C it is not just a short distance bus. There are bus extender IC’s that can extend it to meters. It is the best interface for a lot of things out there. A to D at a distance. Static code and web page storage. Data logging storage etc. The Stellaris Processor i use has a built in I2C interface for ease of use, all library’s included in the development software. Don’t be a chicken, go forth and use new things and design them into your devices.

  3. @Texas Toast: Microchip’s AN734 spells it out pretty clearly for both SSP and MSSP both in English and in assembly. PIC I2C hardware doesn’t do you any favors since it requires your code to implement part of the state machine, but as long as you stick to the states defined in the appnote things tend to work ok.

    Just make sure to get document number DS00734B or later. I once spent a week trying to debug an I2C ISR because the older version required BF=0 for state 3 which isn’t always the case.

  4. @Texas Toast
    Perhaps I over reacted, but I had just spent two hours looking for a manual to the c30 I2C library before this came in n my RSS feed. The microchip documents are fairly worthless in that none of them actually use their own library.

    Honestly though, if I wanted a theoretical overview of how I2C works, I would just look it up on wikipedia or something. The mikroC libraries and C30 libraries are very different in how they are used.

  5. I like the read even though I’m just starting out with microcontrollers’s and stuff.
    I’d like to make my Ti Launchpad communicate with a Wii Motion Plus sensor that uses I2C.

    long distance is 20m.
    short distance is 20cm.
    case closed.

  6. I use I2C in a ton of products and it’s a nice easy to understand protocol if you don’t have a lot of noise in your system, and if you don’t run the signals off board more than 1 meter. You can use Schmitt-Trigger inputs to improve noise immunity.

    This is genius right here though, using constant current pull-ups instead of resistors. Posted by TZ on the Embedded Labs thread comments:

    Haters … STFU
    Whiners … GTFO
    Hackers … 01101000 01101001 01100111 01101000 00100000 01100110 01101001 01110110 01100101

  7. Don’t most desktops use I2C for health monitoring? If you can access it some how it would seem like a great way to add an LCD or even an IR Remote to your PC without using one of our USB ports. Of course I really wish that desktop PCs would bring out all the available buses and ports to headers even if they are not using them

  8. Don’t most PCs have an I2C bus for monitoring system health? You know for fans and such?
    Seems like an interesting way to add an LCD display or other sensors to you PC without using a USB port.

  9. i believe the ram modules have an i2c eeprom on them, so the bios can properly configure the dram controlers

    just solder a few thin wires to the ram module and you have a breakout board for it

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.