Stm32 I2C eeprom中的冗余值和冗余系统

Stm32 I2C eeprom中的冗余值和冗余系统,stm32,i2c,eeprom,Stm32,I2c,Eeprom,我继承了一个用于STM32的eeprom库,用于使用HAL_i2c_Mem_xxx库的i2c设备。 我注意到,每个保存的参数都有2个副本。 所以总共是相同值的3倍 我想知道这是否是一种安全机制,以避免写入/读取错误数据,这是否是在i2c上使用eeprom时的最新技术 还不完全清楚的是: 1. After each read call, all the 3 values are read and if the return state from the HAL_I2C_Mem_Read is di

我继承了一个用于STM32的eeprom库,用于使用HAL_i2c_Mem_xxx库的i2c设备。 我注意到,每个保存的参数都有2个副本。 所以总共是相同值的3倍

我想知道这是否是一种安全机制,以避免写入/读取错误数据,这是否是在i2c上使用eeprom时的最新技术

还不完全清楚的是:

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.
现在真的需要这些吗

问候,

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确实需要某种类型的值检查,因为它们可以成功地进行位翻转,尽管有更优雅的方法来确保数据完整性(如ECC),这种方法被证明是有效且易于实现的,因此在我看来,这将“完成任务”(发动机ECU甚至使用这种方法将数据存储在EEPROM中)

我也同意你在1、2、3和4中的观点

在我的例子中,我放弃了使用EEPROM存储参数,我将在PCB中不使用EEPROM,取而代之的是,我将在闪存中模拟EEPROM,因为这将不太容易发生位翻转(不需要存储每个值的3倍)和通信错误(I2C有时真的有问题)

我仍然在编写EEPROM仿真代码,但它的工作方式是基于ST()的应用说明AN2594。
此外,AN中描述的代码包含在HAL库软件包中,该软件包在我的计算机中位于:STM32Cube\u FW\u F1\u V1.4.0\Projects\STM32F103RB Nucleo\Applications\EEPROM\EEPROM\u Emulation

您能提供一些代码来实现flash中的EEPROM吗?@Luigi在答案中添加了信息;)