Data storage method and device of EEPROM (Electrically Erasable Programmable Read-Only Memory)
By setting up a backup area in the EEPROM and utilizing a cyclic backup storage mechanism and data verification technology, the problem of the limited number of EEPROM erase/write cycles is solved, extending its service life and ensuring data integrity and accuracy, thus meeting the long-term operation requirements of the BMS system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI PAINENG NEW ENERGY TECH CO LTD
- Filing Date
- 2024-11-13
- Publication Date
- 2026-05-19
AI Technical Summary
EEPROM has a limited number of erase/write cycles, making it difficult to meet the long-term operation requirements of BMS systems. Furthermore, traditional storage methods cannot guarantee data integrity and accuracy, easily leading to premature aging and data corruption.
The system employs a cyclic backup storage mechanism and data verification technology. By setting up a backup area in the EEPROM, the target backup area is determined by utilizing the parity of the maximum timestamp and the number of backup areas. This optimizes the erase and write load, reduces the number of erase and write operations per storage unit, and ensures data integrity through data completion identifiers and cyclic redundancy check codes.
It significantly extends the lifespan of EEPROM, meets the reliability requirements of BMS system for long-term operation, and ensures data integrity and accuracy.
Smart Images

Figure CN122064530A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and more specifically, to an EEPROM memory data storage method, apparatus, and electronic device. Background Technology
[0002] With the rapid development of new energy technologies, Battery Management Systems (BMS) play a crucial role in energy storage and power battery applications. BMS ensures that batteries operate safely and efficiently by monitoring and managing them. Its core functions include battery status detection, capacity estimation, charge / discharge management, and fault protection, among which accurate storage of real-time data is essential for the long-term reliable operation of the system.
[0003] In a Battery Management System (BMS), real-time data such as battery percentage, voltage, current, and watt-hour integral values need to be frequently stored to ensure the continuity of critical parameters during power outages or fault recovery. Traditionally, Electrically Erasable Programmable Read-Only Memory (EEPROM), as a non-volatile memory, has been widely used for critical data storage in BMS. However, the physical characteristics of EEPROM limit its write cycles, typically ranging from 1 million to 4 million. Assuming data storage occurs every 2 minutes, some EEPROMs with fewer write cycles reach the end of their lifespan in less than 4 years, making it difficult to meet the 15+ year usage requirements of a BMS system.
[0004] Therefore, how to maintain data storage frequency while reducing the number of erase / write cycles on a single EEPROM storage cell, thereby extending its lifespan, has become a pressing issue in the technical field. Furthermore, the system needs to have mechanisms to ensure data integrity and accuracy, preventing data loss or damage due to unexpected power outages or write failures during storage. Traditional single-block storage methods often cannot cope with frequent erase / write operations and data reliability requirements, easily leading to premature aging and data corruption of the EEPROM. Summary of the Invention
[0005] This disclosure provides at least one EEPROM memory data storage method, apparatus, and electronic device. By utilizing a cyclic backup storage mechanism and data verification technology, the erase and write load of the EEPROM is optimized, significantly extending its service life and meeting the reliability requirements of long-term operation of the BMS system.
[0006] This disclosure provides an EEPROM memory data storage method, including:
[0007] Determine the multiple by which the erase / write lifespan of the EEPROM memory differs from the preset lifespan, and set up a backup area in the EEPROM memory with the number of such multiples.
[0008] Initialize the backup area index number, filter the data headers in the backup area to find the largest timestamp, and determine the target backup area based on the parity of the quotient between the largest timestamp and the number of backup areas corresponding to the backup area.
[0009] Acquire the real-time data to be stored, set the data completion flag corresponding to the data header in the target backup area to an incomplete state, and write the real-time data into the target backup area;
[0010] The data completion flag is set to a completed state, and the backup area index number is increased by a preset step size. The steps of determining the target backup area are repeated according to the preset data storage frequency until the data storage task is completed.
[0011] In one optional implementation, the target backup area is determined based on the parity of the quotient between the maximum timestamp and the number of backup areas corresponding to the backup area, specifically including:
[0012] Determine whether the maximum timestamp is divisible by the number of backup areas;
[0013] When the maximum timestamp is divisible by the number of backup areas and the quotient is odd, if the high-order byte corresponding to the data completion identifier indicates an incomplete state, then the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0014] When the maximum timestamp is divisible by the number of backup areas and the quotient is even, if the low-order byte corresponding to the data completion identifier indicates an incomplete state, the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0015] In one optional implementation, the target backup area is determined based on the maximum timestamp and the number of backup areas corresponding to the backup area, specifically further including:
[0016] When the maximum timestamp and the number of backup areas are not divisible and the quotient is odd, if the low byte corresponding to the data completion identifier indicates an incomplete state, the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0017] When the maximum timestamp is not divisible by the number of backup areas and the quotient is odd, if the high-order byte corresponding to the data completion identifier indicates an incomplete state, the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0018] In one optional implementation, setting the data completion flag to a completion status specifically includes:
[0019] The current storage iteration number is determined based on the timestamp corresponding to the data header in the target backup area;
[0020] When the number of storage passes is odd, the completion status is written to the low byte corresponding to the data completion identifier;
[0021] Once data storage is complete, the high byte corresponding to the data completion identifier is written to the incomplete state.
[0022] In one optional implementation, setting the data completion flag to a completion status further includes:
[0023] When the number of storage passes is even, the high byte corresponding to the data completion identifier is written to the completion status.
[0024] Once data storage is complete, the incomplete state is written to the low byte corresponding to the data completion identifier.
[0025] In one optional implementation, the storage format of the real-time data includes: a real-time data storage header, a backup block data header corresponding to each backup area, and the real-time data stored in each backup area;
[0026] The real-time data storage header is used to identify the storage method of the real-time data;
[0027] The backup block header includes a data completion identifier, a cyclic redundancy check code, and a timestamp.
[0028] This disclosure also provides an EEPROM memory data storage device, including:
[0029] The backup area setting module is used to determine the difference multiple between the erase / write life of the EEPROM memory and the preset life, and to set the number of backup areas in the EEPROM memory equal to the difference multiple.
[0030] The target backup area filtering module is used to initialize the backup area index number, filter the data header with the largest timestamp in the backup area, and determine the target backup area based on the largest timestamp and the number of backup areas corresponding to the backup area.
[0031] The real-time data writing module is used to acquire the real-time data to be stored, set the data completion flag corresponding to the data header in the target backup area to an incomplete state, and write the real-time data into the target backup area;
[0032] The circular storage module is used to set the data completion flag to a completed state, and after increasing the backup area index number by a preset step size, repeat the step of determining the target backup area according to a preset data storage frequency until the data storage task is completed.
[0033] In one optional implementation, the target backup area filtering module is specifically used for:
[0034] Determine whether the maximum timestamp is divisible by the number of backup areas;
[0035] When the maximum timestamp is divisible by the number of backup areas and the quotient is odd, if the high-order byte corresponding to the data completion identifier indicates an incomplete state, then the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0036] When the maximum timestamp is divisible by the number of backup areas and the quotient is even, if the low-order byte corresponding to the data completion identifier indicates an incomplete state, the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0037] This disclosure also provides an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of the above-described EEPROM memory data storage method or any possible implementation of the above-described EEPROM memory data storage method.
[0038] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the above-described EEPROM memory data storage method or any possible implementation of the above-described EEPROM memory data storage method.
[0039] This disclosure also provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the above-described EEPROM memory data storage method, or the steps in any possible implementation of the above-described EEPROM memory data storage method.
[0040] This disclosure provides an EEPROM memory data storage method, apparatus, and electronic device. The method involves determining the multiple between the EEPROM memory's erase / write lifespan and a preset lifespan, setting up a number of backup zones in the EEPROM memory equal to this multiple, initializing backup zone index numbers, filtering the backup zones based on the maximum timestamp in the data headers of the backup zones, and determining a target backup zone based on the parity of the quotient between the maximum timestamp and the number of backup zones corresponding to the backup zone. The method then acquires real-time data to be stored, sets the data completion flag corresponding to the data header in the target backup zone to an incomplete state, and writes the real-time data into the target backup zone. Finally, the method sets the data completion flag to a completed state, increases the backup zone index number by a preset step size, and repeats the steps of determining the target backup zone according to a preset data storage frequency until the data storage task is completed. By utilizing a cyclic backup storage mechanism and data verification technology, the erase / write load of the EEPROM is optimized, significantly extending its lifespan and meeting the reliability requirements of a BMS system for long-term operation.
[0041] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0042] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.
[0043] Figure 1 A flowchart illustrating a data storage method for an EEPROM memory provided in an embodiment of this disclosure is shown;
[0044] Figure 2 A flowchart illustrating another data storage method for an EEPROM memory provided in an embodiment of this disclosure is shown;
[0045] Figure 3 A schematic diagram of a data storage device for an EEPROM memory provided in an embodiment of the present disclosure is shown;
[0046] Figure 4 A schematic diagram of an electronic device provided in an embodiment of the present disclosure is shown. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.
[0048] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0049] In this document, the term "and / or" merely describes a relationship, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Furthermore, the term "at least one" in this document means any combination of at least two of any one or more elements. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0050] Research has revealed that the physical characteristics of EEPROM limit its erase / write cycles, typically ranging from 1 million to 4 million. Assuming data storage occurs every 2 minutes, some EEPROMs with fewer erase / write cycles reach the end of their lifespan in less than 4 years, failing to meet the 15+ year usage requirements of a BMS system. Therefore, how to maintain data storage frequency while reducing the number of erase / write cycles on a single EEPROM cell, thereby extending its lifespan, has become a pressing issue in the technical field. Furthermore, the system needs mechanisms to ensure data integrity and accuracy, preventing data loss or corruption due to unexpected power outages or write failures during storage. Traditional single-block storage methods often cannot cope with frequent erase / write operations and data reliability requirements, easily leading to premature aging and data corruption of the EEPROM.
[0051] Based on the above research, this disclosure provides a data storage method, apparatus, and electronic device for EEPROM memory. The method involves determining the multiple between the erase / write lifespan of the EEPROM memory and a preset lifespan, setting up a number of backup zones in the EEPROM memory equal to the multiple of the difference, initializing the backup zone index number, filtering the backup zones based on the maximum timestamp of the data header, and determining the target backup zone based on the parity of the quotient between the maximum timestamp and the number of backup zones corresponding to the backup zone; acquiring the real-time data to be stored, setting the data completion flag corresponding to the data header in the target backup zone to an incomplete state, and writing the real-time data into the target backup zone; setting the data completion flag to a completed state, increasing the backup zone index number by a preset step size, and repeating the steps of determining the target backup zone according to a preset data storage frequency until the data storage task is completed. By utilizing a cyclic backup storage mechanism and data verification technology, the erase / write load of the EEPROM is optimized, significantly extending its lifespan and meeting the reliability requirements of long-term operation of the BMS system.
[0052] To facilitate understanding of this embodiment, a data storage method for an EEPROM memory disclosed in this disclosure will first be described in detail. The execution entity of the data storage method for an EEPROM memory provided in this disclosure is generally a computer device with certain computing capabilities. This computer device may include, for example, a terminal device, a server, or other processing devices. The terminal device may be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. In some possible implementations, the data storage method for the EEPROM memory can be implemented by a processor calling computer-readable instructions stored in the memory.
[0053] See Figure 1 The diagram shows a flowchart of a data storage method for an EEPROM memory according to an embodiment of this disclosure. The method includes steps S101 to S104, wherein:
[0054] S101. Determine the multiple of the difference between the erase / write life of the EEPROM memory and the preset life, and set up a backup area in the EEPROM memory with a number equal to the multiple of the difference.
[0055] In practical implementation, data storage and erasure in EEPROM memory have a limited lifespan. Each EEPROM has a fixed number of erase / write cycles, meaning it can only maintain normal function until this maximum number of cycles is reached. However, in actual use, sometimes we need to ensure the actual lifespan of the EEPROM reaches a preset value. This involves managing the erase / write cycles of the memory to ensure data reliability.
[0056] Here, we assume that the EEPROM memory has an erase / write lifespan of 4 million cycles, while the objective is to ensure it can be used for 15 years in practical applications. If an EEPROM has a lower erase / write lifespan, such as only 1 million cycles, but still needs to reach the target lifespan, we first determine the ratio between the EEPROM's erase / write lifespan and the target lifespan as the gap factor.
[0057] Based on the aforementioned data gap ratio, a corresponding number of backup areas are set in the EEPROMs with shorter lifespans. Using this example, if the gap ratio is 4, then 4 backup areas are set. The purpose of the backup areas is to store data in rotation, thereby distributing the erase and write operations evenly and extending the actual lifespan of the EEPROM.
[0058] In this embodiment, the storage format of real-time data includes: a real-time data storage header, a backup area data header corresponding to each backup area, and real-time data stored in each backup area; the real-time data storage header is used to identify the storage method of the real-time data; the backup area data header includes a data completion identifier, a cyclic redundancy check code, and a timestamp.
[0059] Here, the real-time data storage header serves as the overall real-time data storage header for the EEPROM memory, distinguishing the data storage method provided in this application embodiment from existing conventional storage methods (i.e., data storage methods that use EEPROM memory with low erase / write lifespan to achieve the lifespan of EEPROM memory with high erase / write lifespan, versus data storage methods that directly use EEPROM memory with high erase / write lifespan). Furthermore, for each backup area, the data format used is a backup area data header and the real-time data stored in the backup area.
[0060] For example, the real-time data storage header can be 0xAA55 (representing storage using the data storage method provided in this application embodiment), occupying 2 bytes of storage space; for each backup area, the backup area data header can be 0x1132FFFFFFFF, occupying 6 bytes of storage space, where the high byte: this byte indicates whether the data storage of this backup area is complete (11 indicates data storage is complete, 22 indicates data storage is not completed due to power failure or other reasons); 32: this byte indicates the Cyclic Redundancy Check (CRC) code used for the overall backup area data; the low 4 bytes represent the timestamp, with an initial value of 1, which increments by 1 every two minutes when the system is running.
[0061] For example, in the real-time data stored in the backup area, the power percentage occupies 2 bytes of storage space, the power integral value_low byte occupies 2 bytes of storage space, the power integral value_high byte occupies 2 bytes of storage space, the power watt-hour percentage uWH occupies 2 bytes of storage space, the power watt-hour integral value_low byte uWH occupies 2 bytes of storage space, and the power watt-hour integral value_high byte uWH occupies 2 bytes of storage space.
[0062] S102. Initialize the backup area index number, filter the data headers in the backup area to find the largest timestamp, and determine the target backup area based on the parity of the quotient between the largest timestamp and the number of backup areas corresponding to the backup area.
[0063] In practice, backup zones are used to manage data storage and write / erase operations, ensuring data reliability and durability. Each backup zone records a timestamp to identify the order in which data was written. The backup zone index number is used to track the location of the currently used backup zone. During initialization, the index number is typically set to an initial value (e.g., 1), representing starting from the first backup zone. The index number identifies the backup zone currently in use or about to be used.
[0064] Here, each backup area's data header will have a timestamp, recording the time or order in which data was written. By traversing all backup areas, the backup area with the largest timestamp represents the one that most recently had data written.
[0065] See Figure 2 The diagram shows a flowchart of another data storage method for an EEPROM memory provided in this embodiment of the present disclosure. The method includes steps S1021 to S1023, wherein:
[0066] S1021. Determine whether the maximum timestamp is divisible by the number of backup areas.
[0067] S1022. When the maximum timestamp and the number of backup areas are divisible and the quotient is odd, if the high-order byte corresponding to the data completion identifier indicates an incomplete state, then the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0068] S1023. When the maximum timestamp and the number of backup areas are divisible and the quotient is even, if the low-order byte corresponding to the data completion identifier indicates an incomplete state, then the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0069] In practice, the selection of the target backup area is determined by calculating the divisibility between the maximum timestamp and the number of backup areas. If the maximum timestamp is divisible by the number of backup areas, it indicates that the current backup area has been used for a complete cycle, which helps determine the next backup area for data storage. The result of the division operation is a quotient value, and the parity of the quotient value will be used to determine this in subsequent steps.
[0070] Here, if the quotient after division is odd, it is also necessary to check the status of the high-order byte in the data completion flag. If the flag of the high-order byte is "incomplete" (e.g., 22), it means that the storage operation of the current backup area has not yet been completed. In this case, the backup area index number will be increased by a preset step size to prevent data from being written to an incomplete backup area, thereby ensuring the integrity and continuity of the data.
[0071] It should be noted that the preset step size is preferably 1.
[0072] Here, when the maximum timestamp is divisible by the number of backup areas and the quotient is even, the status of the low-order byte in the data completion flag is checked. If the low-order byte flag is "incomplete" (e.g., 22), it means that the data in this backup area has not been fully written or has not been marked as complete. Similar to the odd-numbered cases, the backup area index number is incremented by a preset step to ensure that no new write operations are performed on incomplete data blocks, and a new backup area is selected for storage.
[0073] In this way, by dividing the maximum timestamp by the number of backup areas, the system can determine the periodicity of data storage and the location of the backup area that needs to be switched. The parity of the quotient is used to distinguish different data storage conditions, preventing frequent duplicate writes within the same backup area and protecting the stability of data storage. The status of the high-order and low-order bytes is used to distinguish the data write progress of the current backup area, ensuring that incomplete storage blocks are not written repeatedly and guaranteeing data consistency.
[0074] Furthermore, as a possible implementation method, determining the target backup area also includes the following steps 1-2:
[0075] Step 1: When the maximum timestamp and the number of backup areas are not divisible and the quotient is odd, if the low byte corresponding to the data completion identifier indicates an incomplete state, then the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0076] Step 2: When the maximum timestamp and the number of backup areas are not divisible and the quotient is odd, if the high-order byte corresponding to the data completion identifier indicates an incomplete state, then the backup area index number is increased by a preset step size to determine the corresponding target backup area.
[0077] S103. Obtain the real-time data to be stored, set the data completion flag corresponding to the data header in the target backup area to an incomplete state, and write the real-time data into the target backup area.
[0078] In practice, once the target backup area is determined, the cyclic redundancy check code of the data header in the target backup area is read to check if it is correct. If the cyclic redundancy check code is correct, the real-time data and the backup area index number are updated in real time, and the data storage cycle starts at a preset data storage frequency (e.g., 2 minutes).
[0079] Here, when writing data to the EEPROM memory, the data completion flag in the data header of the corresponding target backup area is first written to an incomplete state (e.g., written as 22), and then the data writing operation is performed to store the real-time data in the target backup area.
[0080] Before actually writing data, the data completion flag is set to an incomplete state to prevent other modules from mistakenly reading the data in the backup area as valid data before it is fully written. This ensures that the data in the backup area is not mistakenly considered complete and valid during the writing process. This is to guarantee data integrity and prevent errors in the storage process.
[0081] S104. Set the data completion flag to the completion status, and after increasing the backup area index number by a preset step size, repeat the step of determining the target backup area according to the preset data storage frequency until the data storage task is completed.
[0082] In practice, once data storage is complete, the data completion flag in the data header of the backup area is written to the completion status. During this process, the current storage iteration count is determined based on the timestamp corresponding to the data header in the target backup area. When the storage iteration count is odd, the completion status is written to the low byte corresponding to the data completion flag. Once data storage is complete, the incomplete status is written to the high byte corresponding to the data completion flag.
[0083] Furthermore, when the number of storage passes is even, the high byte corresponding to the data completion flag is written to the completion status; when the data storage is completed, the low byte corresponding to the data completion flag is written to the incomplete status.
[0084] As one possible implementation method, the data storage method of the EEPROM memory provided in this application embodiment is mainly applied to achieving a lifespan higher than the erase and write lifespan of the EEPROM memory using an EEPROM memory with a low erase and write lifespan (hereinafter collectively referred to as the new storage method), and can be compatible with the method of directly using an EEPROM memory with a high erase and write lifespan for storage (hereinafter collectively referred to as the original storage method).
[0085] Specifically, after power-on initialization, check if the statistical data identifier (DRV_EEPROM_STATSTIC_FLAG_ADDR) of the external EEPROM memory is 0x55aa. If not, it means that the EEPROM memory has been erased or has never been loaded. In this case, 0x55aa needs to be written into the statistical data identifier of the external EEPROM memory, and the data is triggered to be stored in the original statistical data location according to the storage logic of the new storage method. The real-time data of the statistical data is stored in the corresponding new location using the data structure corresponding to the new storage method. At this time, the initialization of the EEPROM memory is completed.
[0086] Furthermore, if the statistical data identifier of the EEPROM memory is 0x55aa, then the real-time data storage header of the EEPROM memory is read to determine the data storage method indicated by the data storage header (e.g., whether the identifier is 0xAA55).
[0087] Here, if the statistical data identifier of the EEPROM memory is 0x55aa, it means that the EEPROM memory stores data in the data storage format corresponding to the new storage method. In this case, all statistical data (except real-time data) needs to be restored to the original structure, and the real-time data needs to be restored from the new location to the new structure. At this point, the initialization of the EEPROM memory is complete. If the statistical data identifier of the EEPROM memory is not 0x55aa, it means that the EEPROM memory stores data in the data storage format corresponding to the original storage method. In this case, all statistical data (except real-time data) needs to be restored to the original structure, and the real-time data needs to be retrieved from the original statistical data location and assigned to the new structure. At this point, the initialization of the EEPROM memory is complete.
[0088] This disclosure provides a data storage method for an EEPROM memory. The method involves determining the multiple between the EEPROM memory's erase / write lifespan and a preset lifespan, setting up a number of backup zones in the EEPROM memory equal to this multiple, initializing backup zone index numbers, filtering the backup zones based on the maximum timestamp in the data headers, and determining a target backup zone based on the parity of the quotient between the maximum timestamp and the number of backup zones corresponding to that backup zone. The method then acquires real-time data to be stored, sets the data completion flag corresponding to the data header in the target backup zone to an incomplete state, and writes the real-time data into the target backup zone. Finally, the method sets the data completion flag to a completed state, increases the backup zone index number by a preset step size, and repeats the steps of determining the target backup zone according to a preset data storage frequency until the data storage task is completed. By utilizing a cyclic backup storage mechanism and data verification technology, the erase / write load of the EEPROM is optimized, significantly extending its lifespan and meeting the reliability requirements of a BMS system for long-term operation.
[0089] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0090] Based on the same inventive concept, this disclosure also provides a data storage device for an EEPROM memory corresponding to the data storage method of the EEPROM memory. Since the principle of the device in this disclosure for solving the problem is similar to the data storage method of the EEPROM memory described above in this disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0091] Please see Figure 3 , Figure 3 This is a schematic diagram of a data storage device for an EEPROM memory provided in an embodiment of this disclosure. Figure 3 As shown in the figure, the data storage device 300 of the EEPROM memory provided in this embodiment includes:
[0092] The backup area setting module 310 is used to determine the difference multiple between the erase / write life of the EEPROM memory and the preset life, and to set a number of backup areas in the EEPROM memory equal to the difference multiple.
[0093] The target backup area filtering module 320 is used to initialize the backup area index number, filter the data headers in the backup area with the largest timestamp, and determine the target backup area based on the largest timestamp and the number of backup areas corresponding to the backup area.
[0094] The real-time data writing module 330 is used to acquire the real-time data to be stored, set the data completion flag corresponding to the data header in the target backup area to an incomplete state, and write the real-time data into the target backup area.
[0095] The circular storage module 340 is used to set the data completion identifier to a completed state, and after increasing the backup area index number by a preset step size, repeat the step of determining the target backup area according to a preset data storage frequency until the data storage task is completed.
[0096] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0097] This disclosure provides a data storage device for an EEPROM memory. The device determines the multiple between the erase / write lifespan of the EEPROM memory and a preset lifespan, and sets up a number of backup zones in the EEPROM memory equal to the multiple of this multiple. It initializes the backup zone index number, filters the backup zones based on the maximum timestamp in the data header, and determines a target backup zone based on the parity of the quotient between the maximum timestamp and the number of backup zones corresponding to that backup zone. It acquires real-time data to be stored, sets the data completion flag corresponding to the data header in the target backup zone to an incomplete state, and writes the real-time data into the target backup zone. It then sets the data completion flag to a completed state, increases the backup zone index number by a preset step size, and repeats the steps of determining the target backup zone according to a preset data storage frequency until the data storage task is completed. By utilizing a cyclic backup storage mechanism and data verification technology, the erase / write load of the EEPROM is optimized, significantly extending its lifespan and meeting the reliability requirements of a BMS system for long-term operation.
[0098] Corresponding to Figure 1 and Figure 2 This disclosure also provides an electronic device 400, such as a data storage method for an EEPROM memory. Figure 4 The diagram shown is a structural schematic of an electronic device 400 provided in an embodiment of this disclosure, including:
[0099] Processor 41, memory 42, and bus 43; memory 42 is used to store execution instructions, including main memory 421 and external memory 422; the main memory 421, also called internal memory, is used to temporarily store the computational data in processor 41, as well as the data exchanged with external memory 422 such as hard disk. Processor 41 exchanges data with external memory 422 through main memory 421. When the electronic device 400 is running, processor 41 and memory 42 communicate through bus 43, enabling processor 41 to execute... Figure 1 and Figure 2 The steps of the data storage method of the EEPROM memory.
[0100] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the data storage method of the EEPROM memory described in the above method embodiments. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0101] This disclosure also provides a computer program product, which includes computer instructions. When the computer instructions are executed by a processor, they can perform the steps of the data storage method of the EEPROM memory described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0102] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0103] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0104] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0105] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0106] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0107] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.
Claims
1. A data storage method for an EEPROM memory, characterized in that, include: Determine the multiple by which the erase / write lifespan of the EEPROM memory differs from the preset lifespan, and set up a backup area in the EEPROM memory with the number of such multiples. Initialize the backup area index number, filter the data headers in the backup area to find the largest timestamp, and determine the target backup area based on the parity of the quotient between the largest timestamp and the number of backup areas corresponding to the backup area. Acquire the real-time data to be stored, set the data completion flag corresponding to the data header in the target backup area to an incomplete state, and write the real-time data into the target backup area; The data completion flag is set to a completed state, and the backup area index number is increased by a preset step size. The steps of determining the target backup area are repeated according to the preset data storage frequency until the data storage task is completed.
2. The method according to claim 1, characterized in that, The target backup area is determined based on the parity of the quotient between the maximum timestamp and the number of backup areas corresponding to the backup area, specifically including: Determine whether the maximum timestamp is divisible by the number of backup areas; When the maximum timestamp is divisible by the number of backup areas and the quotient is odd, if the high-order byte corresponding to the data completion identifier indicates an incomplete state, then the backup area index number is increased by a preset step size to determine the corresponding target backup area. When the maximum timestamp is divisible by the number of backup areas and the quotient is even, if the low-order byte corresponding to the data completion identifier indicates an incomplete state, the backup area index number is increased by a preset step size to determine the corresponding target backup area.
3. The method according to claim 2, characterized in that, The target backup area is determined based on the maximum timestamp and the number of backup areas corresponding to the backup area. Specifically, this also includes: When the maximum timestamp and the number of backup areas are not divisible and the quotient is odd, if the low byte corresponding to the data completion identifier indicates an incomplete state, the backup area index number is increased by a preset step size to determine the corresponding target backup area. When the maximum timestamp is not divisible by the number of backup areas and the quotient is odd, if the high-order byte corresponding to the data completion identifier indicates an incomplete state, the backup area index number is increased by a preset step size to determine the corresponding target backup area.
4. The method according to claim 1, characterized in that, Setting the data completion flag to a completed state specifically includes: The current storage iteration number is determined based on the timestamp corresponding to the data header in the target backup area; When the number of storage passes is odd, the completion status is written to the low byte corresponding to the data completion identifier; Once data storage is complete, the high byte corresponding to the data completion identifier is written to the incomplete state.
5. The method according to claim 4, characterized in that, Setting the data completion flag to a completed state specifically includes: When the number of storage passes is even, the high byte corresponding to the data completion identifier is written to the completion status. Once data storage is complete, the incomplete state is written to the low byte corresponding to the data completion identifier.
6. The method according to claim 1, characterized in that: The storage format of the real-time data includes: a real-time data storage header, a backup block data header corresponding to each backup area, and the real-time data stored in each backup area; The real-time data storage header is used to identify the storage method of the real-time data; The backup block header includes a data completion identifier, a cyclic redundancy check code, and a timestamp.
7. An EEPROM memory data storage device, characterized in that, include: The backup area setting module is used to determine the difference multiple between the erase / write life of the EEPROM memory and the preset life, and to set the number of backup areas in the EEPROM memory equal to the difference multiple. The target backup area filtering module is used to initialize the backup area index number, filter the data header with the largest timestamp in the backup area, and determine the target backup area based on the parity of the quotient between the largest timestamp and the number of backup areas corresponding to the backup area. The real-time data writing module is used to acquire the real-time data to be stored, set the data completion flag corresponding to the data header in the target backup area to an incomplete state, and write the real-time data into the target backup area; The circular storage module is used to set the data completion flag to a completed state, and after increasing the backup area index number by a preset step size, repeat the step of determining the target backup area according to a preset data storage frequency until the data storage task is completed.
8. The apparatus according to claim 7, characterized in that, The target backup area filtering module is specifically used for: Determine whether the maximum timestamp is divisible by the number of backup areas; When the maximum timestamp is divisible by the number of backup areas and the quotient is odd, if the high-order byte corresponding to the data completion identifier indicates an incomplete state, then the backup area index number is increased by a preset step size to determine the corresponding target backup area. When the maximum timestamp is divisible by the number of backup areas and the quotient is even, if the low-order byte corresponding to the data completion identifier indicates an incomplete state, the backup area index number is increased by a preset step size to determine the corresponding target backup area.
9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of the EEPROM memory data storage method as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the EEPROM memory data storage method as described in any one of claims 1 to 6.