I2C Communication- STM32F407VG(Master) to PCA9554D(Slave)

Thread Starter

satti15790

Joined Jul 17, 2017
17
Hi ,
I am trying to establish a I2C connection between STM32F407VG to PCA9554D using STM32 cube.
I am using HAL libraries for the communication but i am not able to establish the connection .
it is returning HAL_Busy error while using api below
device address: 0x40
HAL_I2C_Master_Transmit(&hi2c2,DeviceAdress,data,size,timeout);

if iam wrong can you please help me out with sample program


Thanks in advance
 

turboscrew

Joined Dec 7, 2018
16
With STM32 devices that usually happens when the lines are not idle when the communication starts. When I2C is enabled, often just a glitch on clock or data line can cause that, and it's hard to get rid of that. Usually the 9 clock pulses don't help.
 

Stuntman

Joined Mar 28, 2011
222
IIRC, you have to do a left bit shift on the device address. I believe this is mentioned in the source code for the HAL. For instance, I have some working code using this (x is the slave address).

TestErrorI2C=HAL_I2C_Master_Transmit(&hi2c1, x<<1, (uint8_t*)i2cTXbuffer, (uint16_t)6, 20);
 
Top