EEPROM (Electrically Erasable Programmable Read Only Memory) is the electronic cleaning type non-erasable storage, it is one kind of non-volatile memory, is similar with cleaning type non-erasable storage (EPROM), after power source vanishing, the storage data still exists, must eliminate stores up in content, is not with the ultraviolet radiation way, but directly eliminates by the electronic signal then.
Is precisely because EEPROM has the above characteristic, this component may widely apply in requests the high application situation to the data storage security and the reliability, like the entrance guard checking attendance system, the survey and the medical measuring appliance, the non-contact smart card, the tax controls the cash register, pre-application situations and so on payment electric meter or duplicate tariff electric meter, water meter, gas meter as well as electrical appliances remote control. This type memory will obtain more and more widespread application in the authentic data memory domain.
But, EEPROM has the fixed service life, this is refers to one by 1 to write is O or writes by O is 1 number of times. The different factory’s product, the same factory different model, the series product, their life is also different, 1,000,000 times for common mainstream product. If some EEPROM life is 1,000,000 times, each second scratches writes one time, then its period of revolution for 1000000/(3600×24)=12 day. This regarding needs the long time preservation data the application situation, obviously does not satisfy the request.
1 lengthens the EEPROM life the method
Generally in the application, must save the data is quite unitary, the EEPROM space with the data which must save compares must be much bigger. Therefore, may use one kind to lengthen the EEPROM working life using the memory space the method.
Method l: Fixed data depositing address, but uses a fixed base address to add on EEPROM one unit content (i.e. offset address) to take the genuine address; If the discovery memory cell bad (has read in differently with read-out content), then the offset address adds 1, reads. If uses 100 time of memory space redundancy, may lengthen the EEPROM actual life 100 times.
Method 2: Starts the stored datum from the first memory cell N time, then changes to the next unit to save again N time, analogizes in turn, when after the last unit deposits N time, changes to the first unit to make a fresh start again. This article recommends uses this law, because on one method has a fatal defect: When some EEPROM unit writes badly again uses the next unit, originally saves the data could not go study. This article following content also depends on this to make the basis to carry on the explanation.
2 EEPROM information storage address confirmation
After embedded system’s EEPROM power source vanishing, the storage data still exists. Confirmed that the data will save the address is can correct save the data read-out the basic condition, but after power failure, on again when electricity how to confirm the data the address pointer? May use the following method.
2.1 look for the biggest data law
Searches in EEPROM the biggest data, before is the power failure, last secondary storage data. This law says regarding the monolithic integrated circuit, when programming the procedure quantity is big, may use the binary search law or the block search law reduces the procedure code quantity.
2.2 after the reducing process
After circulation reads in the current data EEPROM, immediately on the front EEPROM space clear 0 again electricity, will search the data non-0 EEPROM space then. Some monolithic integrated circuit request before write data, must possess the space to restore is OxFF, like this searches non-0xFF the data space then.
2.3 address pointer law
Supposes address pointer EE-ADR[i] for each data in EEPROM, so long as like this confirmed that the EEADR[i] value then found the corresponding data. Has the following some skills regarding the address pointer law.
①An address pointer corresponds a data. This method mentality is simple, the supposition EEPROM space may store 50 groups of data and 50 address ADR[i], a group of data take 4 bytes, an address takes 1 byte, altogether 250 bytes, when stored data, causes 50 addresses to aim at 50 groups of data the first addresses, and causes is smaller than variable i ADR[i] resets, or the evaluation is 0xFF again. When searches the data, found non-O or non-0xFF ADR[i], then came the specified data according to the ADR[i] value the storage address then.
②With two variable data recording storage’s address, ADDR 10 LD and ADDILNEW symbolized separately time the current data read-out’s address and gathers newly the data next time must save address.
③Takes the address pointer with a byte’s EEPROM space. , Address pointer’s value is always this time equal with information storage’s address value, this kind of situation most has the technicality, because this time may use the least address pointer, thus may most massive saving. EEPROM space, thus lengthens the EEP-ROM life. This method’s mentality is: Supposition Oth byte achievement address pointer, when this indicator value is 1, the data starts from the first address to store up; When for 2, the data starts from the second address to store up, ex analogia.
3 application examples
Myself when design intelligence flow instrument, uses American Microchip Corporation’s PIC16F877 monolithic integrated circuit. This monolithic integrated circuit itself brings has 256 byte EEPROM, it scratches writes the number of times typical value is 1,000,000 times, mainly stores up the accumulation current capacity and the scaling factor with it. And, the 201~255th byte uses in saving the scaling factor, because it does not need to operate frequently, therefore no longer uses to these data changes the address dynamic storage. The 0th byte stored data’s address pointer, the 1~200th byte uses for to store up the accumulation quantity.
Regarding the accumulation quantity, may use the floating number storage, only takes 3~4 bytes, the goal lies in with the fixed byte length may guarantee the same relative accuracy.
The intelligence flow instrument year to year does not stop works, in the short time’s current capacity relatively total current capacity says, may ignore. Therefore, to cause monolithic integrated circuit’s EEPROM life to be longer, a time fragment (e.g. 10s) has stored up an accumulation quantity also to be possible to satisfy the accuracy requirement. If presents the power cut accident, the accumulation quantity only then the 10s current capacity error, the relative total quantity may satisfy the accuracy requirement. This strategy may make EEPROM to lengthen 10 time of lives.
Because this example uses O byte data recording the memory address, if the data saves every time one time trades an address, then 200 bytes may save a 200/4=50 position, is equal scratches in the stored data EEPROM space writes one time, the Oth byte scratches writes 50 times, therefore, the Oth byte life is other 1/50, this is not obviously feasible. Therefore may select the following method: Will store up 50 time later in the first address to change an address storage again, will also store up to the last address when again 50 times will change to the first address storage, such all EEPROM space use number of times is equal.
Storage accumulation quantity flow chart as shown in Figure 1.

pass: Before data storage, program loop’s number of times, it attributes the long time to store up a data.
save_adr: Data in EEPROM memory address.
save_time: Some data the number of times which saves in the identical address.
eeprom_write(eeadr, value):EEPROM writes the function.
Below is this flow correspondence procedure (uses Australian HI-TECH Corporation’s PICC the demo compiler).

if(save_time>50)//saves 50 moves to a EEPROM address from now on
{save_time=0; clrwdt();
save_adr =4; // accumulation quantity stores up with 4 bytes
if(save_adr>197)//only uses 1~200 bytes to save the accumulation quantity {save_adr=1;}
eeprom_write(0, save-adr); //save-adr is saves the accumulation to measure land the site first byte
}
eeprom_write(savcl_adr, x[O]);
eeprom_write(save_adr 1, x[1]);
eeprom_write(save_adr 2, x[2]);
eeprom_write(save_adr 3, x[3]);
}
}
4 read out the data which in EEPROM saves
After system’s EEPROM power failure, on again when electricity is quite simple from the EEPROM readout’s procedure.
before void Read_Sum_Q() {// read-out power failure accumulation quantity
y[O]=eeprom_read(save_adr);
y[1]=eeprom_read(1 save_adr);
y[2]_eeprom_read(2 save_adr);
y[3]=eeprom_read(3 save_adr);
p2= (float *) y;
Q=*p2;
}
Conclusion
Uses the method which the example shows, 10s saves one time may make the EEPROM life to lengthen 10 times, uses 50 time of EEPROM space redundancy, also causes it to follow orders to lengthen 50 times, like this has 1000000 time life EEPROM to be possible the non-stop run time for 10×50×1000000/(3600×24×365) the =15.85 year, basic may satisfy each kind of embedded system’s work requirement, raised the EEPROM use efficiency greatly. Therefore, this article introduced the method has in the related domain widespread profits from the significance and the use value.