I2C – Troubleshooting I2C Slave Pulling Down SCL

i2cmicrocontrollerpulluptexas instrumentstm4c123g

I have an MCU (Texas Instruments tm4c123gh6pm) in which I have configured an I2C slave device. I have taken 3.3V from the MCU pin that provides them and connect them to two 4.7 kOhm resistors (to make the pull-ups). I have tried with 2 1.5V batteries in series as well.

When I connect one of the above two lines to the slave SDA, it remains high (fine) but, for some reason, as soon as I connect SCL to the other pull-up res., it goes low (to 0.8 V or so). For some reason, the slave's SCL pulls down the line while the it is doing nothing (I haven't even connected it to the master).

Why this happens?

Here is how I initialize the I2C slave:

static void I2C1_Init(void) {
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    GPIOPinConfigure(GPIO_PA6_I2C1SCL);
    GPIOPinConfigure(GPIO_PA7_I2C1SDA);

    GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6);
    GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);

    I2CSlaveEnable(I2C1_BASE);
    I2CSlaveInit(I2C1_BASE, I2C_SLAVE_ADDRESS);
}

IMPORTANT EDIT

I'm providing the pull-up resistors from an external power supply, whose ground I connect to the MCU GND pin. The MCU is powered by a laptop through its USB port. I have observed that the problem above doesn't arise if I don't connect these 2 grounds, but as far as I understand I do need to connect them, right?

Best Answer

The SCL pin is initialized, when is a master, to be push-pull since in reality the SCL pins are having an internal pull system. Try with GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_6); without the SCL which should call the OD type. It could be that in slave configuration, there are issues. In fact, is not the best documented part, when used as a I2C slave, and I won't exclude presence of bugs in the IC.