# Slave can't pull I2C low

I'm trying to use 3 TCA9539PWR and a TCA6408A on an I2C bus.

Here's the schematic diagram:

However, when I try to send the TCA9539PWR's addresses , none of them responds (no ACK) and when I try to send the address of TCA6408A (0x40,) the wave shows that it can't pull down the bus fully.

I use 10k pull-up resistors, and I think it's the resistor is strong enough;I can't change the res on the pcb easily, so it's hard for me to test that.

That's a part of the code I use to control the SDA and SCL:


void SDA_OUT(void) //init SDA to send Data
{
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = I2C_SDA_Pin;
HAL_GPIO_Init(I2C_PORT, &GPIO_InitStruct );
}

//...

void SDA_IN(void)    //release the SDA wire
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = I2C_SDA_Pin;
HAL_GPIO_Init(I2C_PORT, &GPIO_InitStruct );
}

//The SCL wire was initialized by STM32CUBEMX;
GPIO_InitStruct.Pin = I2C_SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

• Would you show the code where the SDA and SCL pins are initialized? Nov 9, 2019 at 8:11
• @Justme Sure,I've edited my question.Thanks. Nov 9, 2019 at 8:22
• Shouldn't the GPIO mode be at an open-drain mode? You are using push-pull mode GPIO. I think that might be the issue. Nov 9, 2019 at 8:37
• I don't understand why bitbanging the I2C in software as the STM32 contains a I2C peripheral so you don't have to bitbang. Nov 9, 2019 at 8:41