Question
STM32F7 HAL I2C Reading bytes out of sync
Posted on April 25, 2016 at 15:27
We're currently talking to a few I2C devices on the same bus using latest STM32F7 HAL drivers.
All works fine for a while (minutes or hours) and the bus debug on our scope looks perfect, however, every so often we have a strange ''bug'' where the I2C read appears to get out of sync with what we see on the scope.Once in this mode, all subsequent device reads become corrupted.eg.When communication is all good, this is typical write/read sequence:Write 0 to IO expander to tell it we want to read port 0Read 0x40 backWrite 1 to expander for port 1Read 0x02 backAfter the intermittent bug happens all reads are like this:Write 0 to IO expander to tell it we want to read port 0Read 0x00 backWrite 1 to expander for port 1Read 0x40 back (the number which should have been in the RXDR read register on the previous read)The BUS on our scope still look fine, it's as though there is an I2C read buffer which has got it's pointers mixed up.We've made sure not to make any calls to I2C inside an ISR and aren't using an RTOSAny thoughts on what might cause this or how to recover from it ? #i2c #stm32f7