A method and device for detecting low power consumption mode of MCU

By setting the initial value and backup value in the MCU, combined with peripheral register changes, the accuracy problem of MCU's low-power mode detection is solved, and accurate detection of different low-power modes and internal module control verification are achieved.

CN117930960BActive Publication Date: 2024-12-03GEEHY SEMICON CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410016062.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-03
Publication Date
2024-12-03
Estimated Expiration
2044-01-03

AI Technical Summary

Technical Problem

In the prior art, the detection of MCU low-power mode cannot achieve accuracy, and it is especially impossible to determine which low-power mode is, and whether the control of the internal module in the corresponding mode is operating normally, resulting in the inability to widely use switching and detection.

Method used

By setting the predefined initial value in memory, calculating and backing up different values, when the MCU switches from the conventional operating mode to the low-power mode and then switches back to the conventional operating mode, the numerical difference is judged, and the changes in peripheral registers are combined. The low power mode detection result is obtained.

Benefits of technology

Accurate detection of low-power mode switching is realized, which can distinguish different low-power modes, verify whether the internal module is turned off, and determine which low-power mode is entered.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117930960B_ABST
    Figure CN117930960B_ABST
Patent Text Reader

Abstract

The present invention discloses a MCU low-power mode detection method and device, the detection method includes, based on a predefined initial value, setting a memory, the memory is a storage device with data volatility characteristics in a low-power state, calculating a second value different from the predefined initial value, and backing up the second value and storing it in a backup domain, the value backed up in the backup domain is a third value, in response to the MCU switching from a normal operation mode to a low-power mode, and then from the low-power mode to a normal operation mode, judging the difference between the second value and the third value after the switching change, obtaining a difference result, and obtaining the MCU low-power mode detection result based at least on the difference result and the peripheral register value of the MCU. Using the MCU low-power detection method of the present invention, it is possible to simply and accurately verify whether each internal module of the MCU is normally shut down, and it is possible to judge which low-power mode the MCU has entered, and to achieve accurate detection of the corresponding low-power mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of chip technology, and in particular to a method and device for detecting a low power consumption mode of an MCU. Background Art

[0002] The design of MCU will be combined with different application scenarios to design low-power modes with different power consumption levels, which can be mainly divided into normal working mode, sleep mode (SLEEP), stop mode (STOP) and standby mode (STANDBY mode). In the early design stage of MCU, it is necessary to fully verify the low-power mode switching of the design to ensure the integrity of the low-power mode switching function of the design. MCU enters low-power mode to reduce power consumption by turning off internal components such as core clock, peripheral clock, clock source, memory, etc.

[0003] In the existing scheme of low-power mode switching, usually, the host computer sends instructions to make the MCU enter different low-power modes, monitor the current consumption and status signals of the MCU in these modes, and then wake up the MCU to return to the normal working mode, and monitor the status signals and current consumption again. By comparing the status signals and current consumption of the MCU in low-power mode and normal working mode, it is judged whether the low-power mode switching of the MCU is normal. The test results will be fed back to the host computer for display. However, the low-power mode in the prior art cannot achieve accurate detection, especially it is impossible to determine which low-power mode it is, and whether the control of the internal module in the corresponding mode is operating normally. When the accuracy cannot be achieved, the low-power mode switching and detection of the prior art cannot be widely used in practice. Summary of the invention

[0004] In order to improve the accuracy of MCU low power mode detection in the prior art, according to one aspect of the present invention, a method for detecting MCU low power mode is provided, the detection method comprising:

[0005] A memory is set based on a predefined initial value, wherein the memory is a storage device having a data volatility characteristic in a low power consumption state,

[0006] A second value different from the predefined initial value is calculated by a calculation model, and the second value is backed up and stored in a backup domain, wherein the value backed up in the backup domain is a third value.

[0007] In response to the MCU switching from the normal operation mode to the low power consumption mode and then from the low power consumption mode to the normal operation mode, the difference between the second value and the third value after the switching change is determined to obtain a difference result,

[0008] The MCU also includes a peripheral register, and the peripheral register pre-stores a peripheral register value.

[0009] The MCU low power consumption mode detection result is obtained based at least on the difference result and the MCU peripheral register value.

[0010] In some embodiments, the memory is a static random access memory and a synchronous dynamic random access memory.

[0011] In some implementations, setting the memory based on a predefined initial value specifically includes storing the predefined initial value in any storage space in the memory.

[0012] In some embodiments, in response to the MCU switching from the normal operation mode to the low power consumption mode and then from the low power consumption mode to the normal operation mode, the difference between the second value and the third value after the switching change is determined to obtain a difference result, specifically including: responding to the MCU switching from the normal operation mode to the low power consumption mode, staying in the low power consumption mode for a first preset time, and then switching from the low power consumption mode to the normal operation mode, determining the difference between the second value and the third value after the switching change, and obtaining a difference result.

[0013] In some implementations, the calculation model completes the calculation based on the operating time in the normal operating mode before switching to the low power consumption mode.

[0014] In some embodiments, the calculation of a second numerical value different from the predefined initial value specifically includes, before the MCU switches from the normal operating mode to the low power consumption mode, based on a rule of performing an accumulation operation every second preset time, taking the predefined initial value as the base value, calculating a second numerical value associated with the normal operating state time.

[0015] In some implementations, the backup domain is an RTC backup register or a backup SRAM.

[0016] In some embodiments, the MCU low power mode detection result is obtained at least based on the difference result and the MCU peripheral register value, specifically including obtaining the MCU low power mode detection result based on the difference result, the MCU peripheral register value and the system clock state after switching from the low power mode to the normal operation mode.

[0017] In some embodiments, based on the difference result, the MCU peripheral register value, and the internal clock state after switching from low power consumption mode to normal operation mode, the MCU low power consumption mode detection result is obtained, specifically including that the difference result is the same, the MCU peripheral register value is a reset value, and it is judged that the sleep mode switching of the MCU is normal.

[0018] In some embodiments, based on the difference result, the MCU peripheral register value, and the internal clock state after switching from low power consumption mode to normal operation mode, the MCU low power consumption mode detection result is obtained, specifically including that the difference result is the same, the MCU peripheral register value is not a reset value, the MCU system clock is an internal high-speed clock, and it is judged that the MCU stop mode switch is normal.

[0019] In some embodiments, based on the difference result, the MCU peripheral register value, and the internal clock state after switching from low power consumption mode to normal operation mode, the MCU low power consumption mode detection result is obtained, specifically including: the difference result is different, the MCU peripheral register value is not a reset value, the MCU system clock is an internal high-speed clock, and it is judged that the MCU power-off mode switching is normal.

[0020] A second aspect of the present invention provides a MCU low power consumption mode detection device, the detection device comprising:

[0021] a setting unit, which sets a memory based on a predefined initial value, wherein the memory is a storage device having a data volatility characteristic in a low power consumption state,

[0022] a calculation unit, calculating a second value different from the predefined initial value,

[0023] The backup unit stores the second value backup in the backup domain, wherein the value backed up in the backup domain is the third value,

[0024] The judging unit judges the difference between the second value and the third value after the switching change in response to the switching of the MCU from the normal operation mode to the low power consumption mode and then from the low power consumption mode to the normal operation mode, and obtains a difference result.

[0025] The detection unit obtains the MCU low power consumption mode detection result based on at least the difference result and the MCU peripheral register value.

[0026] The third aspect of the present invention provides an MCU chip, including a processor and a memory, wherein the memory stores a computer program that can be executed by the processor, and the processor can execute the computer program to implement the low power consumption mode detection method as described in any one of the first aspects of the present invention.

[0027] Beneficial effects of the present invention:

[0028] The MCU low-power mode detection method of the present invention sets a predefined initial value and stores it in a memory, calculates a second value different from the predefined initial value, backs up the second value and stores it in a backup domain, the value backed up in the backup domain is a third value, responds to the switching of the MCU from the normal operation mode to the low-power mode and then from the low-power mode to the normal operation mode, judges the difference between the second value and the third value after the switching change, obtains a difference result, and obtains the MCU low-power mode detection result based at least on the difference result and the MCU peripheral register value. By cleverly comparing the second value stored in different low-power modes with the third value of the backup domain, and coordinating the changes of the peripheral registers in different low-power modes, accurate detection of low-power mode switching is achieved, different low-power modes can be detected and distinguished, and verification of whether the internal module is closed during low-power mode switching is achieved, and judgment of which low-power mode is also achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 This is a schematic diagram of the process flow of a method for detecting a low power consumption mode of an MCU according to a first embodiment of the present invention;

[0030] Figure 2 This is a schematic flow chart of a method for detecting a low power consumption mode of an MCU according to a second embodiment of the present invention;

[0031] Figure 3 This is a schematic diagram of a MCU low power consumption mode detection device according to a third embodiment of the present invention; DETAILED DESCRIPTION

[0032] The present invention is further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0033] It should be noted that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0034] In the present invention, unless otherwise clearly specified and limited, the terms "installation", "connection", "fixation" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral one; it can be a mechanical connection, an electrical connection, or communication with each other; it can be a direct connection, or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0035] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.

[0036] In the above description, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0037] Embodiment 1:

[0038] As attached Figure 1 As shown, it is a schematic flow chart of the MCU low power mode detection method of the first embodiment of the present invention. The MCU low power mode detection method in the embodiment of the present invention is applied to the MCU chip. The MCU chip is the abbreviation of the microcontroller unit, which is a central processing unit (CPU) with appropriately reduced frequency and specifications, and integrates the memory, counter, USB, A / D conversion, UART, PLC, DMA and other functional modules on a single chip to form a chip-level microcontroller computer.

[0039] The current MCU design combines the functional characteristics of different usage scenarios, designs different work number modes, and arranges them from high to low according to power consumption. It has four working modes: normal operation mode, sleep mode, stop mode and standby mode. After power-on reset, the MCU is in operation. When the core does not need to continue running, it can choose to enter the following three low-power modes to reduce power consumption. In these three modes, the power consumption, wake-up time and wake-up source are different. Users need to choose the best low-power mode according to application requirements. In the current prior art, the low-power mode switching is usually to send instructions through the host computer to make the MCU enter different low-power modes, and monitor the current consumption and status signals of the MCU in these modes, and then wake up the MCU back to the normal working mode, and monitor the status signal and current consumption again. By comparing the status signal and current consumption of the MCU in the low-power mode and the normal working mode, it is judged whether the low-power mode switching of the MCU is normal. The detection method of low power mode in the prior art cannot achieve accurate detection. In particular, the prior art verifies whether the low power consumption of the MCU is normal by detecting the change in current when the MCU enters the low power consumption mode. The verification of whether the internal module is turned off is not detailed and accurate enough. Specifically, it is unable to confirm which IP circuits enter low power consumption and which IP circuits do not enter low power consumption through the change in current. At the same time, the above-mentioned prior art cannot specifically determine which low power consumption mode to enter by "verifying whether the internal module is turned off".

[0040] In view of the above problems in the existing MCU low power mode detection, a first embodiment of the present invention provides an MCU low power mode detection method, which is applied to an MCU chip. The detection method is that the MCU chip responds to external detection instructions and executes the detection and judgment steps by itself.

[0041] The detection method comprises:

[0042] Step S100, setting a memory based on a predefined initial value, wherein the memory is a storage device having a data volatility characteristic in a low power consumption state;

[0043] The predefined initial value in the embodiment of the present invention may be any preset non-zero value, and the preset method may be that the MCU is automatically generated based on the calculation rules in the program pre-burned in the MCU chip before leaving the factory and stored in the memory, or a pre-set non-zero value may be set and stored in the memory through a pre-burned program. Since in different low-power modes, the variables stored in the storage component after wake-up will be reset to zero after power failure, setting a non-zero defined initial value can facilitate subsequent detection and judgment.

[0044] The memory is a storage device with data transmission characteristics in a low power state, such as static random access memory (SRAM) and synchronous dynamic random access memory (SDRAM). In this mode, due to power interruption or significant reduction, the data in the storage unit cannot be maintained, resulting in data loss. The memory is set based on a predefined initial value, specifically including storing the predefined initial value in any storage space in the memory. It should be noted that the predefined initial value setting memory, one implementation method is to select a certain address of the memory to store the predefined initial value, and record the storage address of the memory for addressing in the subsequent method flow.

[0045] Step S101, calculate a second value different from the predefined initial value through a calculation model, and store the second value in a backup domain, wherein the value backed up in the backup domain is a third value. The MCU normal operation mode is a normal operation mode of the MCU.

[0046] In an embodiment of the present invention, in the normal working mode of the chip, any program that can calculate the predefined initial value stored in the memory can obtain a second value, and the second value is the value after the predefined initial value is processed by the calculation model; the calculation model processing can be any calculation method or calculation model that obtains a second value different from the predefined initial value, as long as a second value different from the defined initial value can be obtained. A preferred and convenient implementation method can select a calculation method based on the predefined initial value and the elapsed time for increment, and the calculated second value can be stored in the same memory as the defined initial value. In different low-power modes, the variables stored in the storage component after awakening will be reset to zero after power failure. For detection and judgment, the second value will be backed up and stored in the backup domain, and the backup value in the backup domain will be recorded as the third value. The value backed up in the backup domain is the third value and can provide reference data for subsequent detection and judgment.

[0047] In an embodiment of the present invention, the backup domain is a backup storage area that can be protected to prevent write access caused by accidental power failure or mode switching. Certain special operating steps must be strictly executed to access it, so that normal data storage can be maintained in low power consumption mode. In an optional manner in the embodiment, the backup domain includes an RTC backup register or a backup SRAM.

[0048] Step S102, in response to the MCU switching from the normal operation mode to the low power consumption mode and then from the low power consumption mode to the normal operation mode, determining the difference between the second value and the third value after the switching change to obtain a difference result.

[0049] After completing the above-mentioned storage of the predefined initial value, the calculation and storage of the second value, and the third value obtained after the backup storage in the backup domain, in order to detect the switching of the MCU low power mode, the MCU chip responds to the switching instruction, switches from the normal operation mode, that is, the normal operation mode to the low power mode, and after running in the low power mode, switches from the low power mode to the normal operation mode to obtain the second value after the switching change. In this switching process, since the second value is stored in areas such as static random access memory (SRAM) and synchronous dynamic random access memory (SDRAM), the switching of the low power mode at any time may cause the second value after the switching change to be different from the calculated value and the predefined value. The original second numerical values ​​with different initial values ​​are the same or different. Therefore, the difference between the second numerical value after the switch change and the third numerical value is judged to obtain a difference result. In this way, in the low power consumption mode, the 1.2V area power supply is not turned off in the sleep mode and the stop mode, and the SRAM is not powered off. Therefore, the second numerical value after the switch is no different from the third numerical value of the backup domain. In the standby mode, the 1.2V area power supply is also turned off, resulting in the power off of the SRAM. Therefore, there is a difference between the second numerical value after the switch and the third numerical value of the backup domain. By judging the difference between the second numerical value after the switch and the third numerical value, accurate detection and judgment of the low power consumption state in the above two specific modes in the low power consumption mode can be achieved.

[0050] In the embodiment of the present invention, the MCU further includes a peripheral register, and the peripheral register pre-stores a peripheral register value.

[0051] Step S103, obtaining an MCU low power consumption mode detection result based at least on the difference result and the MCU peripheral register value.

[0052] Considering that the difference judgment of the second value field and the third value after the switch change can only obtain the basic detection of the above two situations, and the sleep mode and the stop mode cannot be distinguished and detected, the embodiment of the present invention is set to obtain the MCU low power mode detection result based on at least the difference result and the MCU peripheral register value. Since in the sleep mode, only the core clock is turned off, the core stops running, and the on-chip peripherals and the core peripherals are still running normally, the peripheral register is a reset value, and in the stop mode and the standby mode, all clocks are turned off and the peripherals stop working, and the peripheral register is a non-reset value, wherein the so-called reset value refers to the default value stored in the register when the register is not operated. In one implementation, the reset value of the peripheral register can be 0x4444 4444.

[0053] The effective effect of the MCU low power mode detection method in the first embodiment of the present invention is to set a predefined initial value and store it in a memory, calculate a second value different from the predefined initial value, and back up the second value and store it in a backup domain. The value backed up in the backup domain is a third value. In response to the switching of the MCU from the normal operation mode to the low power mode and then from the low power mode to the normal operation mode, the difference between the second value and the third value after the switching change is judged to obtain a difference result, and the MCU low power mode detection result is obtained at least based on the difference result and the MCU peripheral register value. By cleverly comparing the second value stored in different low power modes with the third value of the backup domain, and coordinating the changes of the peripheral registers in different low power modes, accurate detection of low power mode switching is achieved, and different low power modes can be detected and distinguished, and verification of whether the internal module is turned off during low power mode switching is achieved, and also judgment of which low power mode is achieved.

[0054] Embodiment 2:

[0055] In the MCU low power mode detection method of the second embodiment of the present invention, in addition to the two judgment factors of the difference result and the MCU peripheral register value, the MCU low power mode detection result is obtained based on the system clock state after the MCU switches from the low power mode to the normal operation mode. Specifically, the MCU low power mode detection method in the second embodiment includes:

[0056] Step S200: Setting a memory based on a predefined initial value, wherein the memory is a storage device having data volatility characteristics in a low power consumption state; the memory can be selectively set to a static random access memory or a synchronous dynamic random access memory.

[0057] Step S201: Calculate a second value different from the predefined initial value, and back up and store the second value in a backup domain, wherein the value backed up in the backup domain is a third value;

[0058] Step S202: responding to the MCU switching from the normal operation mode to the low power consumption mode, staying in the low power consumption mode for a preset time, and then switching from the low power consumption mode to the normal operation mode, determining the difference between the second value and the third value after the switching change, and obtaining a difference result;

[0059] In the second embodiment of the present invention, in response to the switching of the MCU from the normal operation mode to the low power mode and then from the low power mode to the normal operation mode, the difference between the second value and the third value after the switching change is judged to obtain the difference result, specifically including: responding to the MCU switching from the normal operation mode to the low power mode, staying in the low power mode for a preset time, and then switching from the low power mode to the normal operation mode, judging the difference between the second value and the third value after the switching change, and obtaining the difference result. Combined with step S201, after setting the first preset time to stay in the low power mode, and then switching to the normal operation mode, the first preset time can be based on the actual working state of the MCU, without affecting the normal operation and low power mode functions, so that the interval between the two modes can be reacted and recognized by the machine and selected by technicians in this field.

[0060] In the second embodiment, S201 can be set so that the calculation model completes the calculation based on the running time in the normal operation mode before switching to the low power consumption mode, or it can be set to before the MCU switches from the normal operation mode to the low power consumption mode, based on the rule of performing an accumulation operation every second preset time, with the predefined initial value as the base value, to calculate the second value associated with the normal operation state time.

[0061] As a preferred implementation, S201 is specifically configured to include, before the MCU switches from the normal operation mode to the low power consumption mode, based on the rule of performing an addition operation every 1 second, taking the predefined initial value as the base value, calculating a second value associated with the normal operation state time. By setting the calculation rule of the second value different from the predefined initial value and the calculation rule associated with the stay time in the low power consumption mode in the step, the low power consumption mode stay process can be associated, the independence of each MCU detection is increased, and the detection failure caused by the external control algorithm loophole is prevented, while being simple and feasible.

[0062] Step S203: Based on the difference result, the MCU peripheral register value and the system clock state after switching from the low power consumption mode to the normal operation mode, the MCU low power consumption mode detection result is obtained.

[0063] Specifically, in the second embodiment of the present invention, for the sleep mode in the low power consumption mode, the MCU low power consumption mode detection result is obtained based on the difference result, the MCU peripheral register value and the internal clock state after switching from the low power consumption mode to the normal operation mode, specifically including that the difference result is the same, the MCU peripheral register value is the reset value, and it is judged that the sleep mode switching of the MCU is normal.

[0064] In the second embodiment of the present invention, for the stop mode in the low power mode, based on the difference result, the MCU peripheral register value and the internal clock state after the low power mode to the normal operation mode, the MCU low power mode detection result is obtained, specifically including that the difference result is the same, the MCU peripheral register value is not a reset value, the MCU system clock is an internal high-speed clock, and the MCU stop mode switching is judged to be normal. In the second embodiment of the present invention, for the disconnect mode in the low power mode, based on the difference result, the MCU peripheral register value and the internal clock state after the low power mode to the normal operation mode, the MCU low power mode detection result is obtained, specifically including that the difference result is different, the MCU peripheral register value is not a reset value, the MCU system clock is an internal high-speed clock, and the MCU disconnect mode switching is judged to be normal. In this embodiment, preferably, the MCU system clock is N times the internal high-speed clock.

[0065] In the embodiment of the present invention, the MCU turns off the core clock, most peripheral clocks, PLL, internal high-speed oscillator, external high-speed oscillator, and the data in the SRAM will be lost in combination with the stop mode and the standby mode. The difference between the second value and the third value after the switching change, the MCU peripheral register value, and the detection result of the MCU system clock are selected to comprehensively judge the switching result of the stop mode in the low power consumption mode, which increases the detection accuracy and solves the defect that the prior art cannot detect which of the three modes in the low power consumption mode is entered.

[0066] The beneficial effects of the MCU low power mode detection method in embodiment 2 of the present invention are based on the beneficial effects of embodiment 1. In addition, when judging the low power mode detection result, in addition to the difference between the second value and the third value after the switching change and the value of the peripheral register, the system clock state after the MCU switches from the low power mode to the normal operation mode is added, which can more accurately judge the sleep mode and the stop mode, thereby achieving more detailed and accurate detection.

[0067] The MCU low power mode detection method in the second embodiment of the present invention is different from that in the first embodiment of the present invention except for the above-mentioned differences. Other steps, functions and effects of the same implementation method are the same. Since any implementation method of each specific step in the above-mentioned first embodiment is described in detail, it will not be repeated here.

[0068] Embodiment three:

[0069] The MCU low power mode detection method in the present invention can also be applied to the collaborative control of multiple subjects to complete the entire detection process, that is, it can be applied to the multi-subject execution process. For example, the MCU low power mode detection method in the third embodiment of the present invention is applied to the collaborative control process of the MCU unit and the external detection device. Specifically, the MCU low power mode detection method specifically includes:

[0070] Step S301: the MCU unit sets a memory based on a predefined initial value, the memory being a storage device having a data volatility characteristic in a low power consumption state;

[0071] Step S302: the MCU unit calculates a second value different from the predefined initial value, and stores the second value in a backup domain, wherein the value backed up in the backup domain is a third value;

[0072] It should be noted that in the third embodiment of the present invention, step S302 can also be selectively partially completed by an external detection device, that is, the external detection device calculates a second value different from the predefined initial value based on a preset calculation rule in the normal operation mode of the MCU, and stores the second value in the memory of the MCU. At the same time, the MCU backs up the second value and stores it in the backup domain, and the value backed up in the backup domain is the third value;

[0073] Step S303: the MCU unit responds to the switching of the MCU from the normal operation mode to the low power consumption mode and then from the low power consumption mode to the normal operation mode, determines the difference between the second value and the third value after the switching change, and obtains a difference result.

[0074] It should be noted that in the third embodiment of the present invention, step S303 can also be selectively completed by an external detection device, and the external detection device determines the difference between the second value field and the third value after the switching change to obtain a difference result. In the implementation of the external detection device completing step S303, the MCU and the external detection device need to respond to each other's instructions to complete the corresponding data transmission and operation steps.

[0075] Step S304: the MCU unit obtains the MCU low power consumption mode detection result based at least on the difference result and the MCU peripheral register value.

[0076] It should be noted that in the third embodiment of the present invention, step S303 can also be selectively completed by an external detection device, and the external detection device determines the difference between the second value field and the third value after the switching change to obtain a difference result. In the implementation of the external detection device completing step S303, the MCU and the external detection device need to respond to each other's instructions to complete the corresponding data transmission and operation steps.

[0077] The beneficial effects of the MCU low power mode detection method of embodiment 3 of the present invention are based on the beneficial effects of embodiments 1 and 2. Its various method steps can be applied to the collaboration between an external detection device and an MCU unit, thus achieving more actual application scenarios and greater configuration flexibility.

[0078] The MCU low power mode detection method in the third embodiment of the present invention has the same steps, functions and effects as those in the first embodiment of the present invention except for the different descriptions of the execution subject. Since any implementation method of each specific step in the first embodiment is described in detail, it will not be repeated here.

[0079] Embodiment 4:

[0080] Attached Figure 3 Schematic diagram of a low power consumption mode detection device for MCU according to a fourth embodiment of the present invention, as shown in the attached figure Figure 3 As shown, the MCU low power consumption mode detection device 400 according to the fourth embodiment of the present invention includes:

[0081] The setting unit 401 sets a memory based on a predefined initial value, wherein the memory is a storage device having a data volatility characteristic in a low power consumption state,

[0082] The calculation unit 402 calculates a second value different from the predefined initial value,

[0083] The backup unit 403 stores the second value backup in the backup domain, wherein the value backed up in the backup domain is the third value.

[0084] The judging unit 404 judges the difference between the second value and the third value after the switching change in response to the switching of the MCU from the normal operation mode to the low power consumption mode and then from the low power consumption mode to the normal operation mode, and obtains a difference result.

[0085] The detection unit 405 obtains the MCU low power consumption mode detection result based on at least the difference result and the MCU peripheral register value.

[0086] In addition to processing the above-mentioned function implementation, each functional unit in the MCU low power mode detection device in the embodiment of the present invention can also complete the steps, functions and effects of any one of the implementation methods of the MCU low power mode detection method described in Embodiments 1 to 3 of the present invention. Since any one of the implementation methods of each specific step in the above Embodiments 1 to 3 has been recorded in detail, the description is not repeated here. The correspondence between any one of the implementation methods and the setting unit 401, the calculation unit 402, the backup unit 403, the judgment unit 404, and the detection unit 405 in the MCU low power mode detection device shall be based on the description of each step of the MCU low power mode detection method in Embodiments 1 to 3 of the present invention.

[0087] An embodiment of the present invention also discloses an MCU chip by way of example, wherein the MCU chip includes a processor and a memory, wherein the memory stores a computer program that can be executed by the processor, and the processor can execute the computer program to implement the MCU low power consumption mode detection method as described in any one of Embodiments 1 to 3 of the present invention.

[0088] In addition to processing the above steps, the method for executing instructions by a processor in an electronic device of the present invention can also complete the steps, functions and effects of any implementation of the MCU low power mode detection method in any one of Embodiments 1 to 3 of the present invention. Since any implementation of each specific step in any one of Embodiments 1 to 3 above is described in detail, it will not be repeated here.

[0089] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0090] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0091] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for detecting low power consumption mode of MCU, It is characterized in that The detection method comprises: A memory is set based on a predefined initial value, wherein the memory is a storage device having a data volatility characteristic in a low power consumption state, A second value different from the predefined initial value is calculated by a calculation model, and the second value is backed up and stored in a backup domain, where the value backed up in the backup domain is a third value. In response to the MCU switching from the normal operation mode to the low power consumption mode and then from the low power consumption mode to the normal operation mode, the difference between the second value and the third value after the switching change is determined to obtain a difference result, The MCU also includes a peripheral register, and the peripheral register pre-stores a peripheral register value. The MCU low power consumption mode detection result is obtained based at least on the difference result and the peripheral register value.

2. The low power mode detection method according to claim 1, It is characterized in that The method responds to the switching of the MCU from the normal operation mode to the low power consumption mode and then from the low power consumption mode to the normal operation mode, determines the difference between the second value and the third value after the switching change, and obtains the difference result. Specifically, it responds to the switching of the MCU from the normal operation mode to the low power consumption mode, stays in the low power consumption mode for a first preset time, and then switches from the low power consumption mode to the normal operation mode, determines the difference between the second value and the third value after the switching change, and obtains the difference result.

3. The low power mode detection method according to claim 1, It is characterized in that The calculation model completes the calculation based on the running time in the normal running mode before switching to the low power consumption mode.

4. The low power mode detection method according to claim 3, It is characterized in that The calculation of a second value different from the predefined initial value specifically includes, before the MCU switches from the normal operation mode to the low power consumption mode, based on the rule of performing an accumulation operation every second preset time, taking the predefined initial value as the base value, calculating a second value associated with the normal operation state time.

5. The low power mode detection method according to claim 1, It is characterized in that The backup domain is an RTC backup register or a backup SRAM.

6. The low power mode detection method according to claim 1, It is characterized in that The MCU low power mode detection result is obtained at least based on the difference result and the MCU peripheral register value, specifically including: obtaining the MCU low power mode detection result based on the difference result, the MCU peripheral register value and the system clock state after switching from the low power mode to the normal operation mode.

7. The low power consumption mode detection method according to claim 1 or 6, It is characterized in that Based on the difference result, the MCU peripheral register value and the internal clock state after switching from low power consumption mode to normal operation mode, the MCU low power consumption mode detection result is obtained, specifically including that the difference result is the same, the MCU peripheral register value is the reset value, and it is judged that the sleep mode switching of the MCU is normal.

8. The low power consumption mode detection method according to claim 7, It is characterized in that Based on the difference result, the MCU peripheral register value and the internal clock state after switching from low power consumption mode to normal operation mode, the MCU low power consumption mode detection result is obtained, specifically including that the difference result is the same, the MCU peripheral register value is not a reset value, the MCU system clock is an internal high-speed clock, and it is judged that the MCU stop mode switching is normal.

9. The low power consumption mode detection method according to claim 7, It is characterized in that Based on the difference result, the MCU peripheral register value and the internal clock state after switching from low power consumption mode to normal operation mode, the MCU low power consumption mode detection result is obtained, specifically including: the difference result is different, the MCU peripheral register value is not a reset value, the MCU system clock is an internal high-speed clock, and it is judged that the MCU standby mode switching is normal.

10. A MCU low power mode detection device, It is characterized in that include, a setting unit, which sets a memory based on a predefined initial value, wherein the memory is a storage device having a data volatility characteristic in a low power consumption state, a calculation unit, which calculates a second value different from the predefined initial value through a calculation model, The backup unit stores the second value backup in the backup domain, wherein the value backed up in the backup domain is the third value, The judging unit judges the difference between the second value and the third value after the switching change in response to the switching of the MCU from the normal operation mode to the low power consumption mode and then from the low power consumption mode to the normal operation mode, and obtains a difference result. The MCU also includes a peripheral register, and the peripheral register pre-stores a peripheral register value. The detection unit obtains the MCU low power consumption mode detection result based on at least the difference result and the peripheral register value.