Method for avoiding data loss and damage applied to intelligent flexible regulation and control device

By employing a two-level voltage monitoring strategy and a hardware delay window mechanism, the main power supply and MCU power supply voltage of the intelligent flexible control device are monitored in a coordinated manner. This solves the problem of data loss and corruption of the MCU under frequent power outages or voltage fluctuations, thereby improving data integrity and system reliability. It is suitable for complex outdoor power environments.

CN121785537APending Publication Date: 2026-04-03HEXING ELECTRICAL CO LTD +4
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-25
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

In environments with frequent power outages or voltage fluctuations, existing intelligent flexible control devices are prone to data loss or damage to MCUs. Existing technologies cannot effectively prevent data inconsistency or storage unit damage caused by low-voltage writes, and simple write-disable strategies may result in the loss of critical information and affect system recovery.

Method used

A two-level voltage monitoring strategy is adopted, which monitors the low voltage of the external main power supply and the core power supply voltage of the MCU in a coordinated manner to ensure data integrity under various power failure scenarios. This includes the first-level protection strategy of detecting Flash operation control when the main power supply fails and the second-level protection strategy of real-time monitoring of the MCU power supply voltage. Combined with hardware delay window and backup power judgment mechanism, it ensures that critical data is stored under safe conditions.

Benefits of technology

It effectively prevents the MCU from performing erase and write operations on the Flash memory under low voltage conditions, ensuring data integrity and system reliability, improving the device's operational stability and anti-interference capabilities in complex power grid environments, extending equipment lifespan, and reducing maintenance risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121785537A_ABST
    Figure CN121785537A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of power electronic control. The invention discloses a method for avoiding data loss and damage applied to an intelligent flexible regulation and control device, which comprises the following steps of: monitoring the power failure of a main power supply through an external circuit at the first stage, and controlling Flash operation according to the state of a standby power supply; the two stages monitor the MCU power supply voltage in real time, reset is triggered once the MCU power supply voltage is lower than a Flash safety operation threshold value, the two stages cooperate to prevent the MCU from erasing and writing Flash under low voltage, and data loss or damage is effectively avoided. According to the invention, through a two-stage voltage monitoring strategy, MCU data loss during power failure or voltage fluctuation of the intelligent flexible regulation and control device is effectively prevented. Primary protection is combined with power failure detection, a delay window and standby power supply judgment to ensure safe storage of key data; and the secondary protection immediately resets the MCU when the power supply is lower than the Flash safety voltage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power electronic control technology, and in particular to a method for avoiding data loss or damage in intelligent flexible control devices. Background Technology

[0002] With the rapid development of smart grids and the energy internet, intelligent flexible control devices are widely used in distribution substations, distributed energy management, and load regulation. These devices are typically deployed outdoors or in environments with complex power supply conditions, facing harsh operating conditions such as voltage fluctuations, frequent power outages, and even instantaneous power failures. As the core control unit, the microcontroller (MCU) needs to process operating data in real time and frequently read and write internal or external Flash memory to save critical information such as configuration parameters, event logs, and operating status.

[0003] Flash memory has strict requirements on power supply voltage; its write and erase operations can only be reliably completed if the specified minimum operating voltage is exceeded. Writing or erasing under insufficient voltage can easily lead to data write failures, damage to memory cells, or even irrecoverable errors affecting the entire storage area. Currently, most devices rely solely on the undervoltage reset function built into the MCU, whose threshold is often lower than the safe operating voltage of the Flash memory, failing to effectively prevent low-voltage writes. While some solutions add power-down detection, they lack dynamic assessment of backup power status and matching of delay windows, making it difficult to balance data security and system continuity.

[0004] In practical applications, if the main power supply is suddenly interrupted without an effective protection mechanism, ongoing Flash operations may be forcibly terminated, causing data inconsistency or program crashes. A simple write-disable strategy, on the other hand, will result in the loss of critical operational information prior to the power outage, affecting subsequent fault diagnosis and system recovery. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention discloses a comprehensive protection method that can collaboratively monitor the main power status and MCU core power supply, intelligently schedule Flash operation timing, and ensure data integrity under various power failure scenarios. This method aims to improve the reliability and safety of intelligent flexible control devices in harsh power environments and prevent data loss or damage in intelligent flexible control devices.

[0006] This invention discloses a method for preventing data loss or damage in intelligent flexible control devices, comprising:

[0007] A two-stage voltage monitoring strategy is adopted:

[0008] The primary protection strategy involves monitoring the AC power supply status through an external main power low-voltage detection circuit. When a main power failure is detected, corresponding Flash operation control is executed based on whether there is an effective backup power supply.

[0009] The secondary protection strategy involves real-time monitoring of the MCU core power supply voltage. When this voltage falls below the Flash safe operation threshold, the MCU is immediately reset.

[0010] The two-level strategy works together to prevent the MCU from performing erase or write operations on the internal or external Flash memory under low voltage conditions, thereby avoiding data loss or damage.

[0011] Furthermore, in the first-level protection strategy, when the external main power low-voltage detection circuit detects an AC power failure signal, if the MCU is not currently performing a Flash erase / write operation, then starting a new erase / write task is prohibited.

[0012] If an erase / write operation is in progress, the current operation is immediately aborted, and the critical runtime data in the cache is written to the non-volatile storage area.

[0013] Furthermore, the hardware power supply design of the intelligent flexible control device provides a power-down delay window, which is defined as the time required from the occurrence of an AC power failure to the MCU power supply voltage dropping to the minimum operating voltage specified in its datasheet. This time is not less than the total time required to complete one minimum unit of Flash erase / write and critical data storage, and a safety margin is reserved.

[0014] Furthermore, the intelligent flexible control device is equipped with a backup power supply;

[0015] After an AC power outage, the system waits for a preset time to confirm whether the backup power supply has been stably activated.

[0016] If the backup power supply voltage is higher than the set threshold, the MCU is allowed to continue performing necessary Flash operations in backup power mode.

[0017] Furthermore, the preset time is 2 seconds;

[0018] During backup power supply, the MCU continuously monitors the backup power supply voltage. Once the voltage drops below the Flash safe operation threshold, all Flash erase and write operations are immediately stopped and the current critical data is saved.

[0019] Furthermore, in the first-level protection strategy, the smallest unit for erasing and writing Flash is a page or a sector, ensuring that atomic writing can be completed within the power-down delay window and avoiding data inconsistency caused by partial writing.

[0020] Furthermore, in the secondary protection strategy, if the MCU chip has a built-in undervoltage reset (BOR) function, the function is enabled, and its reset threshold is configured to be no lower than the higher of the internal Flash and external Flash minimum operating voltage and the minimum voltage required for normal operation of the MCU.

[0021] Furthermore, if the MCU chip does not support the BOR function, or its BOR reset threshold is lower than the minimum safe operating voltage of the Flash, an external voltage monitoring circuit is added; when the MCU power supply voltage is lower than the minimum safe operating voltage of the Flash, the external voltage monitoring circuit outputs a reset signal to force the MCU to reset.

[0022] Furthermore, it is applied to intelligent flexible control devices, which include:

[0023] The main AC power input module, AC-DC conversion module, backup power module, MCU, internal or external Flash memory, external main power low voltage detection circuit (LVD), and MCU power supply voltage monitoring unit.

[0024] Furthermore, the MCU power supply voltage monitoring unit is either a built-in BOR module of the MCU or a separate external voltage monitoring chip, and its output is connected to the MCU's reset pin.

[0025] The beneficial effects of this invention are:

[0026] This invention effectively solves the problem of MCU data loss or corruption in intelligent flexible control devices under frequent power outages or voltage fluctuations through a two-level voltage monitoring strategy. The first-level protection responds quickly when the main power supply fails, combining a hardware delay window and a backup power judgment mechanism to ensure that critical data can be stored safely. The second-level protection monitors the MCU core power supply voltage in real time, immediately resetting the system when the voltage falls below the Flash safe operation threshold, improving data integrity and system reliability.

[0027] This invention employs a hardware-software co-design, making full use of existing MCU resources and external circuits, resulting in a simple structure and controllable cost. Whether relying on a built-in undervoltage reset function or an external monitoring chip, it can flexibly adapt to different main control platforms. Simultaneously, by limiting the minimum write unit of Flash to a page or sector, it ensures atomic writing within a limited power-down sustaining time, avoiding data inconsistencies caused by partial writes.

[0028] This invention enhances the operational stability and anti-interference capability of intelligent flexible control devices in complex power grid environments. Even in the event of a sudden power outage or backup power degradation, the system can automatically save critical data and safely exit, preventing control logic malfunctions, configuration loss, or equipment crashes. This extends equipment lifespan, reduces on-site maintenance risks, and provides a solid technical guarantee for the safe and reliable operation of the power system. Attached Figure Description

[0029] Figure 1 Flowchart of the primary protection strategy for the intelligent flexible control device MCU.

[0030] Figure 2 This is a flowchart of the secondary protection strategy for the intelligent flexible control device MCU. Detailed Implementation

[0031] To enable those skilled in the art to better understand the present invention, the technical solutions in the specific embodiments of the present invention will be clearly and completely described below.

[0032] This invention discloses a method for preventing MCU data loss or damage in intelligent flexible control devices, comprising:

[0033] A two-stage voltage monitoring strategy is adopted:

[0034] The primary protection strategy involves monitoring the AC power supply status through an external main power low-voltage detection circuit. When a main power failure is detected, corresponding Flash operation control is executed based on whether there is an effective backup power supply.

[0035] The secondary protection strategy involves real-time monitoring of the MCU core power supply voltage. When this voltage falls below the Flash safe operation threshold, the MCU is immediately reset.

[0036] The two-level strategy works together to prevent the MCU from performing erase or write operations on the internal or external Flash memory under low voltage conditions, thereby avoiding data loss or damage.

[0037] This invention implements a two-level voltage monitoring mechanism through a combination of hardware and software. The first level of protection involves an external low-voltage detection circuit that monitors the main AC power supply status in real time. Upon detecting a power failure, the system immediately determines whether a valid backup power supply is available and decides whether to allow continued Flash operation or urgently save critical data and then stop writing. The hardware power supply design ensures that even after the main power is disconnected, a sufficiently long delay window is maintained to supply power to the MCU to complete necessary data storage and the smallest unit of erase / write operations, thereby ensuring data consistency.

[0038] Secondary protection focuses on the stability of the MCU's core power supply voltage. Regardless of whether it's powered by mains or backup power, the system immediately triggers a reset mechanism if the MCU's power supply voltage drops below the Flash safety operation threshold. This mechanism relies on the MCU's built-in undervoltage reset function; if it doesn't support this or the threshold is insufficient, a forced reset is achieved through an external voltage monitoring chip. This dual protection effectively prevents the MCU from performing unreliable Flash read / write operations when the voltage is insufficient, preventing data corruption due to low voltage. It enhances the reliability and safety of intelligent flexible control devices in complex power grid environments. It is particularly suitable for outdoor applications with frequent power outages and severe voltage fluctuations, effectively avoiding control anomalies or equipment failures caused by data loss. The overall solution has a simple structure, controllable cost, and strong compatibility, not only extending equipment lifespan but also ensuring the stable operation of the power system.

[0039] As one implementation method, in the first-level protection strategy, when the external main power low-voltage detection circuit detects an AC power failure signal, if the MCU is not currently performing a Flash erase / write operation, then starting a new erase / write task is prohibited.

[0040] If an erase / write operation is in progress, the current operation is immediately stopped. After the stop, the invalid area is marked and verified and repaired after power-on. The critical runtime data in the cache is then written to the non-volatile storage area.

[0041] Power-down response is achieved through hardware signal linkage between an external low-voltage detection circuit and the MCU. When the main power supply voltage drops to a preset threshold, the low-voltage detection chip immediately sends an interrupt or level signal to the MCU. Upon receiving this signal, the MCU quickly enters the power-down process. First, it determines whether the flash is in the erase / write state. If erase / write has not started, flash access is locked directly; if erase / write is in progress, subsequent operations are immediately terminated, and critical operational data not yet saved in the cache is prioritized for writing to the non-volatile storage area to ensure data integrity. To ensure that critical data can be stored within the limited power-down duration, the system's hardware design reserves sufficient power delay capability, such as through large-capacity energy storage capacitors or power management circuits, to continue supplying power to the MCU and Flash for hundreds of milliseconds after an AC power outage. Simultaneously, the software optimizes the data storage path, saving only necessary parameters and avoiding redundant operations, thereby completing safe disk write in a very short time and effectively avoiding data loss or Flash damage caused by sudden power outages. By differentiating erase / write states and adopting differentiated emergency strategies, invalid or dangerous write operations are avoided while retaining critical information for system operation. The power failure handling logic not only enhances the robustness of the intelligent flexible control device, but also provides a reliable data foundation for subsequent power-on recovery and fault diagnosis, effectively reducing operation and maintenance risks and the probability of safety accidents.

[0042] As one implementation, the hardware power supply design of the intelligent flexible control device provides a power-down delay window. This window time is defined as the time required from the occurrence of an AC power failure to the MCU power supply voltage dropping to the minimum operating voltage specified in its datasheet. This time is not less than the total time required to complete one minimum unit of Flash erase / write and critical data storage, and a safety margin is reserved.

[0043] The power-down delay window is achieved by introducing energy storage components and optimizing the power path in the power supply circuit. Sufficient capacity electrolytic capacitors or dedicated energy storage modules are configured on the main power rail after AC-DC conversion. When the AC input is suddenly interrupted, these energy storage components can continue to provide a stable voltage to the MCU and Flash chip. The power management circuit is designed with low quiescent power consumption and fast response characteristics; after the main power is lost, the system voltage drops slowly rather than abruptly, thus buying time for operation.

[0044] The duration of the delay window has been precisely calculated and verified through actual testing to ensure that it covers the entire time required to complete a minimum unit Flash erase / write operation and write critical operational data, while also retaining a certain safety margin to cope with actual operating conditions such as temperature changes, device aging, or load fluctuations. This time is typically in the tens to hundreds of milliseconds range, sufficient to support the complete execution of atomic storage tasks and avoid write failures or memory entering an unrecoverable state due to insufficient voltage. Even in the event of a sudden power outage, the system can still persistently save necessary data before complete loss of control, effectively preventing problems such as configuration loss, metering errors, or control logic disorder. This solution does not rely on complex software scheduling; it achieves highly reliable power-loss protection solely through hardware guarantees, offering advantages such as low cost, high stability, and strong compatibility, making it suitable for various outdoor power terminal equipment.

[0045] As one implementation method, the intelligent flexible control device is equipped with a backup power supply;

[0046] After an AC power outage, the system waits for a preset time to confirm whether the backup power supply has been stably activated.

[0047] If the backup power supply voltage is higher than the set threshold, the MCU is allowed to continue performing necessary Flash operations in backup power mode.

[0048] Seamless power supply transition is achieved by integrating a backup power module into the intelligent flexible control device, along with power switching and voltage monitoring circuitry. When the main AC power fails, the system first relies on the energy stored before the main power failure to maintain operation briefly, while simultaneously initiating the backup power activation process. During this period, the MCU suspends write operations to the Flash memory and enters a waiting state, continuously monitoring whether the backup power output voltage rises steadily within a preset time and exceeds a safety threshold to confirm that it has reliably taken over the power supply task.

[0049] The preset waiting time is typically set to two seconds, providing sufficient startup and voltage stabilization time for the backup power supply while avoiding excessive delays that could impact system response. Once the backup power supply voltage is detected to be higher than the minimum threshold required for safe Flash operation, the MCU determines that the current power supply environment meets the data writing conditions, re-enables Flash operation, and continues to complete previously interrupted or newly generated critical data storage tasks. The entire process is controlled collaboratively by a hardware voltage comparator and software logic, ensuring accurate decision-making and timely action. Compared to solutions relying on power-down delays, introducing a backup power supply not only extends the system's uptime but also supports the continued execution of necessary tasks during power outages, such as event logging, remote reporting, or parameter updates. Voltage threshold judgment avoids risky Flash writes when the backup power supply is unstable, balancing functional continuity and data security, and enhancing the adaptability and operational stability of the intelligent flexible control device in complex power environments.

[0050] As one implementation method, the preset time can be set according to the type of backup power supply, with a typical value of 2 seconds, in order to take into account the startup stabilization time of most lead-acid batteries or lithium battery modules.

[0051] During backup power supply, the MCU continuously monitors the backup power supply voltage. Once the voltage drops below the Flash safe operation threshold, all Flash erase and write operations are immediately stopped and the current critical data is saved.

[0052] By setting a fixed two-second wait window in the MCU software and combining it with a hardware voltage monitoring circuit, the status of the backup power supply is dynamically evaluated. After an AC power failure, the system enters the backup power confirmation phase. The MCU starts an internal timer to begin counting, continuously reading the backup power supply voltage value during this period. If the voltage stabilizes and exceeds the preset safe operating threshold within two seconds, the backup power supply is deemed available, and the Flash writing function is restored; if it does not meet the threshold, it is considered an backup power failure, and the system immediately enters the data protection process.

[0053] During backup power supply, the MCU samples the backup power output voltage in real time using a built-in ADC or an external voltage detection chip and compares it with the minimum safe operating voltage specified in the Flash device datasheet. Once the voltage drops below this threshold, the system immediately interrupts all ongoing erase / write tasks and prioritizes writing critical operating parameters, event logs, or configuration information from the cache to the non-volatile storage area. A two-second wait time balances the physical characteristics of backup power startup with system response efficiency, avoiding misjudgments caused by instantaneous voltage fluctuations; continuous voltage monitoring forms a second line of defense, preventing irreversible storage damage when backup power is insufficient. The entire solution requires no manual intervention, automatically completing the entire process from judgment and execution to protection. It is suitable for intelligent power terminals deployed in unattended environments for extended periods, effectively reducing operational risks and the probability of data loss.

[0054] As one implementation method, in the first-level protection strategy, the smallest unit of erasing and writing Flash is a page or a sector, ensuring that atomic writing can be completed within the power-down delay window and avoiding data inconsistency caused by partial writing.

[0055] By strictly limiting the minimum granularity of Flash operations at the software level to match the hardware power-down delay window, the system organizes all critical information into data blocks of no more than one page or one sector during the data storage logic design, ensuring that each write operation is performed only on this smallest erasable unit. When a power-down signal is triggered, the MCU prioritizes completing the full programming flow of the current page or sector without initiating a new erase / write task, thus guaranteeing an indivisible atomic write within the limited power supply duration. The physical characteristics of Flash chips dictate that erasure and writing must be based on pages or sectors; partial writes not only fail to take effect but may also leave the memory cell in an uncertain state. This solution fully utilizes this characteristic, actively aligning operation boundaries during the power-down process to avoid cross-page writes or interruptions. The delay window provided by the power supply circuit has been calculated to be sufficient to cover the worst-case duration of a single page / sector erase / write operation, ensuring that a complete and effective storage operation can be completed even during a sustained voltage drop. By limiting write operations to atomic units, the system will not leave behind partially written invalid data even in the event of a sudden power outage, thus guaranteeing the integrity and recoverability of the stored content. This improves the operational reliability of the intelligent flexible control device under harsh power supply conditions, simplifies the self-test and recovery logic after power-on, reduces software complexity, and provides a solid foundation for long-term stable operation.

[0056] As one implementation, in the secondary protection strategy, if the MCU chip has a built-in undervoltage reset function, the function is enabled, and its reset threshold is configured to be no lower than the higher of the internal Flash and external Flash minimum operating voltage and the minimum voltage required for normal operation of the MCU.

[0057] Real-time monitoring of the core power supply voltage is achieved by configuring the MCU's internal undervoltage reset function. During system initialization, the software determines the higher of the internal and external Flash devices' datasheets to obtain the lowest safe operating voltage. This, combined with the MCU's minimum operating voltage required for normal operation, is used as the maximum value among the three as the BOR reset threshold. This function is then enabled by writing to a specific register, causing the MCU to automatically trigger a reset when the power supply voltage drops to this threshold, thus preventing abnormal operation under low voltage. This ensures that the MCU will not continue operating under conditions where the voltage is insufficient to support reliable Flash read / write operations, regardless of power supply fluctuations. Since erasing or writing Flash below its minimum operating voltage can easily lead to data corruption or permanent failure of the storage unit, setting the BOR threshold above the safe boundary fundamentally eliminates this risk. The reset action is performed directly by hardware, resulting in a fast response time, no software intervention required, and extremely high reliability. This fully utilizes the MCU's built-in resources, avoiding additional circuit costs while enhancing the system's self-protection capabilities against power supply anomalies. In outdoor power environments with frequent power outages or unstable voltage, the active reset strategy effectively prevents program crashes, data errors, or equipment malfunctions caused by voltage drops, enhancing the stability and lifespan of intelligent flexible control devices.

[0058] As one implementation, if the MCU chip does not support the BOR function, or its BOR reset threshold is lower than the minimum safe operating voltage of the Flash, an external voltage monitoring circuit is added; when the MCU power supply voltage is lower than the minimum safe operating voltage of the Flash, the external voltage monitoring circuit outputs a reset signal to force the MCU to reset.

[0059] The inadequacy of the MCU's own undervoltage protection is compensated by adding a dedicated external voltage monitoring chip to the circuit board. This monitoring chip's detection threshold is precisely set to be no lower than the minimum safe operating voltage required by the internal or external Flash devices, and it is directly connected to the MCU's reset pin. When the system power supply drops below this threshold due to power failure, voltage drops, or other abnormal reasons, the monitoring chip immediately outputs a valid reset signal, forcing the MCU into a reset state, thereby preventing it from continuing to execute programs or access Flash memory under unreliable voltage conditions.

[0060] External voltage monitoring circuits typically employ high-precision, low-latency dedicated reset ICs, possessing anti-interference capabilities and stable temperature characteristics to ensure accurate response to voltage changes under various environmental conditions. Their operation is independent of the MCU software state; even if the MCU malfunctions due to voltage instability, the circuit can still independently perform a reset. Hardware-level protection mechanisms and primary power-down protection strategies complement each other, jointly constructing a dual safety guarantee system covering the entire voltage range.

[0061] For cost-sensitive or functionally limited MCU models, voltage protection capabilities meeting Flash operation requirements can be obtained without replacing the main control chip. Since the reset action is forcibly triggered by external hardware, protection failures caused by software freezes or interrupts are avoided. The overall implementation is simple, low-cost, and fast-responding, making it particularly suitable for intelligent flexible control devices deployed long-term at the end of the power grid under complex power supply conditions, effectively preventing data corruption and system crashes.

[0062] This application provides a method for preventing MCU data loss or damage in intelligent flexible control devices, focusing on two core scenarios that easily lead to data anomalies: low-voltage operation of the MCU's Flash memory. Specifically, it includes two core processes: first, protection of the MCU when the intelligent flexible control device experiences an AC power outage; and second, protection of the MCU when its power supply voltage is unstable. These two processes are described below with reference to the corresponding accompanying drawings.

[0063] In this application, please refer to Figure 1 , Figure 1 The flowchart for the first-level protection strategy of the intelligent flexible control device MCU can specifically include the following steps:

[0064] 1. The LVD circuit monitors the external main power to determine if the terminal is in normal working condition. This detection circuit mainly consists of a voltage detection chip. Its working principle is as follows: the AC-DC circuit converts AC power into 12V main power. The voltage detection chip monitors the main power. When the AC power fails, causing the 12V main voltage to drop to 10V, the detection chip's feedback pin is pulled low, and the MCU executes a protection strategy. 2. Upon detecting a power failure signal, determine if the MCU is executing the erase / write function. 3. Determine if the erase / write has started. 4. If not, exit the erase / write function. 5. If the erase / write has started, only erase the smallest unit of Flash memory. 6. Finally, save important data in the cache. The data storage time is provided by hardware with a delay time. This delay time is from the AC power failure to the time the MCU power supply drops to the threshold voltage required by the specifications. It should satisfy the time required to store necessary data and the time required for one erase / write operation, with a margin. The time for the intelligent flexible control device can be set to 200ms. 7. After waiting 2 seconds, determine if the backup power system is working. 8. If the backup power is working normally, determine if the MCU needs to erase / write Flash memory at this time. 9. Perform the erase / write operation and monitor the backup power voltage. 10. When the backup power voltage is less than or equal to the set value. 11. Stop erasing / writing the Flash memory and save important data.

[0065] In this application, please refer to Figure 2 , Figure 2 The flowchart for the secondary protection strategy of the intelligent flexible control device MCU can be summarized as follows:

[0066] 1. Confirm that the MCU internally supports BOR and that the reset voltage is lower than the minimum operating voltage of the Flash memory. 2. If step 1 is not met, an external MCU power monitoring circuit is required. 3. Determine if the supply voltage is lower than the set voltage. 4. If a voltage drop below the set voltage is detected, immediately reset the MCU to prevent low-voltage operation of the Flash memory, which could lead to data loss or corruption.

[0067] It should be understood that those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A method for preventing data loss or damage in an intelligent flexible control device, characterized in that, include: A two-stage voltage monitoring strategy is adopted: The primary protection strategy involves monitoring the AC power supply status through an external main power low-voltage detection circuit. When a main power failure is detected, corresponding Flash operation control is executed based on whether there is an effective backup power supply. The secondary protection strategy involves real-time monitoring of the MCU core power supply voltage. When this voltage falls below the Flash safe operation threshold, the MCU is immediately reset. The two-level strategy works together to prevent the MCU from performing erase or write operations on the internal or external Flash memory under low voltage conditions, thereby avoiding data loss or damage.

2. The method for avoiding data loss or damage in an intelligent flexible control device according to claim 1, characterized in that: In the first-level protection strategy, when the external main power low-voltage detection circuit detects an AC power failure signal, if the MCU is not currently performing a Flash erase / write operation, then starting a new erase / write task is prohibited. If an erase / write operation is in progress, the current operation is immediately aborted, and the critical runtime data in the cache is written to the non-volatile storage area.

3. The method for avoiding data loss or damage in an intelligent flexible control device according to claim 2, characterized in that: The hardware power supply design of the intelligent flexible control device provides a power-down delay window, which is defined as the time required from the occurrence of an AC power failure to the MCU power supply voltage dropping to the minimum operating voltage specified in its datasheet. This time is not less than the total time required to complete one minimum unit of Flash erase / write and critical data storage, and a safety margin is reserved.

4. The method for avoiding data loss or damage in an intelligent flexible control device according to claim 3, characterized in that: The intelligent flexible control device is equipped with a backup power supply; After an AC power outage, the system waits for a preset time to confirm whether the backup power supply has been stably activated. If the backup power supply voltage is higher than the set threshold, the MCU is allowed to continue performing necessary Flash operations in backup power mode.

5. The method for avoiding data loss or damage in an intelligent flexible control device according to claim 4, characterized in that: The preset time is 2 seconds; During backup power supply, the MCU continuously monitors the backup power supply voltage. Once the voltage drops below the Flash safe operation threshold, all Flash erase and write operations are immediately stopped and the current critical data is saved.

6. The method for avoiding data loss or damage in an intelligent flexible control device according to claim 1, characterized in that: In the Level 1 protection strategy, the smallest unit of writing to Flash is a page or a sector, ensuring that atomic writing can be completed within the power-down delay window and avoiding data inconsistency caused by partial writing.

7. The method for avoiding data loss or damage in an intelligent flexible control device according to claim 1, characterized in that: In the secondary protection strategy, if the MCU chip has a built-in undervoltage reset (BOR) function, the function is enabled and its reset threshold is configured to be no lower than the higher of the internal Flash and external Flash minimum operating voltage and the minimum voltage required for normal operation of the MCU.

8. The method for avoiding data loss or damage in an intelligent flexible control device according to claim 7, characterized in that: If the MCU chip does not support the BOR function, or its BOR reset threshold is lower than the minimum safe operating voltage of the Flash, an external voltage monitoring circuit is added; when the MCU power supply voltage is lower than the minimum safe operating voltage of the Flash, the external voltage monitoring circuit outputs a reset signal to force the MCU to reset.

9. The method for avoiding data loss or damage in an intelligent flexible control device according to claim 1, characterized in that: Applied to intelligent flexible control devices, which include: The main AC power input module, AC-DC conversion module, backup power module, MCU, internal or external Flash memory, external main power low voltage detection circuit (LVD), and MCU power supply voltage monitoring unit.

10. A method for avoiding data loss or damage in an intelligent flexible control device according to claim 9, characterized in that: The MCU power supply voltage monitoring unit is either a built-in BOR module of the MCU or an independent external voltage monitoring chip, and its output is connected to the reset pin of the MCU.