CN114816230A - Flash data storage method and device and household appliance - Google Patents

Flash data storage method and device and household appliance Download PDF

Info

Publication number
CN114816230A
CN114816230A CN202110129314.1A CN202110129314A CN114816230A CN 114816230 A CN114816230 A CN 114816230A CN 202110129314 A CN202110129314 A CN 202110129314A CN 114816230 A CN114816230 A CN 114816230A
Authority
CN
China
Prior art keywords
data block
flash memory
storage space
current data
current
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110129314.1A
Other languages
Chinese (zh)
Inventor
韦依宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Hetai Intelligent Home Appliance Controller Co ltd
Original Assignee
Shenzhen Hetai Intelligent Home Appliance Controller Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Hetai Intelligent Home Appliance Controller Co ltd filed Critical Shenzhen Hetai Intelligent Home Appliance Controller Co ltd
Priority to CN202110129314.1A priority Critical patent/CN114816230A/en
Publication of CN114816230A publication Critical patent/CN114816230A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0616Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The embodiment of the invention relates to a Flash data storage method, a Flash data storage device and household electrical appliance equipment, wherein the method comprises the following steps: when a Flash memory is electrified, reading a stored data block, a starting address of a current data block and a residual storage space in the Flash memory; judging whether the residual storage space is smaller than the maximum length of the current data block; when the residual storage space is not smaller than the maximum length of the current data block, judging whether the strong electricity of the Flash memory is powered off or not; and if the strong electricity of the Flash memory is in power failure, writing the current data block into the residual storage space from the initial address in the weak electricity power failure state of the Flash memory. The embodiment of the invention protects important data of a product during operation, can quickly respond to a power-off event and save storage space, thereby effectively prolonging the service life of a storage device.

Description

Flash data storage method and device and household appliance
Technical Field
The embodiment of the invention relates to the technical field of intelligent household appliances, in particular to a Flash data storage method and device and a household appliance.
Background
In an intelligent household appliance, a Flash memory may be used to store a program and may also be used to store data in an MCU (micro controller Unit). Flash is generally erased when program codes are stored in production and burned, the burning times of an electronic product are usually few, data in a storage space are required to be empty (namely 0xFF) before the data are stored, the data are erased when the data are not empty, the erasing times are limited, the erasing time is relatively long, and therefore the erasing time and times are necessary to be reasonably arranged.
However, in the prior art, the number of times of erasing is large when storing user data, and when the size of space and the number of times of erasing are in the face, the life of a chip is often affected, or space is wasted.
Disclosure of Invention
The embodiment of the invention aims to provide a Flash data storage method, a Flash data storage device and household electrical appliance equipment, which can protect important data during the operation of a product, can quickly respond to a power failure event and save storage space, thereby effectively prolonging the service life of a storage device.
In a first aspect, an embodiment of the present invention provides a Flash data storage method, where the method includes:
when a Flash memory is electrified, reading a stored data block, a starting address of a current data block and a residual storage space in the Flash memory;
judging whether the residual storage space is smaller than the maximum length of the current data block;
when the residual storage space is not smaller than the maximum length of the current data block, judging whether the strong electricity of the Flash memory is powered off or not;
and if the strong electricity of the Flash memory is in power failure, writing the current data block into the residual storage space from the initial address in the weak electricity power failure state of the Flash memory.
In some embodiments, when the Flash memory is powered on, reading the stored data block, the start address of the current data block, and the remaining storage space in the Flash memory includes:
when a Flash memory is electrified, searching a data head of a stored data block in the Flash memory;
reading the data length of the stored data block according to the data head of the stored data block;
determining the storage address of the next data block according to the data length of the stored data block;
determining a data head of the next data block according to the storage address of the next data block;
judging whether the next data block is a current data block or not according to the data head of the next data block;
and when the next data block is the current data block, setting the pre-stored address of the next data block as the initial address of the current data block, and determining the residual storage space according to the data length of the stored data block and the total storage space of the Flash memory.
In some embodiments, after the determining whether the next data block is the current data block, the method further includes:
when the next data block is the current data block, checking the data content of the current data block;
when the data content passes the verification, setting the pre-stored address of the next data block as the initial address of the current data block;
and when the data content verification fails, erasing the total storage space to set the pre-stored address of the next data block as the first address of the total storage space.
In some embodiments, the determining whether the next data block is the current data block according to the data header of the next data block includes:
judging whether the data head of the next data block is empty or not;
and if the data head of the next data block is empty, determining that the next data block is the current data block.
In some embodiments, after said determining whether the remaining storage space is less than the maximum length of the current data block, the method further comprises:
and when the residual storage space is smaller than the maximum length of the current data block, erasing the total storage space so that the residual storage space is not smaller than the maximum length of the current data block.
In some embodiments, the determining whether a strong current of the Flash memory is powered down includes:
judging whether a strong electric pulse signal received by the Flash memory is overtime or not according to the electricity-dropping induction circuit;
if the Flash memory receives the overtime strong electric pulse signal, judging the strong electric power failure of the Flash memory;
and if the timing data corresponding to the strong electric pulse signal received by the Flash memory is increased, judging that the strong electric power of the Flash memory is not powered down.
In some embodiments, if the strong power of the Flash memory is lost, writing the current data block from the start address into the remaining storage space in the weak power lost state of the Flash memory includes:
if the strong current of the Flash memory is in power-down state, entering the weak current power-down state of the Flash memory according to the power-down sensing circuit;
acquiring the initial address of the current data block;
and writing the current data block into the residual storage space from the initial address before the weak power-down state of the memory of the Flash is finished.
In some embodiments, the power-down sensing circuit comprises a first resistor, an optical coupler, a first capacitor, a second resistor and a third resistor, wherein a first input end of the optical coupler is connected with one end of an external power supply through the first resistor, and a second input end of the optical coupler is strongly connected with the other end of the external power supply; the first output end of the optocoupler is connected with one end of the second resistor, one end of the third resistor and one end of the second capacitor respectively, and the second output end of the optocoupler is connected with the other end of the second capacitor and the grounding end; the other end of the third resistor is connected with a main control module of the household appliance, and the first capacitor is connected with a weak current power supply module and a grounding end of the main control module.
In a second aspect, an embodiment of the present invention provides a Flash data storage device, where the device includes:
the power-on reading module is used for reading a stored data block, a starting address of a current data block and a residual storage space in the Flash memory when the Flash memory is powered on;
a residual storage space judging module, configured to judge whether the residual storage space is smaller than a maximum length of the current data block;
the strong electricity power-down judging module is used for judging whether strong electricity of the Flash memory is powered down or not when the residual storage space is not smaller than the maximum length of the current data block;
and the writing module is used for writing the current data block into the residual storage space from the initial address in the weak power failure state of the Flash memory if the strong power of the Flash memory is in power failure.
In a third aspect, an embodiment of the present invention provides a home appliance, where the home appliance includes:
at least one processor, and
a memory communicatively coupled to the at least one processor, the memory storing instructions executable by the at least one processor to enable the at least one processor to perform the method described above.
In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium, which stores computer-executable instructions, and when the computer-executable instructions are executed by an electrical home appliance, the electrical home appliance performs the method described above.
The Flash data storage method, the device and the household appliance in the embodiment of the invention read the stored data block, the initial address of the current data block and the residual storage space in the Flash memory when the Flash memory is electrified, judge whether the residual storage space is smaller than the maximum length of the current data block, indicate that the residual storage space is enough to store the current data block when the strong electricity is electrified when the residual storage space is not smaller than the maximum length of the current data block, at the moment, if the strong electricity of the Flash memory is powered off, the current data block is written into the residual storage space from the initial address under the weak electricity power-off state of the Flash memory, namely, the data block storage is carried out only under the condition of the strong electricity, the power-off event is quickly responded, and the storage of the current data block when the strong electricity is powered off is realized, the user data is not required to be stored in the Flash memory at regular time, the storage space of the Flash memory is effectively saved, and the data is not required to be erased when the residual storage space is not less than the maximum length of the current data block, so that the erasing times are reduced, and the service life of the device of the Flash memory is effectively prolonged.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the figures in which like reference numerals refer to similar elements and which are not to scale unless otherwise specified.
FIG. 1 is a schematic flow chart diagram illustrating one embodiment of a Flash data storage method of the present invention;
FIG. 2 is a block diagram of data of one embodiment of a Flash data storage method of the present invention;
FIG. 3 is a Flash space structure diagram of three continuous pages of non-stored data blocks and stored data blocks according to an embodiment of the Flash data storage method of the present invention;
FIG. 4 is a power down sensing circuit diagram of one embodiment of a Flash data storage method of the present invention;
FIG. 5 is a timing diagram of a power-off sensing circuit of one embodiment of the Flash data storage method of the present invention;
FIG. 6 is a schematic structural diagram of one embodiment of a Flash data storage device of the present invention;
FIG. 7 is a schematic structural diagram of one embodiment of a Flash data storage device of the present invention;
fig. 8 is a diagram illustrating a hardware structure of a controller according to an embodiment of the home appliance.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The Flash data storage method and device provided by the embodiment of the invention can be applied to household appliances. The household appliance can be an intelligent terminal device, such as an intelligent refrigerator, an air conditioner and other terminal devices.
It can be understood that, in the household electrical appliance, the controller is arranged as a main control center, which protects important data during the operation of the product, can quickly respond to a power-off event, and saves the storage space, thereby effectively prolonging the service life of the storage device.
Referring to fig. 1, fig. 1 is a schematic flowchart of a Flash data storage method according to an embodiment of the present invention, where the method may be executed by a controller 13 in a home appliance device, as shown in fig. 1, and the method is applied to the home appliance device, and includes:
101: and when the Flash memory is electrified, reading the stored data block in the Flash memory, the initial address of the current data block and the residual storage space.
When the intelligent household appliance is powered on, for example, when the alternating current of 220V mains supply is accessed, a Flash memory of the intelligent household appliance is powered on, and at the moment, a stored data block, a starting address of a current data block and a residual storage space in the Flash memory are read.
The data block includes three parts, i.e. a data header, as shown in fig. 2, the data block header, i.e. the data header, is also divided into two parts, one part is a header identifier and occupies one byte, e.g. 0xA5, the other part is a data block length, the data block length can be designed as required, e.g. 8 bits, 16 bits, etc., and in fig. 2, the data length adopted is 8 bits and occupies one byte.
The data body is parameter data related to user functions, for example, the temperature of the air conditioner set by the user is 23 ℃, and the data body is parameter data representing the temperature of the air conditioner of 23 ℃.
The checksum, which is located behind the data body and occupies one byte, is from the data header identifier to the last byte of the data body, and is used for ensuring the accuracy of the verification data.
The amount of data to be saved is made variable by the variable byte nature of the data volume, and the data is saved as needed, for example, 24 bytes for the first time, 64 bytes for the second time, and 16 bytes for the third time. Compared with the prior art, the data size is fixed, for example, 32 bytes are fixed, the data is stored in different sizes of 24 bytes, 16 bytes and 32 bytes, and if only 24 bytes are required to be stored, the 32 bytes are used for storing during storage, which causes 8 bytes of space waste.
As shown in fig. 3, fig. 3 is a Flash space structure diagram of three consecutive pages of non-stored data blocks and stored data blocks, where the content of Flash is all hexadecimal FF when no data block is stored, and there are data blocks with different sizes when data blocks are stored, for example, in the Flash space of the stored data block of page 0, the length of data block 0 is smaller than the length of data block 1, and the length of data block 1 is larger than the length of data block 2.
In some embodiments, when the Flash memory is powered on, reading the stored data block, the start address of the current data block, and the remaining storage space in the Flash memory may include:
when a Flash memory is electrified, searching a data head of a stored data block in the Flash memory;
reading the data length of the stored data block according to the data head of the stored data block;
determining the storage address of the next data block according to the data length of the stored data block;
determining a data head of the next data block according to the storage address of the next data block;
judging whether the next data block is a current data block or not according to the data head of the next data block;
and when the next data block is the current data block, setting the pre-stored address of the next data block as the initial address of the current data block, and determining the residual storage space according to the data length of the stored data block and the total storage space of the Flash memory.
Specifically, the stored data block is user data stored before power failure last time, and according to the components of the data block, when the Flash memory is powered on, the data head of the stored data block is searched in the Flash memory, so that the data length where the stored data block is located can be read according to the data head of the stored data block, for example, a set data storage start page and a set total page number are loaded first, and a start page head address is set as a searched address, for example, if the start page is a 0 th page, the searched address is a data block 0 of the 0 th page, a header identifier 0xA5 in the data head of the stored data block is searched, and then, since another byte in the data head represents the data body length, according to the data head of the stored data block Dn, the data length where the stored data block Dn is located can be read; after the data length of the stored data block Dn is obtained, since it can be known that the stored data block Dn is located in the data block of the page several, the storage address of the next data block can be determined, for example, if the stored data block Dn is the data block 1 of the page 0, the storage address of the next data block Dn +1 can be determined as the storage address of the data block 2, that is, the start address of the next data block Dn +1 is the end address +1 of the data block 1, according to the data block storage sequence of the page 0, since the data length of the data block 1 is known. Since the data blocks are arranged in sequence, the data header of the next data block Dn +1 can be determined based on the storage address of the next data block Dn + 1.
In some embodiments, determining whether the next data block Dn +1 is a current data block according to the data header of the next data block Dn +1 may include:
judging whether the data head of the next data block is empty or not;
and if the data head of the next data block is empty, determining that the next data block is the current data block.
Specifically, the current data block is a user data block that the user finally needs to store, for example, if the user adjusts the temperature of the air conditioner to 23 ℃, if the air conditioner is suddenly powered off, the temperature parameter of the air conditioner temperature 23 ℃ needs to be stored, so that the user can operate at 23 ℃ when a call comes. Further, when determining whether the next data block Dn +1 is the current data block, determining whether the data header of the next data block Dn +1 is empty, and if the data header of the next data block is empty, for example, the stored data block is the data block 11 of the first page, and the next data block is an empty hexadecimal FF, it is obvious that the user does not update the data block any more, so the data block 11 is taken as the current data block; correspondingly, if the stored data block Dn is the data block 9, it is obvious that there is a next data block, that is, it indicates that new user data has been updated, at this time, the query address needs to be added, and data header query is returned until a data block with an empty data header is found to determine the current data block.
In some embodiments, after the determining whether the next data block is the current data block, the method further includes:
when the next data block is the current data block, checking the data content of the current data block;
when the data content passes the verification, setting the pre-stored address of the next data block as the initial address of the current data block;
and when the data content verification fails, erasing the total storage space to set the pre-stored address of the next data block as the first address of the total storage space.
Specifically, when the next data block is the current data block, the data content of the current data block needs to be checked, and according to the components of the data block, the data content can be checked through the checksum of the current data block, so as to ensure the accuracy of the verification data.
When the data content passes the verification, the data content is normal, the MCU of the home appliance can take out the data block saved in the last power-off for use, and the pre-stored address of the next data block Dn +1 is set as the start address of the current data block.
Correspondingly, when the data content is failed to be verified, it is indicated that the data content is wrong, then the parameter set by the user is modified to be default, for example, the lowest temperature of the air conditioner is 16 ℃, when the temperature of the air conditioner is 16 ℃, the user continues to press down the downward temperature adjustment, then the parameter corresponding to the downward temperature adjustment is the data content failed to be verified, at this time, the total storage space is erased, so that the pre-stored address of the next data block is set as the first address of the total storage space.
And when the next data block Dn +1 is the current data block, setting the pre-stored address of the next data block as the start address of the current data block Dn +1, and determining the remaining storage space according to the data length of the stored data block Dn and the total storage space of the Flash memory. Thereby reading the stored data block, the start address of the current data block and the remaining storage space in the Flash memory.
And 102, judging whether the residual storage space is smaller than the maximum length of the current data block.
Correspondingly, when the data content of the current data block Dn +1 passes the verification, it indicates that the data content is normal, the MCU of the home appliance may take out the data block saved after the last power failure, and set the pre-stored address of the next data block Dn +1 as the start address of the current data block, and then determine whether the remaining storage space is smaller than the maximum length of the current data block.
Whether the residual storage space is enough for storing the current data block is judged by detecting the residual storage space, if not, the total storage space of the Flash memory is erased in time, so that the residual storage space is enough for storing the current data block, and the judgment, the erasing and other processing are carried out before the power failure, so that the problem that the storage fails due to insufficient space when the current data block needs to be stored due to the fact that the space is not erased after the power failure is avoided.
And 103, judging whether the strong electricity of the Flash memory is powered off or not when the residual storage space is not less than the maximum length of the current data block.
When the residual storage space is not smaller than the maximum length of the current data block, the residual storage space is enough to store the current data block, and at the moment, whether the strong electricity of the Flash memory is powered off or not can be judged.
In some embodiments, as shown in fig. 4, fig. 4 is a power-off sensing circuit of a Flash memory, and according to the power-off sensing circuit, whether a strong current of the Flash memory is powered down is determined, specifically, the power-down sensing circuit includes a first resistor R1, an optocoupler U1, a first capacitor C1, a second capacitor C2, a second resistor R2, and a third resistor R3, a first input end of the optocoupler U1 is connected to one end of an external power supply through the first resistor R1, and a second input end of the optocoupler U1 is connected to the other end of the external power supply; the first output end of opto-coupler U1 is connected with the one end of second resistance R2 respectively, the one end of third resistance R3 and the one end of second electric capacity C2, and the second output end of opto-coupler U1 is connected with the other end and the earthing terminal of second electric capacity C2, the other end of third resistance R3 is connected with the main control module MCU of tame electric installation, first electric capacity C1 connects main control module MCU's weak current power module 3.3V and earthing terminal. The MCU power module and the optocoupler U1 are connected with the same 220V alternating current, and the 3.3V power supply of the main control module MCU of the household appliance is provided by the MCU power module.
Specifically, when being connected to the alternating current of 220V of external power supply, the Flash memory is electrified, first resistance R1 can be 470k omega, through first resistance R1, prevent that opto-coupler U1 from burning out under 220V's alternating current, and light-operated triode in the light-coupled U1 lights, and, with the second output ground of opto-coupler U1, through opto-coupler U1, alternate current sine wave signal with 220V's alternating current is converted into square wave signal, square wave signal's jump from top to bottom is along the signal and lets MCU produce the program interrupt and clear away the power failure timeout count, other interference signal can be filtered to second electric capacity C2. Taking 220V ac as an example, the frequency of the obtained square wave signal is 50Hz, then the obtained one-cycle transition edge signal is 20ms, and strong power failure is confirmed by continuously losing two-cycle transition edge signals (i.e. 40 ms).
Therefore, in some embodiments, determining whether a strong current of the Flash memory is powered down includes:
judging whether a strong electric pulse signal received by the Flash memory is overtime or not according to the electricity-dropping induction circuit;
if the Flash memory receives the overtime strong electric pulse signal, judging the strong electric power failure of the Flash memory;
and if the timing data corresponding to the strong electric pulse signal received by the Flash memory is increased, judging that the strong electricity of the Flash memory is not powered down.
Specifically, according to the inductance dropping sensing circuit, whether a strong electric pulse signal received by the Flash memory is overtime is judged, for example, whether a jump edge signal of two periods is continuously received, if the jump edge signal is not received, the strong electric pulse signal received by the Flash memory is overtime can be judged, and the strong electric power failure of the Flash memory is judged; if the timing data corresponding to the received strong electric pulse signal is increased when the jump edge signals of two continuous periods are received, namely the number of the received strong electric pulse signals is continuously increased, the situation that the strong electricity of the Flash memory is not powered down is shown.
104: and if the strong electricity of the Flash memory is in power failure, writing the current data block into the residual storage space from the initial address in the weak electricity power failure state of the Flash memory.
When detecting that the strong electricity of the Flash memory is powered off, the Flash memory enters a weak electricity power-off state according to the known electricity-off sensing circuit, and the current data block is written into the residual storage space from the initial address under the weak electricity power-off state of the Flash memory.
In some embodiments, if the strong power of the Flash memory is lost, writing the current data block from the start address into the remaining storage space in the weak power loss state of the Flash memory includes:
if the strong current of the Flash memory is in power-down state, entering the weak current power-down state of the Flash memory according to the power-down sensing circuit;
acquiring the initial address of the current data block;
and writing the current data block into the residual storage space from the initial address before the weak power-down state of the flash memory is finished.
Specifically, as shown in fig. 5, fig. 5 is a timing diagram of the inductance-reducing sensing circuit. When strong electricity power-off is confirmed, 3.3V can not disappear within a certain time range due to the discharging effect of the MCU power module and the first capacitor C1, at the moment, the initial address of the current data block is obtained by depending on the weak electricity power-off state of 3.3V power supply as data storage time, and the current data block is written into the residual storage space from the initial address before the weak electricity power-off state of the Flash memory is finished.
Because the residual storage space is determined during writing without erasing the space, only the writing needs time, and the weak power-down state can just provide the writing time, thereby effectively ensuring the writing time of the current data block.
Compared with two data storage modes in the prior art, one mode is fixed address timing storage, the fixed address stores data with a fixed address every time, the data are stored after the original data are erased when the fixed address is stored at the fixed time, the other mode is unfixed address single fixed data volume storage, the address can be read once when the power is on, the data are stored when the time is set to the storage time in the operation process, and the address is fixedly increased by one data block space unit again, so that the storage times can be increased.
In addition, in conventional electrical appliance application products, the power failure data is recorded with a certain parameter, the power failure protection data is not too large in a certain switch state, and is generally within tens of bytes, and the data is refreshed instead of accumulated when being changed, for example, 32 bytes of data are refreshed instead of being accumulated into 64 bytes after being changed in state. In the MCU system of the conventional electric appliance, the saving operation of 1024 bytes consumes about 5 milliseconds, and there is a difference of several tens milliseconds to several seconds from the strong power drop to the weak power drop (drop of the effective voltage). The current data block is saved within the time of the weak power-down state. Tens of milliseconds and even to seconds are consumed when a different MCU re-erases a space, so the erase action is put on power.
In addition, the data block does not need to be stored in the period from power-on to power-off, and the data block does not lose power in the MCU memory. If storage is needed, if a user has a manual storage function, a storage action can be executed, and the address variable to be stored is increased according to the size of the stored data block.
In the embodiment of the application, when a Flash memory is electrified, a stored data block, a starting address of a current data block and a residual storage space in the Flash memory are read, whether the residual storage space is smaller than the maximum length of the current data block or not is judged, when the residual storage space is not smaller than the maximum length of the current data block, the residual storage space is enough to store the current data block when a strong current is electrified, at the moment, if the strong current of the Flash memory is powered off, the current data block is written into the residual storage space from the starting address under the weak current power-off state of the Flash memory, namely, the data block is stored under the condition that the strong current is powered off, a power-off event is quickly responded, so that the storage of the current data block when the strong current is powered off is realized, and the Flash memory does not need to store user data regularly, the storage space of the Flash memory is effectively saved, and the data does not need to be erased when the residual storage space is not less than the maximum length of the current data block, so that the erasing times are reduced, and the service life of the device of the Flash memory is effectively prolonged.
Correspondingly, as shown in fig. 6, an embodiment of the present invention further provides a Flash data storage device, which can be used for a home appliance, where the Flash data storage device 700 includes:
the power-on reading module 701 is used for reading a stored data block, a starting address of a current data block and a residual storage space in a Flash memory when the Flash memory is powered on;
a remaining storage space determining module 702, configured to determine whether the remaining storage space is smaller than the maximum length of the current data block;
a strong power failure determining module 703, configured to determine whether a strong power of the Flash memory is in a power failure when the remaining storage space is not less than the maximum length of the current data block;
and the writing module 704 is configured to write the current data block into the remaining storage space from the start address in a weak power failure state of the Flash memory if a strong power failure of the Flash memory occurs.
In the embodiment of the invention, when a Flash memory is electrified, a stored data block, an initial address of a current data block and a residual storage space in the Flash memory are read, whether the residual storage space is smaller than the maximum length of the current data block or not is judged, when the residual storage space is not smaller than the maximum length of the current data block, the residual storage space is enough to store the current data block when the strong electricity is electrified, at the moment, if the strong electricity of the Flash memory is powered off, the current data block is written into the residual storage space from the initial address under the weak electricity power-off state of the Flash memory, namely, the data block is stored under the condition that the strong electricity is powered off, a strong electricity power-off event is quickly responded, the storage of the current data block when the strong electricity is powered off is realized, and the Flash memory does not need to store user data regularly, the storage space of the Flash memory is effectively saved, and the data does not need to be erased when the residual storage space is not less than the maximum length of the current data block, so that the erasing times are reduced, and the service life of the device of the Flash memory is effectively prolonged.
In other embodiments, the power-on reading module 701 is further configured to:
when a Flash memory is electrified, searching a data head of a stored data block in the Flash memory;
reading the data length of the stored data block according to the data head of the stored data block;
determining the storage address of the next data block according to the data length of the stored data block;
determining a data head of the next data block according to the storage address of the next data block;
judging whether the next data block is a current data block or not according to the data head of the next data block;
and when the next data block is the current data block, setting the pre-stored address of the next data block as the initial address of the current data block, and determining the residual storage space according to the data length of the stored data block and the total storage space of the Flash memory.
In other embodiments, the power-on reading module 701 is further configured to:
when the next data block is the current data block, checking the data content of the current data block;
when the data content passes the verification, setting the pre-stored address of the next data block as the initial address of the current data block;
and when the data content verification fails, erasing the total storage space to set the pre-stored address of the next data block as the first address of the total storage space.
In other embodiments, the power-on reading module 701 is further configured to:
judging whether the data head of the next data block is empty or not;
and if the data head of the next data block is empty, determining that the next data block is the current data block.
In some embodiments, after the remaining storage space determining module 702 performs the determination of whether the remaining storage space is smaller than the maximum length of the current data block, the Flash data storage device 700 further includes:
an erase module 705 to:
and when the residual storage space is smaller than the maximum length of the current data block, erasing the total storage space so that the residual storage space is not smaller than the maximum length of the current data block.
In some embodiments, the strong power failure determining module 703 is further configured to:
judging whether a strong electric pulse signal received by the Flash memory is overtime or not according to the electricity-dropping induction circuit;
if the Flash memory receives the overtime strong electric pulse signal, judging the strong electric power failure of the Flash memory;
and if the timing data corresponding to the strong electric pulse signal received by the Flash memory is increased, judging that the strong electricity of the Flash memory is not powered down.
In some embodiments, the writing module 704 is further configured to:
if the strong current of the Flash memory is in power-down state, entering the weak current power-down state of the Flash memory according to the power-down sensing circuit;
acquiring the initial address of the current data block;
and writing the current data block into the residual storage space from the initial address before the weak power-down state of the memory of the Flash is finished.
In some embodiments, the power-down sensing circuit comprises a first resistor, an optical coupler, a first capacitor, a second resistor and a third resistor, wherein a first input end of the optical coupler is connected with one end of an external power supply through the first resistor, and a second input end of the optical coupler is strongly connected with the other end of the external power supply; the first output end of the optical coupler is respectively connected with one end of a second resistor, one end of a third resistor and one end of a second capacitor, and the second output end of the optical coupler is connected with the other end of the second capacitor and the grounding end; the other end of the third resistor is connected with a main control module of the household appliance, and the first capacitor is connected with a weak current power supply module and a grounding end of the main control module.
It should be noted that the above-mentioned apparatus can execute the method provided by the embodiments of the present application, and has corresponding functional modules and beneficial effects for executing the method. For technical details which are not described in detail in the device embodiments, reference is made to the methods provided in the embodiments of the present application.
Fig. 8 is a schematic diagram of a hardware structure of a controller according to an embodiment of the home appliance, and as shown in fig. 8, the controller 13 includes:
one or more processors 131, memory 132. Fig. 8 illustrates an example of one processor 131 and one memory 132.
The processor 131 and the memory 132 may be connected by a bus or other means, and fig. 8 illustrates the connection by the bus as an example.
The memory 132, as a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions/modules corresponding to the Flash data storage method in the embodiment of the present application (for example, the power-on reading module 701, the remaining space determining module 702, the strong power-off determining module 703, the writing module 704, and the erasing module 705 shown in fig. 6 to 7). The processor 131 executes various functional applications and data processing of the controller, i.e., a Flash data storage method implementing the above-described method embodiments, by running the nonvolatile software programs, instructions, and modules stored in the memory 132.
The memory 132 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the Flash data storage device, and the like. Further, the memory 132 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, memory 132 may optionally include memory located remotely from processor 131, which may be connected to the home device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 132 and, when executed by the one or more processors 131, perform the Flash data storage method of any of the above-described method embodiments, e.g., performing the method steps 101-104 of fig. 1 described above; the functions of the modules 701 and 704 in fig. 6 and the functions of the modules 701 and 705 in fig. 7 are realized.
The product can execute the method provided by the embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the methods provided in the embodiments of the present application.
Embodiments of the present application provide a non-transitory computer-readable storage medium, which stores computer-executable instructions, which are executed by one or more processors, such as one processor 131 in fig. 8, and enable the one or more processors to perform the Flash data storage method in any of the method embodiments, such as performing method steps 101 to 104 in fig. 1 described above; the functions of the modules 701 and 704 in fig. 6 and the functions of the modules 701 and 705 in fig. 7 are realized.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that the embodiments may be implemented by software plus a general hardware platform, and may also be implemented by hardware. It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a computer readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; within the idea of the invention, also technical features in the above embodiments or in different embodiments may be combined, steps may be implemented in any order, and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A Flash data storage method is characterized by comprising the following steps:
when a Flash memory is electrified, reading a stored data block, a starting address of a current data block and a residual storage space in the Flash memory;
judging whether the residual storage space is smaller than the maximum length of the current data block;
when the residual storage space is not smaller than the maximum length of the current data block, judging whether the strong electricity of the Flash memory is powered off or not;
and if the strong electricity of the Flash memory is in power failure, writing the current data block into the residual storage space from the initial address in the weak electricity power failure state of the Flash memory.
2. The method according to claim 1, wherein reading the stored data block, the start address of the current data block, and the remaining storage space in the Flash memory when the Flash memory is powered on comprises:
when a Flash memory is electrified, searching a data head of a stored data block in the Flash memory;
reading the data length of the stored data block according to the data head of the stored data block;
determining the storage address of the next data block according to the data length of the stored data block;
determining a data head of the next data block according to the storage address of the next data block;
judging whether the next data block is a current data block or not according to the data head of the next data block;
and when the next data block is the current data block, setting the pre-stored address of the next data block as the initial address of the current data block, and determining the residual storage space according to the data length of the stored data block and the total storage space of the Flash memory.
3. The method of claim 2, wherein after the determining whether the next data block is the current data block, the method comprises:
when the next data block is the current data block, checking the data content of the current data block;
when the data content passes the verification, setting the pre-stored address of the next data block as the initial address of the current data block;
and when the data content verification fails, erasing the total storage space to set the pre-stored address of the next data block as the first address of the total storage space.
4. The method of claim 2, wherein said determining whether the next data block is a current data block according to the data header of the next data block comprises:
judging whether the data head of the next data block is empty or not;
and if the data head of the next data block is empty, determining that the next data block is the current data block.
5. The method of claim 1, wherein after said determining whether the remaining storage space is less than the maximum length of the current data block, the method comprises:
and when the residual storage space is smaller than the maximum length of the current data block, erasing the total storage space so that the residual storage space is not smaller than the maximum length of the current data block.
6. The method according to claim 1, wherein the determining whether the strong electricity of the Flash memory is powered down comprises:
judging whether a strong electric pulse signal received by the Flash memory is overtime or not according to the electricity-dropping induction circuit;
if the Flash memory receives the overtime strong electric pulse signal, judging the strong electric power failure of the Flash memory;
and if the timing data corresponding to the strong electric pulse signal received by the Flash memory is increased, judging that the strong electricity of the Flash memory is not powered down.
7. The method according to claim 1, wherein writing the current data block from the start address into the remaining storage space in a weak power-down state of the Flash memory if a strong power of the Flash memory is powered down, comprises:
if the strong current of the Flash memory is in power-down state, entering the weak current power-down state of the Flash memory according to the power-down sensing circuit;
acquiring the initial address of the current data block;
and writing the current data block into the residual storage space from the initial address before the weak power-down state of the memory of the Flash is finished.
8. A Flash data storage device, the device comprising:
the power-on reading module is used for reading a stored data block, a starting address of a current data block and a residual storage space in the Flash memory when the Flash memory is powered on;
a residual storage space judging module, configured to judge whether the residual storage space is smaller than a maximum length of the current data block;
the strong electricity power-down judging module is used for judging whether strong electricity of the Flash memory is powered down or not when the residual storage space is not smaller than the maximum length of the current data block;
and the writing module is used for writing the current data block into the residual storage space from the initial address in the weak power failure state of the Flash memory if the strong power of the Flash memory is in power failure.
9. An appliance device, comprising:
at least one processor, and
a memory communicatively coupled to the processor, the memory storing instructions executable by the at least one processor to enable the at least one processor to perform the method of any of claims 1-8.
10. A non-transitory computer-readable storage medium having stored thereon computer-executable instructions that, when executed by an appliance, cause the appliance to perform the method of any of claims 1-7.
CN202110129314.1A 2021-01-29 2021-01-29 Flash data storage method and device and household appliance Pending CN114816230A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110129314.1A CN114816230A (en) 2021-01-29 2021-01-29 Flash data storage method and device and household appliance

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110129314.1A CN114816230A (en) 2021-01-29 2021-01-29 Flash data storage method and device and household appliance

Publications (1)

Publication Number Publication Date
CN114816230A true CN114816230A (en) 2022-07-29

Family

ID=82525656

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110129314.1A Pending CN114816230A (en) 2021-01-29 2021-01-29 Flash data storage method and device and household appliance

Country Status (1)

Country Link
CN (1) CN114816230A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117742588A (en) * 2023-11-30 2024-03-22 武汉芯必达微电子有限公司 Data storage method and system using Flash simulation EEPROM

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104850507A (en) * 2014-02-18 2015-08-19 腾讯科技(深圳)有限公司 Data caching method and data caching device
US20160034388A1 (en) * 2014-08-04 2016-02-04 Phison Electronics Corp. Data management method, memory control circuit unit and memory storage apparatus
CN109683825A (en) * 2018-12-24 2019-04-26 广东浪潮大数据研究有限公司 A kind of storage system online data compression method, device and equipment
CN110430548A (en) * 2019-08-02 2019-11-08 上海西派埃自动化仪表工程有限责任公司 Data reissue method, apparatus, collector and storage medium
CN111666597A (en) * 2020-05-13 2020-09-15 上海微符尔半导体有限公司 On-chip storage method and device for electronic detonator chip

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104850507A (en) * 2014-02-18 2015-08-19 腾讯科技(深圳)有限公司 Data caching method and data caching device
US20160034388A1 (en) * 2014-08-04 2016-02-04 Phison Electronics Corp. Data management method, memory control circuit unit and memory storage apparatus
CN109683825A (en) * 2018-12-24 2019-04-26 广东浪潮大数据研究有限公司 A kind of storage system online data compression method, device and equipment
CN110430548A (en) * 2019-08-02 2019-11-08 上海西派埃自动化仪表工程有限责任公司 Data reissue method, apparatus, collector and storage medium
CN111666597A (en) * 2020-05-13 2020-09-15 上海微符尔半导体有限公司 On-chip storage method and device for electronic detonator chip

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117742588A (en) * 2023-11-30 2024-03-22 武汉芯必达微电子有限公司 Data storage method and system using Flash simulation EEPROM
CN117742588B (en) * 2023-11-30 2024-06-04 武汉芯必达微电子有限公司 Data storage method and system using Flash simulation EEPROM

Similar Documents

Publication Publication Date Title
US8072197B2 (en) Power-managed socket
CN201041656Y (en) CMOS cleaning circuit
CN103199311B (en) The battery power saving method of portable type electronic product, equipment and mobile terminal
CN102356363B (en) Method and apparatus for controlling distribution of power
CN106877442B (en) Battery management method
CN105204730A (en) Screen control method and user terminal
CN109067416A (en) Method for realizing hot plug and start of SIM card and intelligent hardware
CN106155942A (en) Power-fail memory function device and system thereof
CN114816230A (en) Flash data storage method and device and household appliance
CN101256392A (en) Method, apparatus and equipment for controlling complete closedown of electrical installation
CN111124041A (en) Wearable device control device and method and wearable device
CN107355948B (en) Control method and device of photovoltaic air conditioner
CN112285550B (en) Switch power-off detection method and device, computer equipment and readable storage medium
CN108924366B (en) Low-voltage reminding method and device, electronic equipment and storage medium
CN103647914A (en) Method and device for timed wake-up after television turning-off
CN108107740B (en) Household appliance control method and device
CN115328694A (en) Equipment short-time power failure recovery circuit, electronic equipment and power failure recovery method of electronic equipment
CN116088362A (en) Device micro-power consumption intelligent control device, method, system and medium
US20230135771A1 (en) Fast/slow charging self-adaption method and apparatus, and electronic device
CN111123781B (en) Parameter correction control method, device, small household appliance and storage medium
CN114325481A (en) Power-off duration detection method and device, electronic equipment and storage medium
US20120297228A1 (en) Data recorder for harsh environments
CN113687711A (en) Terminal wake-up circuit and wake-up method
CN112310753B (en) Intelligent socket, control method and control device of intelligent socket
CN110062509B (en) Induction module and intelligent lighting system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination