Open neilh10 opened 2 years ago
The bad reads can happen after an I2C lockup. It would seem that if there is a bad read, it should be caught in the physical device driver ST3100dd.
Arduino I2C lockup has had a lot of discussion. https://github.com/arduino/Arduino/issues/1476 Enabling it is here https://github.com/neilh10/STC3100arduino/commit/54891f124a0e26337753e35eb2fc78bf6042388b
Hey @fronders is this something we can help fix / have already fixed?
Well, in STM32 I2C there's no such problem at all, since the HAL library allows to validate the I2C transactions. Basically same check that we implemented for timeout works out for this purpose too, two birds with one stone 😁. In AVR Wire though there's no such possibility, and added timeout check should address the issue. Another way of solving this for AVR is to move to alternative Wire implementations that provide such validation check
Thanks for the thoughts. @fronders , interesting your mentioning of the AVR Wire timeout, doesn't that perform the same function. ? I must confess I have watched some of the Arduino conversations, but I haven't got out my I2C Protocol analyzer to understand what is happening with the STC3100. I have found some chips are more susceptible to repeated read problems than other chips ~ so I was able to filter out for a few chips that I used, and then gave up on the chip and coloumb counter philosophy. Plus the chips became unavailable.
I've been using a few left over boards with the STC3100 for some test bench power usage monitoring and accurately monitoring a LiIon battery over power discharge, and that doesn't require reliability, but always interested to understand the root causes. Especially with the new I3C protocols coming along
In some cases when reading from the STC3100 registers, they are read as 0xff. When reading from the STC3100, need to validate that the transaction is good. This is a general I2C issue that there is no way of validating the read registers.
It may be possible to parse the message looking for out of expected range values, and if received redo the transaction.