I2C not working on pins 9+10

24 Jan 2011

Hello all. I have strange issue getting I2C communication to work on pins 9 and 10. My testing code is:

#include "mbed.h"
#include "TMP102.h"
#include "TextLCD.h"

TMP102 temperature(p9, p10, 0x90);
TextLCD lcd(p21, p22, p23, p24, p25, p26);

int main() {    
    float t;
    while(1) {
        lcd.cls();
        t = temperature.read();
        lcd.printf("Temperature:\n%f", t);
        
        wait(0.5);
    }
}

The only result I get back is 0 (zero). If I switch to pins 28 and 27 then it works correctly. I have checked the connections are correct several times, have tried with another mbed board (giving the same result), and tried with another I2C temperature sensor with my own interface code (again, same result).

Has anyone else encountered a similar problem, or have any debugging tips?

24 Jan 2011

It sounds like your pull-up resistors on SDA and SCL are not wired to +3.3 volts. You might want to double check them.

24 Jan 2011

I may have found something related to this problem - the Workshop baseboard connects pin 9 to the microSD slot S2 connection. I don't use the microSD in my example, but is it possible that this is interfering still?

If this is a problem, does anyone know what the S2 connection does? I thought it was connected to the shield as the microSD breakout boards I've seen have S1 and S2 both tied to ground, but the Workshop board connects S1 to the 3.3V rail. There seems to be extensive information around on the connections to the microSD card itself, but that doesn't include S1 and S2. I can't find any useful information on the connections to the slots. Any help here regarding the function of the pin and whether it's safe to cut it/remap it would be greatly appreciated.

24 Jan 2011

Hexley Ball wrote:

It sounds like your pull-up resistors on SDA and SCL are not wired to +3.3 volts. You might want to double check them.

Thank you for the reply. I don't think this is the issue as the readings are correct when the sensor is attached to the other I2C bus. I am using the Sparkfun breakout board for the TMP102, which includes the pullup resistors.

24 Jan 2011

After further investigation, it seems that S1 and S2 are attached to a switch which is closed when a microSD card is inserted. This ties pin 9 to 3.3V, which would obviously interfere with I2C operation. One unexpected thing is that pin 10 also gets tied to 3.3V when the card is inserted. The schematic shows no connection to pin 10 on the baseboard.

Edit: I was wrong, the behaviour is stranger than that. Pin 9 is always tied to 3.3V and also the shield, regardless of if a card is inserted. However, upon insertion of a card, the shield is disconnected from the other two. Summary:

No card: pin 9, shield, and Vout all connected.

Card inserted: pin 9 connected to Vout, shield connected to neither (doesn't appear to be connected to anything at all).