AnsweredAssumed Answered

STM32F7 HAL I2C Reading bytes out of sync

Question asked by teal.andy on Apr 25, 2016
Latest reply on Nov 14, 2017 by David Henretty
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 0
Read 0x40 back
Write 1 to expander for port 1
Read 0x02 back


After the intermittent bug happens all reads are like this:
Write 0 to IO expander to tell it we want to read port 0
Read 0x00 back
Write 1 to expander for port 1
Read 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 RTOS


Any thoughts on what might cause this or how to recover from it ?

Outcomes