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);