Introduction
In the embedded control system, usually must use the nonvolatile storage. Regardless of being time the power failure the maintenance needs to preserve establishment, saves the important record, the reliable nonvolatile storage is one kind of ideal choice. Exterior the non-volatility saves uses the serial storage to realize frequently, the I2C connection product is the most commonly used one type. However, this product and other EEPROM memory are the same, when use also has some conditions to meet latent causes it to have certain non-standards even is the wrong operation. Therefore when carries on I2C the serial EEPROM memory’s application design, besides should consider the data book standard, but must consider that more factors, can realize the more vigorous and healthier system design like this, guaranteed that the system has the fine quality coefficient.
1 against accident writes the measure
Component on electricity/power failure period or the SDA/SCL line’s noise is oversized when has the possibility to cause the accident to write the operation. In order to solve this problem, on the one hand needs to use the decoupling electric capacity (capacity usually is 0.1 μF) helps to filter on VCC the ripple, on the other hand may through write the protective measures to prevent visit to component’s illegal.
Regarding has the hardware to write the protection function the component, may also connect its WP pin VCC to protect the entire array, may also connect its WP pin VSS to give up writing the protection. Usually the user may connect the WP pin micro controller’s I/O mouth on-line, and connects on one in this pin and VCC to pull the resistance, like this may guarantee that the component is usually being at writes the protection condition; But must start the write cycle, the WP pin must first actuate for logic 0. The attention, the WP pin cannot be hanging, otherwise the component will be unable the normal work.
Regarding not writes the protection function the component, then may use an electronic switching to carry in-off control to its SDA pin with micro controller between connection to realize writes the protection. When usually does not visit the component, shuts off their connection; Only when needs to read to the component implementation/writes the operation only then puts through.
2 data integrity protective measures
In the entire write cycle (speaking of majority components, usually is most greatly 5 ms), must maintain VCC above the smallest working voltage. If this time VCC power failure or falls to the minimum voltage below, regardless of then the time length, is unable to guarantee that is written page’s data integrity, possibly causes to program the data not to be correct. In addition, because is unable to the EEPROM unit to carry on programs completely, component’s retention of data time the time which stipulated the data book will be shorter. These questions which the power failure causes regarding the write cycle, usually may take the corresponding protective measures on the software to come to solve. Based on thing submission - retroversion mechanism [1] is one kind of typical solution. May prove, when after the EEPROM memory application system uses this mechanism, regardless of when the power source power failure or the micro controller when is repositioned, the EEPROM memory subsystem may maintain the data the integrity.
(1) submits - the retroversion mechanism establishment
Submission - retroversion mechanism establishment including two aspect contents: On the one hand defines the EEPROM memory’s logical organization; On the other hand is the structure visit to saves the subsystem to carry on, the inspection and the wrong cleaning up connection function. This mechanism EEPROM memory division primarily memory block, verification memory block and buffer area 3 parts. And advocates the memory block to use in storing the user data; The verification memory block uses in depositing the main memory block each page’s CRC verification code, and in this area each page of last CRC uses in verifying this page of data; The buffer area writes the buffer including many, each writes the buffer to contain 4 territory - aerodynamic data territory, the address field, the condition territory and 16 CRC territories. When the data field uses in temporary depositing writing the data page which the function reads, the execution next submission order, this data page will transmit from the buffer area to the main memory block. The address field expressed the buffer data needs to read in page address; The condition territory expression buffer’s condition, including available (available), takes (occupied) and terminates the (expired) condition; 16 CRC territories use for to verify entire write the buffer.
This mechanism has provided 6 connection functions: Reads, writes, the submission, the retroversion, the inspection and the cleaning up.
① Reads the function. Receives 1 page serial number and 1 uses in depositing treats the readout the temporarily stored area indicator. If the temporarily stored area indicator and the page serial number is in the range of validity, the procedure will assign the page data read-in interim area, and will verify the data the validity. This function will return to one of following conditions: Reads (valid read), to read (invalid read) invalid effectively, the invalid temporarily stored area address (invalid buffer address), the invalid page serial number (invalid page number) or the protection defeat (protection failure).
② Writes the function. Receives 1 page serial number and 1 direction fills in the data the temporarily stored area indicator. If the temporarily stored area indicator and the page serial number is in the range of validity, the procedure will read in the data the non-volatility buffer, and will mark the buffer condition to prepare the submission.
③ Submission and retroversion function. The submission and the retroversion function are may after the movement writes the function carries out supplementary operation. The submission function will be read in recently the buffer in the data reproduction memory block corresponding position, and the data page which treats reads in prepares the buffer structure for next. The retroversion function in fact is one “cancels” the operation, it eliminates the recent execution to write the effect which the function produces, and writes the operation for next to prepare the buffer subsystem.
④ Inspection function. The read saves component’s each data page, and inspects the stored datum the validity. This function also inspects the buffer subsystem, guaranteed that the execution has not written the operation. Any invalid page or the execution has not written the operation to cause the inspection function to return to an error status.
⑤ Cleaning up function. Repairs a data damage EEPROM. In fact, it will attempt the mistake which discovers occurs, and takes the corresponding solution measure.
(2) submits - the retroversion mechanism application
Reads the operation: The transfer reads the function to realize.
Renews the main memory block data manipulation: Transfers first writes the function to transfer the submission function to complete again. The main memory block only then after completing a submission operation only then the refresh data, but is not after writes the operation renews.
Exception handling: After any possibility destroys the EEPROM write cycle the event (e.g. on electricity), first will carry out the verification/cleaning up function. The inspection function will examine memory system’s usability, and reports any discovery the mistake; The cleaning up function will solve EEPROM system existence any problem according to the inspection function returns’s error code. When cleaning up operation withdrawal, regardless of the EEPROM subsystem formerly were what condition, should be possible to continue to use.
3 I2C correspondence validity safeguard measure
(1) the software repositions
Sometimes the EEPROM component possible need executive software to reposition the sequence to guarantee that it is in correctly, and known condition. This can be very useful in the certain circumstances. For example, when EEPROM electricity, if the main line noise is oversized, on after EEPROM electricity, will enter not the correct condition; Also like, micro controller in correspondence period, if has the replacement, will cause the correspondence not to fall into the synchronized condition. In order to guarantee after having these situations, system’s micro controller and I2C between the serial EEPROM component can correct, realize the correspondence effectively, may transmit the software which shown in Figure 1 to reposition the sequence first, causes the I2C connection component to reposition reliably, afterward, then log-on data transmission process.

Reference
[1] Maxim/Dallas under Corporation .MAXQ environment EEPROM protective measures [EB/OL]. http://www.maximic.com.cn/appnotes.cfm/appnote_number/3771,20061213.
[2] Li Weiping, Zhang Tao, Ding Zhenjun. Lengthens EEPROM the service life the method [J]. monolithic integrated circuit and the embedded system application, 2005(6).
Wang Shemin (senior engineer), main research direction for intellectualization instruments and meters and embedded system.