September 15, 2013

Launchpad, I2C, EEPROM = WINNING!

I've got tiger blood. Or something. Who else uses bad internet memes years after they're even remotely funny?

So this post is to document the travails I encountered in trying to get I2C working with the MSP430 Launchpad and a simple EEPROM memory chip, wired up my brutally hacked version of the dangerousprototype's 3EEPROM board.

Let's cover the background; I have a TI MSP430 Launchpad that I want to eventually be the controller for my SI570 break-out board, shown here [1]. My first thought was to use Energia, as it has the nice Wire library for I2C interactions, as well as a serial writing functionality for debugging. I naively tried adapting some code snippets I found on the googletubes to see if I could get the frequency to change, but to no avail.

The next step, then, was to simplify. Let's make sure that my I2C stuff was actually doing what I thought it was doing. So when I put on an I2C sniffer, it showed nada, zip, zilch, nuthin, zero. Well crap, apparently I don't know how to use the Wire library.

To test whether or not I could do I2C, I decided to try and do something ridiculously easy, and stumbled upon the 3EEPROM board of dangerousprototypes.com [2], complete with command sets to test it out. I procured the 25xx and 24xx SPI and I2C PROM chips and built a simple little protoboard circuit for testing purposes. Useless and requisite photo here:


All I wanted to do was write a couple of bytes to the 24xx chip and read 'em back. So began the long and painful journey....along the way I found a nice useful serial debug library (based upon work by oPossum of 43oh) [3], and got the workings of a simple skeleton makefile/project to work.

While the 0101E0009 release of Energia didn't seem to work for me, the latest release, 0101E0010 did the trick. But I wanted to see it work outside of Energia, as I really don't like the IDE provided with it. I may eventually try to get an external makefile to work (like this here [4]), but for now I'll continue with what I have working here. I eventually found an I2C library that worked for me (located here in the 43Oh forums by member V0JT4 [5]). I needed to add a simple little function that must have been an intrinsic with the compiler he was using, the _swap_bytes function.

As can be seen from the wiring picture below, I'm using the Gabotronics Xprotolab [6] as a protocol sniffer, powered from the 5V tap near the USB connection of the Launchpad. The 24XX chip has an I2C address of  0x50 hex, and examing the blurry picture you can see the bytes of the phrase HELLO WORLD being sent back and forth from it. Use asciitable.com to help with the translation of hex into ASCII values if you're really bored.



Anyway, I put the code up on github [7]; almost none of it is original code from me. Thanks to the awesome forum at 43oh for basically doing all of the heavy lifting for me!

[1] - http://underwaterwhistler.blogspot.com/2013/08/si570-breakout-fun.html
[2] - http://dangerousprototypes.com/docs/3EEPROM_explorer_board#24AA_I2C_EEPROM
[3] - http://forum.43oh.com/topic/1289-tiny-printf-c-version/
[4] - https://github.com/elpaso/energia-makefile
[5] - http://forum.43oh.com/topic/1772-universal-ripple-control-receiver/
[6] - http://www.gabotronics.com/development-boards/xmega-xprotolab.htm
[7] - https://github.com/kpimmel/msp430_i2cEEPROM

2 comments:

  1. Hi, can you please tell me more about how did you connect the EEPROM IC to the MSP board and how did you program it? Like the libraries. I'm interested to know more. Thank you.

    ReplyDelete
  2. Hi Bryan, sorry for the late reply. The actual wiring is pretty straightforward; the pinout for the launchpad for I2C is P1.6 for SCL and P1.7 for SDA. Just map those to the appropriate pins of your EEPROM (check your datasheet). Note that you may need 10kohm pull-up resistors.

    As for programming it, I use the mspdebug utility shipped with Energia. If you look at the makefile in my project files (source 7 above), you can see the exact command: mspdebug tilib -d USB --force-reset "prog main.elf"

    As for the libraries, well, I scoured the web for a couple of different of implementations and when I found one that I could get to work, I used it :). I'm definitely on the beginner side in terms of experience. If you have questions, I really encourage you to explore the forums at 43oh.com and if you can't find an already posted answer to ask one yourself there. They really are pretty quick in answering and are polite and helpful.

    Good luck!

    ReplyDelete