CN112527207B - Data storage method and device in EEPROM - Google Patents
- ️Fri Dec 13 2024
Disclosure of Invention
Accordingly, the present application is directed to a method, system, device and computer readable storage medium for data storage in EEPROM, which can improve the service life of EEPROM. The specific scheme is as follows:
a method of data storage in an EEPROM comprising:
Receiving current real-time data corresponding to a target data type;
determining a storage position of last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block;
And storing the current real-time data to a next logic block adjacent to the target logic block in the EEPROM.
Optionally, the method further comprises:
Storing the current real-time data into corresponding standby logic blocks in the standby partition by utilizing the storage position of the next logic block of the target logic block and the corresponding relation with the storage position in the standby partition;
And carrying out block division on the storage space in the EEPROM in advance to obtain a main partition and a standby partition.
Optionally, the process of storing the current real-time data into the corresponding spare logical block in the spare partition by using the storage location of the next logical block of the target logical block and the corresponding relation with the storage location in the spare partition includes:
storing the current real-time data into corresponding standby logic blocks in a standby partition by using the storage position and the block length of the next logic block of the target logic block;
the block length is the number of storage blocks included in each partition, and the spare partition is the same as the block length of the main partition.
Optionally, after the storing the current real-time data in the corresponding spare logical block in the spare partition by using the storage location of the next logical block of the target logical block and the corresponding relation with the storage location in the spare partition, the method further includes:
Receiving a data reading instruction for reading target storage data corresponding to each other in the main partition and each standby partition in the EEPROM;
Checking the target storage data stored in each partition according to the data reading instruction;
if the target storage data stored in all the partitions are successfully checked, the target storage data is read;
And if the target storage data stored in any partition fails to be checked, the storage data stored in the most partitions are read.
Optionally, the process of determining the last storage location of the history data stored in the EEPROM corresponding to the target data type to obtain the target history storage location includes:
The storage position of the historical data is determined in advance by utilizing the storage count of the current logic block and the adjacent logic block pointed for the first time when the EEPROM is initialized so as to obtain a target historical storage position;
And after each time of data storage in the EEPROM, the storage count is increased by one, and the storage count and the stored data are stored in the same logic block.
Optionally, the method further comprises:
s421, obtaining a first saving count saved in a current logic block;
s422, determining a second storage position of a second logic block adjacent to the current logic block by using the number of storage blocks occupied by the current logic block;
S423, judging whether valid data are stored in the second logic block or not by utilizing the second storage position;
s424, if the valid data is stored, judging whether a second save count in a second logic block is larger than the first save count;
S425, if the second save count is greater than the first save count, re-executing steps S421 to S424 by taking the second logic block as a new current logic block until no valid data is stored in the second logic block or the second save count is less than the first data save count, and recognizing the current logic block as the first logic block of the last saved data before the EEPROM is powered on;
The first current logic block is the logic block pointed for the first time when the EEPROM is initialized, and the number of the current logic block is the same as that of the storage blocks included in the second logic block.
Optionally, the process of saving the current real-time data to a next logic block in the EEPROM adjacent to the target logic block includes:
And saving the current real-time data to a next logic block adjacent to the target logic block by utilizing the target historical storage position and the number of storage blocks included in the target logic block.
Optionally, the process of saving the current real-time data to a next logic block adjacent to the target logic block by using the target history storage location and the number of storage blocks included in the target logic block includes:
obtaining a first storage position of a next logic block adjacent to the target logic block by using the target history storage position and the number of storage blocks included in the target logic block;
And saving the current real-time data to a next logic block adjacent to the target logic block by utilizing the first storage position.
Optionally, after receiving the current real-time data corresponding to the target data type, the method further includes:
Acquiring the current running temperature of the EEPROM;
judging whether the current running temperature of the EEPROM exceeds a preset temperature threshold value;
If yes, judging whether the time interval between the current time and the historical preservation time for preserving the historical data is smaller than a preset time threshold value;
and if the current real-time data is smaller than the current real-time data, storing the current real-time data into a memory buffer area.
The application also discloses a data storage device in the EEPROM, which comprises:
A memory for storing a computer program;
And a processor for executing the computer program to implement the data storage method in the EEPROM as described above.
The application discloses a data storage method in an EEPROM (electrically erasable programmable read-Only memory), which comprises the steps of receiving current real-time data corresponding to a target data type, determining a storage position of last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, determining a logic block corresponding to the target historical storage position as a target logic block, and storing the current real-time data into a next logic block adjacent to the target logic block in the EEPROM.
The application circularly saves the new data into the whole EEPROM, and does not repeatedly save the data into the same logic block, thereby delaying the occurrence of bad blocks in the EEPROM and integrally prolonging the service life of the EEPROM.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The embodiment of the application discloses a data storage method in EEPROM, which is shown in figure 1 and comprises the following steps:
s11, receiving current real-time data corresponding to a target data type;
And S12, determining the storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block.
Specifically, in order to prolong the service life of the EEPROM when the same data type is stored, after receiving the current real-time data of the corresponding target data type, a logic block is not directly selected to store the current real-time data, but the storage position of the last historical data stored in the EEPROM corresponding to the target data type is firstly determined to obtain the target historical storage position. The historical data is the data stored in the EEPROM for the last time, and the data is the same as the target data type of the current real-time data.
Specifically, after the target history storage position is obtained, a specific logic block corresponding to the target history storage position can be found, the logic block can be determined to be the target logic block, the target logic block is used for storing history data, each logic block can comprise one or more physical storage blocks, when the history data is stored, the storage space included in the logic block is not required to be occupied completely, but in order to reduce the waste of the storage space, one logic block can correspond to the minimum required storage block number, for example, one history data is 6KB, the storage space of one storage block is 4KB, the logic block for storing one history data at least comprises two storage blocks, one storage block can store the history data of 4KB, and the other storage block can store the history data of another 2KB, so that the complete history data is stored.
Wherein the memory block is a physical memory block in the EEPROM.
And S13, saving the current real-time data to the next logic block adjacent to the target logic block in the EEPROM.
Specifically, after the target logic block is determined, the current real-time data is stored to the next logic block adjacent to the target logic block, so that the data stored each time is ensured not to be repeatedly stored in the same logic block, namely, the data is not repeatedly stored in the storage block corresponding to the logic block, meanwhile, the current real-time data is always stored to the next logic block adjacent to the target logic block, the storage space in the whole EEPROM can be effectively and integrally utilized, the condition that the data are repeatedly stored in a plurality of logic blocks is avoided, the data are sequentially stored in each logic block in the EEPROM, the condition that the service life of the individual storage block is rapidly used up due to the fact that the individual storage block in the EEPROM is repeatedly erased in a concentrated mode when the data are stored is avoided, and the integral service life of the EEPROM is prolonged as much as possible.
It should be noted that, the storage space in the EEPROM may be divided into a plurality of sequentially adjacent logic blocks in order to save the size of the logic block required by the target data type, where the first logic block is the next logic block adjacent to the last logic block to form a cycle of the storage space, so as to implement the effect of circularly saving the current real-time data in each logic block in the whole EEPROM, thereby prolonging the service life of a single storage block, for example, each storage block may be erased 100 ten thousand times, and at present, it is required to repeatedly save the driving mileage of the vehicle, if the driving mileage of the vehicle is saved once every 0.1 km, after the vehicle has driven for 10 ten thousand km, the driving mileage of the vehicle has reached 100 ten thousand times, at this time, by adopting the prior art, the storage blocks individually used for storing the driving mileage of the vehicle may be damaged, so that the phenomenon of the damaged block appears in the whole EEPROM occurs, if the circulation save method of the embodiment of the application is adopted, if the EEPROM includes 50 logic blocks, the number of erasing times that can be changed to 50 x 100 ten thousand times before the occurrence of damage appears, and the service life of the EEPROM is obviously prolonged in the whole.
Therefore, the embodiment of the application circularly saves the new data into the whole EEPROM, and does not repeatedly save the data into the same logic block, thereby delaying the phenomenon of bad blocks in the EEPROM and integrally prolonging the service life of the EEPROM.
The embodiment of the application discloses a specific EEPROM data storage method, and compared with the previous embodiment, the technical scheme of the embodiment is further described and optimized. See fig. 2 for details:
s21, receiving current real-time data corresponding to the target data type;
S22, determining a storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block;
S23, storing the current real-time data to a next logic block adjacent to the target logic block in the EEPROM;
and S24, storing the current real-time data into the corresponding standby logic blocks in the standby partition by utilizing the storage position of the next logic block of the target logic block and the corresponding relation with the storage position in the standby partition.
Specifically, since the whole storage space in the EEPROM is fully used by the cyclic storage, but the service life of the EEPROM is not changed, a large number of bad blocks are easy to occur to cause data loss when the service life of the EEPROM is finally approached, in order to avoid the data loss caused by the bad blocks, the storage space in the EEPROM can be divided into a main partition and a spare partition in advance to obtain the main partition, and after the current real-time data is stored in the main partition in S21 to S23, the storage position of the next logic block of the target logic block can be continuously utilized to find the corresponding storage position in the spare partition.
Specifically, the spare partition includes a plurality of adjacent logic blocks connected in sequence, the logic blocks of the spare partition and the main partition are also continuous, for example, the EEPROM includes 6 logic blocks, which can be divided into two partitions on average, each partition includes 3 logic blocks, one partition is the main partition, one partition is the spare partition, the logic blocks corresponding to the main partition can be the first logic block to the third logic block in sequence, the logic blocks corresponding to the spare partition can be the fourth logic block to the sixth logic block in sequence, and when data is stored in the first logic block, the data can be simultaneously stored in the first logic block, namely the fourth logic block, in the corresponding spare partition, so that the data is also circularly stored in the spare partition, and the data backup is realized.
Further, the current real-time data can be stored in the corresponding spare logical block in the spare partition by using the storage position and the block length of the next logical block of the target logical block, wherein the block length is the number of storage blocks included in each partition, and the spare partition is the same as the block length of the main partition.
For example, the EEPROM includes 6 logic blocks, the logic blocks corresponding to the main partition may be the first logic block to the third logic block in sequence, the logic blocks corresponding to the spare partition may be the fourth logic block to the sixth logic block in sequence, each logic block may include 2 storage blocks, the block length of one partition is 6, the storage position of the first logic block may correspond to the storage position of the first storage block being 1, the storage position of the fourth logic block is the storage position of the first logic block plus the block length, and 7 corresponds to the storage position of the first storage block in the fourth logic block.
Specifically, even if the number of logical blocks included in the main partition and the spare partition is different, the method may be implemented by using a block length, for example, the main partition includes a first logical block to a third logical block, the spare partition includes a fourth logical block and a fifth logical block, the block length is 3, the storage position of the third logical block is 3, the storage position corresponding to the third logical block is 6, and the storage position of the fifth logical block in the spare partition is 5, where at this time, the method may be implemented by cycling in the spare partition, and the storage position is 6 corresponding to the fourth logical block, thereby implementing the method of circularly storing data in the spare partition.
It will be appreciated that multiple spare partitions may be partitioned in the EEPROM, e.g., one or two, however, partitioning too many spare partitions may result in a reduction in the amount of different data that can be stored in the EEPROM at the same time, and for this purpose, it may be preferable to provide one main partition and two spare partitions, and 3 partitions may be used to divide the storage space in the EEPROM equally, so that the logical blocks between the partitions can be in a one-to-one correspondence, as shown in table 1, each Page corresponds to one storage block, pages 0 to 17 are 18 consecutive storage blocks in one EEPROM, pages 0 to 5 correspond to the main partition, pages 6 to 11 correspond to the first spare partition, pages 12 to 17 correspond to the third spare partition, and the storage blocks between each partition are aligned.
TABLE 1
Page0 | Page1 | Page2 | Page3 | Page4 | Page5 |
Page6 | Page7 | Page8 | Page9 | Page10 | Page11 |
Page12 | Page13 | Page14 | Page15 | Page16 | Page17 |
The embodiment of the application also discloses a specific EEPROM data storage method, and compared with the previous embodiment, the technical scheme of the embodiment is further described and optimized. With reference to fig. 3, the above embodiment is further improved, and the method includes:
s31, receiving a data reading instruction for reading target storage data corresponding to each other in the main partition and each standby partition in the EEPROM.
Specifically, the target storage data in the main partition is read, and meanwhile, the corresponding target storage data in each standby partition is also read, and under the theoretical condition, the target storage data stored in each partition should be consistent.
S32, checking target storage data stored in each partition according to the data reading instruction.
Specifically, after storing a plurality of data into the main partition and the spare partition, since any partition cannot be guaranteed to be intact, data verification is required when reading the data, so that erroneous target storage data is prevented from being read out due to data loss caused by bad blocks.
S33, if all the target storage data stored in the partitions are successfully checked, the target storage data are read.
Specifically, the target storage data may be verified using a checksum of 1 byte in the target storage data.
S34, if the target storage data stored in any partition fails to be checked, the storage data stored in the most partitions are read.
Specifically, if the verification of the target storage data stored in any partition fails, the storage data stored in the most partitions is read, and because the data corruption is a small probability event, reading the storage data with the largest storage number can ensure that the correct target storage data is read.
For example, the EEPROM includes 3 partitions, a main partition, a first spare partition, and a second spare partition, the target storage data is a, the storage data corresponding to the target storage data in the first spare partition becomes A1, and the storage data corresponding to the target storage data in the main partition and the second spare partition are the same as each other, and there are storage data stored in only 1 partition among the most partitioned areas with respect to A1 among the 2 partitions, so the storage data in the main partition or the second spare partition is read as the target storage data.
The embodiment of the application discloses a specific EEPROM data storage method, and compared with the embodiment, the embodiment further describes and optimizes the technical scheme. See fig. 4 for details:
s41, receiving current real-time data corresponding to a target data type;
And S42, determining the storage position of the history data by utilizing the storage counts of the current logic block and the adjacent logic blocks pointed at first time when the EEPROM is initialized in advance so as to obtain a target history storage position, and determining the logic block corresponding to the target history storage position as a target logic block.
Specifically, when the EEPROM is powered on for the first time, it needs to be initialized, and the target history storage location of the last stored history data is redetermined, so as to store the latest data. When the EEPROM is initialized, the first logic block in the EEPROM, namely the current logic block, is pointed at first, then according to the preservation count recorded in each logic block, whether the current logic block is the logic block for preserving data last time is judged, the logic block for preserving data last time can be searched by traversing the logic blocks in the EEPROM, then the storage position of the historical data can be determined by preserving in sequence, so as to obtain the target historical storage position, and the logic block corresponding to the target historical storage position is determined as the target logic block, or the logic block for preserving data last time is the target logic block.
After each time of data storage in the EEPROM, the storage count is increased by one, and the storage count and the stored data are stored in the same logic block, wherein the storage count can be expressed as Index and is 4-byte unsigned integer.
And S43, saving the current real-time data to the next logic block adjacent to the target logic block in the EEPROM.
Further, the process of initializing the EEPROM mentioned in S42 may specifically include a process of initializing the last stored logical block by the process of searching for the last stored logical block in S421 to S425, wherein,
S421, a first saving count saved in the current logic block is obtained.
Specifically, the first current logic block is the first logic block pointed at during EEPROM initialization, and is usually the first logic block of the EEPROM, and the first saving count saved in the current logic block is obtained for subsequent judgment.
S422, determining a second storage position of a second logic block adjacent to the current logic block by using the number of storage blocks occupied by the current logic block.
Specifically, although the logic blocks are adjacent to each other, in the process of searching the actual position, the actual storage position of the corresponding storage block is still needed, and because the current logic block is pointed, the storage position of the first storage block under the current logic block can be known, and the second storage position of the second logic block adjacent to the current logic block can be obtained by adding the storage position of the first storage block with the number of the storage blocks in the current logic block.
For example, the storage location of the first storage block of the current logic block is 1, and the current logic block includes 2 storage blocks, and then the second storage location of the adjacent second logic block is 3, that is, the storage location of the first storage block in the second logic block.
S423, judging whether valid data are stored in the second logic block by utilizing the second storage position.
Specifically, after the second storage location is obtained, the second logic block is found, so that it can be determined whether valid data is stored in the second logic block, because the second logic block may not be used yet, and the data is never stored, if the second logic block does not store the data, it can be stated that the current logic block is the logic block for storing the data last time.
S424, if the valid data is stored, judging whether the second save count in the second logic block is larger than the first save count.
Specifically, if valid data is stored in the second logic block, it is also possible that old data stored in the second logic block in the past, that is, when stored last time, may have already been stored once in all logic blocks in the EEPROM, this time, and this time, the second logic block may store old data instead of the latest data. Therefore, it is also necessary to determine whether the second save count in the second logical block is greater than the first save count, and if so, to indicate that the data saved in the second logical block is data saved very early, then to indicate that the data in the current logical block is data saved last time because new data has not yet been saved in the next adjacent second logical block.
And S425, if the second save count is greater than the first save count, re-executing the steps S421 to S424 by taking the second logic block as a new current logic block until no effective data is stored in the second logic block or the second save count is less than the first data save count, and recognizing the current logic block as the first logic block of the last saved data before the EEPROM is powered on.
Specifically, if the second save count is greater than the first save count, it indicates that the second logic block stores data that is later than the current logic block, so that the second logic block is re-used as a new current logic block, and is brought back to S421 to re-compare the next adjacent logic block until no valid data is stored in the second logic block or the second save count is less than the first data save count, and the current logic block is considered as the first logic block in which data was last saved before the EEPROM was powered on.
The number of the storage blocks included in the current logic block is the same as that of the storage blocks included in the second logic block, the number of the storage blocks required for storing data each time is the same, and the storage space of each logic block is the same, so that the next logic block can be found by utilizing the number of the storage blocks and matching with the storage position.
If the current real-time data is the first time stored after the EEPROM is initialized, the first logic block finally found after the EEPROM is the target logic block, if the current real-time data is not the first time stored after the EEPROM is initialized, the first logic block is taken as a starting point in the process of storing the data in the follow-up process, the data is stored until the data is stored to the target logic block, and then the current updated data is stored according to the target historical storage position of the target logic block.
The embodiment of the application also discloses a data storage method in the EEPROM, which is shown in FIG. 5 and comprises the following steps:
S51, receiving current real-time data corresponding to the target data type;
s52, acquiring the current operation temperature of the EEPROM.
Specifically, the EEPROM itself will heat up after storing data a plurality of times, and an excessively high temperature will cause the speed of storing data by the EEPROM and the possibility of failure in storing data, for which purpose the current operating temperature of the EEPROM is detected so as to be adjusted according to the current operating temperature of the EEPROM.
S53, judging whether the current running temperature of the EEPROM exceeds a preset temperature threshold value;
s54, if yes, judging whether the time interval between the current time and the historical preservation time for preserving the historical data is smaller than a preset time threshold value;
and S55, if the current real-time data is smaller than the current real-time data, storing the current real-time data into a memory buffer area.
Specifically, if the current running temperature of the EEPROM exceeds the preset temperature threshold, it is indicated that the EEPROM has overheated or is close to the upper limit of overheating, at this time, it is further determined whether the time interval between the current time and the last stored historical storage time is smaller than the preset time threshold, if the time interval is smaller than the preset time threshold, the storage is too frequent, and if the time interval is smaller than the time interval, the EEPROM may be continuously warmed up, which is not beneficial to stable operation of the EEPROM, so that the current real-time data can be stored in the memory buffer area in advance, so that the EEPROM is cooled.
Specifically, if the temperature of the EEPROM decreases, the current real-time data in the memory buffer area can be saved back to the EEPROM again, and the saving process is the same as S11 to S13.
S56, if the temperature threshold value is not exceeded or the time threshold value is not smaller than the temperature threshold value, determining the storage position of the last historical data stored in the EEPROM corresponding to the target data type to obtain a target historical storage position, and determining a logic block corresponding to the target historical storage position as a target logic block;
And S57, saving the current real-time data to the next logic block adjacent to the target logic block by utilizing the target historical storage position and the number of storage blocks included in the target logic block.
Specifically, the first storage position of the next logic block adjacent to the target logic block can be obtained by using the target history storage position and the number of storage blocks included in the target logic block, and then the current real-time data is stored to the next logic block adjacent to the target logic block by using the first storage position, so that the data storage is completed, and the process of searching the last stored first logic block required during initialization is not needed.
It will be appreciated that, before the EEPROM is powered down, if the current real-time data is also stored in the memory buffer, the current real-time data may be saved again in the EEPROM according to the processes from S11 to S13.
Correspondingly, the embodiment of the application also discloses a working process of the data storage method in the EEPROM under a specific application scene, which comprises the following steps:
taking an EEPROM for recording the mileage of the automobile as an example, storing mileage data every 0.1 km the automobile travels, storing the current mileage data in the next logic block of the logic block used when the mileage data is stored last time, for example, the current mileage data is 52.3, the mileage data stored last time is 52.2, storing the mileage data in the fifth logic block, and storing the current mileage data in the sixth logic block.
Meanwhile, after the current mileage data is stored in the sixth logic block, the current mileage data can be stored in the first standby partition and the second standby partition at the same time, wherein the first standby partition comprises 12 storage blocks according to the block length 12 of the main partition, namely, each block comprises 2 storage blocks, the mileage data needs to be stored in the eighteenth logic block according to the storage position 11 of the sixth logic block, the first standby partition obtains the storage position 23 corresponding to the twelfth logic block in the first standby partition, the current mileage data is stored in the twelfth logic block, the second standby partition finds the storage position 35 of the eighteenth logic block by utilizing the block length 12 of the first standby partition and the storage position 23 of the twelfth logic block, and the current mileage data is stored in the eighteenth logic block.
And the current running temperature and the storage time interval of the EEPROM can be detected before the current mileage data are stored, if the current mileage data exceeds the temperature and is smaller than the time interval, the current mileage data are stored in the memory buffer zone, and the rest current mileage data in the memory buffer zone are all stored in the EEPROM during the period that the vehicle is stopped and is ready to be closed for power down.
Meanwhile, when the vehicle is started, the EEPROM is initialized, and the first logic block for storing the history count last time is determined by using the stored count in each logic block.
Correspondingly, the embodiment of the application also discloses a data storage system in the EEPROM, which is shown in FIG. 6 and comprises the following steps:
A data receiving module 11, configured to receive current real-time data corresponding to a target data type;
A logic block determining module 12, configured to determine a storage location of the last history data stored in the EEPROM corresponding to the target data type, to obtain a target history storage location, and determine a logic block corresponding to the target history storage location as a target logic block;
and the data storage module 13 is used for storing the current real-time data to the next logic block adjacent to the target logic block in the EEPROM.
Therefore, the embodiment of the application circularly saves the new data into the whole EEPROM, and does not repeatedly save the data into the same logic block, thereby delaying the phenomenon of bad blocks in the EEPROM and integrally prolonging the service life of the EEPROM.
Specifically, the system also comprises a data backup module, wherein,
The data backup module is used for storing the current real-time data into the corresponding standby logic block in the standby partition by utilizing the storage position of the next logic block of the target logic block and the corresponding relation with the storage position in the standby partition;
and performing block division on the storage space in the EEPROM in advance to obtain a main partition and a standby partition.
Specifically, the data backup module may be specifically configured to save the current real-time data to a corresponding spare logical block in the spare partition by using a storage location and a block length of a next logical block of the target logical block;
The block length is the number of storage blocks included in each partition, and the spare partition is the same as the block length of the main partition.
The system also comprises a reading instruction receiving module, a data checking module, a first data reading module and a second data reading module, wherein,
The read instruction receiving module is used for receiving a data read instruction for reading target storage data corresponding to each other in the main partition and each standby partition in the EEPROM;
the data verification module is used for verifying the target storage data stored in each partition according to the data reading instruction;
The first data reading module is used for reading the target storage data if the target storage data stored in all the partitions are successfully checked;
and the second data reading module is used for reading the storage data stored in the most subarea if the target storage data stored in any subarea fails to be checked.
Specifically, the logic block determining module 12 is specifically configured to determine a storage location of the history data by using a save count of a current logic block and an adjacent logic block pointed to by the EEPROM for the first time during initialization in advance, so as to obtain a target history storage location;
After each time of data storage in the EEPROM, the storage count is increased by one, and the storage count and the stored data are stored in the same logic block.
Specifically, the system also comprises a first count acquisition module, a storage position determination module, a valid data judgment module, a count judgment module and a logic block determination module 12, wherein,
The first count acquisition module is used for acquiring a first saving count saved in the current logic block;
The storage position determining module is used for determining a second storage position of a second logic block adjacent to the current logic block by using the number of storage blocks occupied by the current logic block;
The effective data judging module is used for judging whether effective data are stored in the second logic block or not by utilizing the second storage position;
the count judging module is used for judging whether the second preservation count in the second logic block is larger than the first preservation count if the valid data are stored;
The logic block determining module 12 is configured to recall the second logic block as a new current logic block from the first count obtaining module if the second save count is greater than the first save count, and identify the current logic block as the first logic block in which data was last saved before the EEPROM was powered on if no valid data is stored in the second logic block or the second save count is less than the first data save count;
the first current logic block is the logic block pointed for the first time when the EEPROM is initialized, and the number of the current logic block is the same as that of the storage blocks included in the second logic block.
Specifically, the data storage module 13 is specifically configured to store the current real-time data to the next logical block adjacent to the target logical block by using the target history storage location and the number of storage blocks included in the target logical block.
Specifically, the data storage module 13 includes a storage location acquisition unit and a data storage unit, wherein,
A storage position obtaining unit, configured to obtain a first storage position of a next logical block adjacent to the target logical block by using the target history storage position and the number of storage blocks included in the target logical block;
And the data storage unit is used for storing the current real-time data to the next logic block adjacent to the target logic block by utilizing the first storage position.
Specifically, the system also comprises an operation temperature acquisition module, a temperature judgment module, a time interval judgment module and a memory storage module, wherein,
The running temperature acquisition module is used for acquiring the current running temperature of the EEPROM;
the temperature judging module is used for judging whether the current running temperature of the EEPROM exceeds a preset temperature threshold value;
The time interval judging module is used for judging whether the time interval between the current time and the historical preservation time for preserving the historical data is smaller than a preset time threshold value or not if the current time exceeds the historical preservation time;
And the memory storage module is used for storing the current real-time data into the memory buffer area if the current real-time data is smaller than the current real-time data.
Specifically, the device also comprises a power-down storage module, wherein,
And the power-down storage module is used for storing the current real-time data into the EEPROM if the current real-time data is stored in the memory buffer area before the EEPROM is powered down.
In addition, the embodiment of the application also discloses a data storage device in the EEPROM, which comprises:
A memory for storing a computer program;
and a processor for executing a computer program to implement the data storage method in the EEPROM as described above.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
While the foregoing has been described in some detail to illustrate the principles and embodiments of the application, it is to be understood that this disclosure is not to be interpreted as limiting, but to enable one of ordinary skill in the art to make and use the application.