Wire does not always connect to I2C properly
Posted: Sun May 10, 2020 6:58 am
Hello All!
I've faced a strange problem that I don't understand how to solve properly.
I have stm32f103 chip that is connected with en EEPROM via I2C. I use STM32Duino core and work with EEPROM via Wire lib. In the most cases everything works well and I connect to I2C EEPROM and can read and can write.
But sometimes, at very rare cases, I can't connect to I2C properly. In the meaning that I connect to it with the same mannor and it seems to be connected. But when I read it returns something random and when I try to write it doesn't. At the same time no errors is returned at all. So from Wire it looks like everything is fine.
So, what shall I do in that way? How to determine that I2C is connected properly? And how to reconnect if I see that there is a problem?
PS. The first thing that comes in my mind - try to write something and read it back. If the value is correct then continue to work otherwise - reboot. But it doesn't seems to be a good solution.
PSS. The code for init:
Wire.setSCL(I2C_SCL);
Wire.setSDA(I2C_SDA);
Wire.begin();
PSS. EEPROM that I use is AT24C08
I've faced a strange problem that I don't understand how to solve properly.
I have stm32f103 chip that is connected with en EEPROM via I2C. I use STM32Duino core and work with EEPROM via Wire lib. In the most cases everything works well and I connect to I2C EEPROM and can read and can write.
But sometimes, at very rare cases, I can't connect to I2C properly. In the meaning that I connect to it with the same mannor and it seems to be connected. But when I read it returns something random and when I try to write it doesn't. At the same time no errors is returned at all. So from Wire it looks like everything is fine.
So, what shall I do in that way? How to determine that I2C is connected properly? And how to reconnect if I see that there is a problem?
PS. The first thing that comes in my mind - try to write something and read it back. If the value is correct then continue to work otherwise - reboot. But it doesn't seems to be a good solution.
PSS. The code for init:
Wire.setSCL(I2C_SCL);
Wire.setSDA(I2C_SDA);
Wire.begin();
PSS. EEPROM that I use is AT24C08