msp430-gcc, msp430-g++ and the tale if I2C

So finally, after 35 years, reality is catching up with George Lucas 3D Display beam ( Star Wars 1977 ). It took about the same time for the Star-Treck communicator to catch up ( Star Treck 1966 ).
The link is a year old but I just found it on YouTube, Enjoy.

And while you are at it … Deathray anyone ?

I have spent the past week again working on the chess robot I am building with my son. Unfortunately I have yet to get the I2C communication between two msp430 devices to work properly.

Getting mspgcc installed also took longer because I was not able to find instructions on how to build msp430g++ in the begining and once I found the instructions it would fail. two days in I decided to re-compile the whole project with the proper configuration following these instructions AND also download and extract the gcc-g++ package before using:


wget http://open-source-box.org/gcc/gcc-4.6.3/gcc-g++-4.6.3.tar.bz2
cd gcc-4.6.3
tar -xjf gcc-g++-4.6.3.tar.bz2
cd ../gcc-4.6.3-msp430
../gcc-4.6.3/configure --target=msp430 --enable-languages=c,c++ --program-prefix="msp430-"

Once I had my development environment back up I went ahead and build a LCD driver and started working on the I2C communication between two devices. After a lot of trial and error I came across this link .

It took me two days to realize, that I had to remove the jumper from LED2 to get any kind of communication going between devices. Turns out there are a lot of people which encounter the same issue but the solution is hard to find online.

Now I have not yet been able to get the slave to work but I hope that I’ll get this done before I have to get back to work tomorrow.

UPDATE:
I finally got the I2C communication going. I went over to this page and read through it and used this code to make it work. I edited the code a bit to output bad states and figure out when things go wrong. It would work 60% of the time, and had issues the remainder of the time.

After tinkering for another couple of hours I accidentally connected +5V to the msp430 and was surprised to see no communications issues. Of course reading up on it I found that it is recommended to use external Pull Up resistors of about 5kOhm. Here is the spec file for I2C the min resistor for 3.6V is about 1kOhm. The max is based on the capacitance of the bus. I picked the 5kOhm to be somewhere between standard and fast-mode. To note is that the internal pullup resistors of the msp430 are about 20k-50kOhm and thus way out of spec.

I2C spec

Note: I also found this quote, and found that disabling the pull-ups from the master improved the communication. Of course it is still not 100%. So external Pull-Ups is what I am going to use.

“The pull-ups should only be used when the pin is operated as an input (PxDIR.y == 0). In fact, when having the pin set as an output (PxDIR.y == 1), enabling the respective pull-up/down resistor bit (PxREN.y == 1) has a direct impact on the port’s output logic on 2xx devices, see the pin schematics in the device datasheet for more details.”

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

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