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.

Comments

  1. Chris says:

    Yeah, I’ll just run a 3rd wire, thanks.

  2. Ikari-Pt says:

    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.

  3. wulfman says:

    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.

  4. UltraMagnus says:

    Unfortunately this is for the commercial mikroC rather than the standard free C18/C30, which will make it useless to most here.

  5. smoker_dave says:

    Useless.

  6. Daid says:

    Meters is still ‘short distance’ IMHO. But maybe I’m spoiled :P

  7. chango says:

    @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.

  8. Olivier says:

    @Daid : depends of the number of meters…
    1000000m is a lot, while 0.00000001km is quite short :)

  9. UltraMagnus says:

    @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.

  10. Alex rus says:

    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.

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

  11. 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:

    http://www.i2cchip.com/constant_current_pullup.html

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

  12. lwatcdr says:

    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

  13. lwatcdr says:

    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.

  14. mike says:

    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

  15. John says:

    @Brett — thanks for posting that. genius, indeed!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 96,369 other followers