0
\$\begingroup\$

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?

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ I have tried it and get the same result. \$\endgroup\$
    – Martel
    Dec 24, 2021 at 20:08
0
\$\begingroup\$

I have tried with a different I2C module. I was using I2C1 (pins PA6 and PA7) and now I'm using I2C2 (pins PE4 and PE5). All works fine, it seems my MCU is damaged or faulty.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ If this solved your problem then please "accept" your own answer so other people don't waste time reading your question. \$\endgroup\$ Jan 2 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.