Storage protection method of EEPROM
By managing the storage address and data write times of EEPROM, the problem of limited number of EEPROM write times is solved, and the efficient utilization of EEPROM storage space is achieved, and the need for frequent data storage in new energy vehicles and industrial equipment is met.
Patent Information
- Application Number
- CN202510155435.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-12
- Publication Date
- 2025-07-11
AI Technical Summary
The limited number of times of rewritten EEPROMs leads to permanent failure of storage addresses after reaching the upper limit, and the data cannot be saved again, affecting the need for frequent data storage in new energy vehicles and industrial equipment.
By allocating continuous storage addresses, using data identifiers and write times to manage EEPROM storage, efficient use of data, including the management of data identifiers, data content and write times, and timely replacement or addition of storage addresses to avoid reaching the write limit.
It realizes efficient utilization of EEPROM storage space, meets frequent data storage needs, extends the service life of storage addresses, and avoids permanent failure of storage addresses.
Smart Images

Figure CN120296808A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of new energy vehicles, and particularly to a storage protection method for an EEPROM. Background Art
[0002] During the operation of new energy electric vehicles, a lot of key data needs to be saved, such as battery power, fault logs, and related calibration data; and according to the requirements of vehicle manufacturers, some data needs to be saved frequently, so the EEPROM needs to be erased and written frequently. However, the number of erasure and write cycles of the EEPROM has an upper limit. Once the upper limit is exceeded, this storage address may become permanently invalid and data cannot be saved again; therefore, compared with other storage addresses, the storage life of this storage address is relatively shorter, so a method is needed to solve this problem. Summary of the Invention
[0003] In order to solve the above problems, the present invention provides a storage protection method for an EEPROM, including the following steps: S1. Allocate continuous storage addresses to all data to be stored, and save the number of stored data at the very front of the storage address as the address offset; S2. Judge whether the newly stored data information is to change the existing data or add new stored data; wherein, the storage address in the S1 step specifically includes: data identifier, data content, and data write count.
[0004] Further, when the newly stored data information in the S2 step is to change the existing data, it specifically includes the following sub-steps: S21. Read the data write count of the changed data according to the data identifier, and judge whether the data write count of this data is less than the maximum write count of the EEPROM; S22. Write the changed data content into the corresponding storage address, and then add 1 to the data write count and write it into the corresponding storage address to complete the storage.
[0005] Further, the S21 step specifically includes the following sub-steps: when the data write count of this data is less than the maximum write count of the EEPROM, execute step S22; when the data write count of this data is equal to the maximum write count of the EEPROM, invalidate the original storage address, save the modified data identifier, data content, and data write count to the position one plus the original storage address, and re-mark it as the original storage address, and store it after adding 1 to the address offset.
[0006] Further, when the data write count of this data is equal to the maximum write count of the EEPROM, the data write count of the re-marked original storage address is 1.
[0007] Further, when the newly stored data information is new stored data in the step S2, specifically: save the new data block to the position where the original storage address is incremented by 1, and re-mark it as the original storage address, and store it after the address offset is incremented by 1.
[0008] The present invention provides a storage protection method for an EEPROM, having the following beneficial effects: The present invention does not limit the storage frequency of data to meet the occasions where data needs to be stored frequently, such as an electric vehicle needs to frequently save battery power or fault information, and industrial equipment needs to frequently save relevant parameters, etc.; by maximizing the use of the storage space of the EEPROM through data identifiers and the number of times the saved data is written, the use of the storage space will be more efficient and more reasonable. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on the structures shown in these drawings without creative efforts.
[0010] Figure 1 is a flowchart of the method provided by the present invention; Figure 2 is a schematic diagram of the data storage method provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0011] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0012] The following will describe in detail the implementation method of the present invention with reference to the drawings. The described are only some embodiments, not all embodiments. For the purpose of clarity, the representations and descriptions unrelated to the present invention are omitted in the drawings and the description.
[0013] In order to have a clearer understanding of the technical features, objectives, and beneficial effects of the present invention, the technical solutions of the present invention are now described in detail below. Obviously, the described embodiments are some embodiments of the present invention, not all embodiments, and should not be construed as limiting the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present invention.
[0014] Such as Figure 1As shown in the figure, the present invention provides a storage protection method for an EEPROM, including the following steps: S1. Allocate consecutive storage addresses to all data to be stored, and save the number of stored data at the very front of the storage address as the address offset; S2. Determine whether the newly stored data information is to change the existing data or add new stored data; wherein, the storage address in step S1 specifically includes: data identifier, data content, and data write count.
[0015] In step S2, when the newly stored data information is to change the existing data, it specifically includes the following sub-steps: S21. Read the data write count of the changed data according to the data identifier, and determine whether the data write count of this data is less than the maximum write count of the EEPROM: when the data write count of this data is less than the maximum write count of the EEPROM, execute step S22; when the data write count of this data is equal to the maximum write count of the EEPROM, invalidate the original storage address, save the modified data identifier, data content, and data write count at the position one plus the original storage address, and re-mark it as the original storage address. At this time, the data write count is 1, and the address offset is stored after adding 1.
[0016] S22. Write the changed data content to the corresponding storage address, and then write the data write count plus 1 to the corresponding storage address to complete the storage.
[0017] In step S2, when the newly stored data information is to add new stored data, specifically: save the new data block at the position one plus the original storage address, and re-mark it as the original storage address. At this time, the data write count is 1, and the address offset is stored after adding 1.
[0018] Embodiment: The maximum write count of the EEPROM is Ne, and the stored data block consists of three parts: data identifier (Fn), data content (Dn), and data write count (Wn). Initially, consecutive storage addresses are allocated for all data; as Figure 2 shown. At the same time, the number of stored data (Ns) will be saved at the very front and used as the address offset. When new data (Dn+1) needs to be saved, Ns will also be incremented by 1.
[0019] When the existing data (Dn) changes and needs to be saved, the following steps are executed: Step S21: According to the data identifier (Fn), read the write count (Wn) of this data. If Wn is less than the maximum write count (Ne) of the EEPROM, then enter step S21-1; otherwise, enter step S21-2; Step S21-1: Write Dn to the corresponding storage address, and then write Wn plus 1 to the corresponding storage address to complete the storage of this data. Step S21-2: The write count of Dn reaches the maximum write count of the EEPROM, and a new storage address needs to be replaced; at this time, the original storage addresses of Fn, Dn, and Wn are invalidated, and the Fn, Dn, and Wn of this data block are saved as new data to the storage addresses of Fn+1, Dn+1, and Wn+1, and re-labeled as Fn, Dn, and Wn. At this time, Wn should be 1, and Nn is incremented and stored; this data storage is completed. When there is new data (Dn+1) to be saved, the following steps are executed: The new data block is saved to the storage addresses of Fn+1, Dn+1, and Wn+1, and re-labeled as Fn, Dn, and Wn. At this time, Wn should be 1, and Ns is incremented and stored; this data storage is completed.
[0020] The present invention does not limit the storage frequency of data to meet the occasions where data needs to be stored frequently, such as an electric vehicle needs to frequently save battery power or fault information, and industrial equipment needs to frequently save relevant parameters, etc.; by maximizing the use of the EEPROM storage space through data identifiers and the write count of the saved data, the use of the storage space will be more efficient and reasonable.
[0021] The above are only the preferred embodiments of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, should not be regarded as an exclusion of other embodiments, but can be used in various other combinations, modifications, and environments, and can be changed within the scope of the concept described herein through the above teachings or the technology or knowledge in related fields. And the changes and alterations made by those skilled in the art that do not depart from the spirit and scope of the present invention should all be within the protection scope of the appended claims of the present invention.
Claims
1. A storage protection method for an EEPROM, characterized in that, It includes the following steps: S1. Allocate consecutive storage addresses to all data to be stored, and save the number of stored data at the very front of the storage address as the address offset; S2. Determine whether the newly stored data information is to change the existing data or add new stored data; Among them, the storage address in step S1 specifically includes: data identifier, data content, and data write count.
2. The storage protection method of the EEPROM according to claim 1, wherein, In step S2, when the newly stored data information is to change the existing data, it specifically includes the following sub-steps: S21. Read the data write count of the data that has changed according to the data identifier, and determine whether the data write count of this data is less than the maximum write count of the EEPROM; S22. Write the changed data content to the corresponding storage address, then add 1 to the data write count and write it to the corresponding storage address to complete the storage.
3. The storage protection method of the EEPROM according to claim 2, characterized in that, The specific steps in step S21 include the following sub-steps: When the data write count of this data is less than the maximum write count of the EEPROM, execute step S22; When the data write count of this data is equal to the maximum write count of the EEPROM, invalidate the original storage address, save the modified data identifier, data content, and data write count to the position one plus the original storage address, and re-mark it as the original storage address, and store it after adding 1 to the address offset.
4. The storage protection method of the EEPROM according to claim 3, characterized in that, When the data write count of this data is equal to the maximum write count of the EEPROM, the data write count of the re-marked original storage address is 1.
5. The storage protection method of the EEPROM according to claim 1, characterized in that, In step S2, when the newly stored data information is to add new stored data, specifically: save the new data block to the position one plus the original storage address, and re-mark it as the original storage address, and store it after adding 1 to the address offset.