2017-06-15 123 views
0

我已經繼承了STM32的eeprom庫,用於使用HAL_I2C_Mem_xxx庫的i2c器件。 我注意到,對於每個保存的參數,它都有2個副本。 所以共有3次相同的值。I2C EEPROM中的冗餘值和冗餘系統

我想知道這是否是一種安全機制,以避免錯誤的數據被寫入/讀取,以及如果這是當使用超過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. 

是這一切真的需要越來越大呢?

問候,

回答

0
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,相反,我會效仿EEPROM在FLASH中,因爲這將不太容易實現位翻轉(不需要存儲每次值的3倍)和通信錯誤(有時候I2C實際上是越野車)

我仍然編碼我的EEPROM仿真,但它的工作方式是基於在ST的應用筆記AN2594(http://www.st.com/en/embedded-software/stsw-stm32010.html)上。 此外,在AN描述的代碼包含在HAL庫包,這在我的電腦islocated在:STM32Cube_FW_F1_V1.4.0 \項目\ STM32F103RB-核蛋白\應用程序\ EEPROM \ EEPROM_Emulation

+0

請您提供一些代碼位在閃存中實現eeprom? – Luigi

+0

@Luigi我在答案中添加了信息;) –