I²C Project: A Single Flipped Bit

I've been working on trying to get I²C comms working on Mecrisp Stellaris, using the built-in hardware module. I spent many lunch breaks seemingly going nowhere, because I couldn't get the Trellis LEDs to even turn on, and the signals did not look correct on the scope. After much looking at waveforms, reading the manuals, and inspecting code, I finally realized that the command bit in the IC_DATA_CMD register is 0 for write, and 1 for read, and not the other way around.

With that fix, I was immediately able to get the Trellis LEDs to turn on and to start blinking.

Some blurry proof the Trellis LEDs came on

Here is the first test waveform I got after applying the fix.

img/first_i2c_signals.png

The first half is

S 1 1 1 0 0 0 0 0 ACK

which is the START pulse, followed by the 7-bit device address $70, followed by the (now correct) command bit, followed by the acknowledgement bit. Then

0 0 1 0 0 0 0 1 ACK P

which is the command $21 (start Trellis oscillator) followed by the acknowledgement bit, followed by the STOP pulse.