Redundant values and Redundancy systems in I2C eeprom

时间:2017-06-15 10:08:25

标签: stm32 i2c eeprom

I've inherited an eeprom library for STM32 for an i2c device which is using the HAL_I2C_Mem_xxx library. What i've noticed is that for each saved parameter there are 2 copies of it. So in total 3 times the same value.

I was wondering if this is a safety mechanism to avoid wrong data to be written/read and if this is the state of the art when using an eeprom over i2c.

What's not completely clear is the following as well:

1. After each read call, all the 3 values are read and if the return state from the HAL_I2C_Mem_Read is different than HAL_OK, all the 3 values are overwritten in the memory with a default value --> shouldn't be better to retry a read call first?
2. If the read call returns 3 different values, all the 3 values are overwritten with a default value --> this could be the safest solution
3. If the last one in memory is equal to 1 of the 2 values and within boundaries, the last one in mem is copied to the one which is different so all 3 of them are equals. If outside boundaries the default is written in all of them.
4. If the first two are equal and the first in memory is within boundaries, the first one is written in the last one in memory.If outside boundaries the default is written in all of them.

Is all of this really needed nowadays?

Regards,

1 个答案:

答案 0 :(得分:1)

I was wondering if this is a safety mechanism to avoid wrong data to be written/read
and if this is the state of the art when using an eeprom over i2c.

好吧,我正在使用STM32 + eeprom的应用程序,并且有完全相同的问题,经过一些搜索后我发现EEPROM确实需要某种值检查,因为它们对于bitflip来说是可以接受的,而且它还有确保数据完整性的更优雅的方法(如ECC),这种方法被证明是有效且易于实现的,因此在我看来,这将是"完成工作",(这种方法甚至被发动机ECU使用)将数据存储在EEPROM中。

我同意你在1,2,3和4中的观点。

在我的情况下,我放弃了使用EEPROM来存储参数,我将把未填充的eeprom留在PCB中,相反,我将在FLASH中模拟EEPROM,因为这将不太可能成为bitflipping(不需要存储3次每个值)和通信错误(有时候I2C确实是错误的)

我仍在编写EEPROM模拟编码,但它的工作方式基于ST(http://www.st.com/en/embedded-software/stsw-stm32010.html)的应用笔记AN2594。 此外,AN中描述的代码包含在HAL库包中,该库在我的计算机中位于:STM32Cube_FW_F1_V1.4.0 \ Projects \ STM32F103RB-Nucleo \ Applications \ EEPROM \ EEPROM_Emulation