cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745I I2C Recovery after addressing nonexistent device?

I have I2C working properly, but can't seem to figure out how to recover the bus and get it to working again if I test for the presence of a device that is not on the bus and therefore I2C_Mem_Read() returns HAL_ERROR.  There are other devices on the bus, but HAL_ERROR seems to be latched and calling MX_I2C4_Init() again doesn't undo it and allow a retry.  The project is built with EWARM 9.30.1 and STMCubeMX 6.11.0.

Suggestions?  

Background:  I know this is working and checked it against an oscilloscope/protocol analyzer; what's happened is that one of my 2 I2C devices is unplugged and I want to recover from the error.

I2CResult = HAL_I2C_Mem_Write(&hi2c4, (0x22<<1)|0x01, 0x0C, 1, ExpanderConfig, 1, 100);

(device is on I2C4 pins, i2c address is 0x22, register address is 0x0C, address size is 1, we are writing 1 byte of ExpanderConfig, an array, and waiting 100ms for timeout)

I2CResult = HAL_I2C_Mem_Read(&hi2c4, 0x47<<1, 0x08, 1, BufConfig,3,100);

(reading on i2c4 pins, i2c address is 0x47, register address is 0x08, address size is 1, BufConfig is a 3 byte array, and we time out in 100ms.)

 

 

10 REPLIES 10

Thanks for coming back with the solution.

> my target I2C device (TUSB320LAI) needs to have its enable pin in the correct state or it won't talk on I2C at all

"Nice".

JW