News

Several protection methods for EEPROM

Time:2018-10-09

Serial EEPROM should be a very reliable device, but in my use, there will often be data errors. Chairman Mao said: Knowing what you know, you can be unbeaten! What is the reason?
Actually this Most cases occur when plugging and unplugging. Let us come
1. The timing of EEPROM read and write may be slightly wrong;
2. In the period of power failure, during the period between the voltage drop to a certain level and the complete power failure, the uncontrolled fast random level appears on the read and write signal lines of the MCU and EEPROM. These levels may be Combine some write commands that are considered legal by the EEPROM, and the result is to modify the values in the EEPROM;
3. During the reset of the power-on, the level of the I/O pin is undetermined, and some write commands may be randomly combined;
4. During the EEPROM read operation, a reset (such as a charge reset) occurs, forming a situation similar to (b);
5. After the voltage is lowered, the MCU may run away. The result is that the bottom driver of the EEPROM is written, and the data is written in! Let's taste the twisted melon!
Treat the enemy can not be soft, how to kill them in the bud! Look at my trick:
1. Lazy: According to the timing on the Datasheet, it is found that most of the time reading and writing is correct, but sometimes it is not correct. At this time, the speed of reading and writing can be reduced. How many NOPs are there, not too stingy? Let us measure (ROM) The next!
2. Shelter: In order to prevent reset during reading EEPROM, we can disable reading and writing EEPROM within 200ms after MCU reset. The reset jitter caused by charging is usually within tens of milliseconds. After this period of time, it will appear again. The possibility of resetting is small,
3. Verification: In the underlying driver of the EEPROM, when performing the write operation, judge some flags, and the good name can pass, otherwise, you have to call back the original (jump to the reset address)
4. Buy more insurance (3 best) to save yourself: For important data (such as communication password, parameter setting, etc., the amount of information is not large, we have to use three backup methods. This information is stored in three different In PAGE, it is better to have different addresses in PAGE. When we write these data, we have to write three times for different addresses, and when reading, for the data read from three places, if they are all the same, there is nothing to say. If there are two identical and one different, use the big number decision, use the same value, and write the value to a different address. Of course, if the three values are all different, you just have to take one (like the first one). And write it to the other two addresses. This method is very effective, because the general error erase will not be all data, but only somewhere, we can allow a unit of EEPROM to be erased by mistake, As soon as I read it, I recovered.