CN117930960A - A method and device for detecting low power consumption mode of MCU - Google Patents
A method and device for detecting low power consumption mode of MCU Download PDFInfo
- Publication number
- CN117930960A CN117930960A CN202410016062.5A CN202410016062A CN117930960A CN 117930960 A CN117930960 A CN 117930960A CN 202410016062 A CN202410016062 A CN 202410016062A CN 117930960 A CN117930960 A CN 117930960A
- Authority
- CN
- China
- Prior art keywords
- low power
- mcu
- power consumption
- value
- mode
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims description 30
- 238000001514 detection method Methods 0.000 claims abstract description 104
- 230000002093 peripheral effect Effects 0.000 claims abstract description 52
- 230000008859 change Effects 0.000 claims abstract description 27
- 230000004044 response Effects 0.000 claims abstract description 10
- 238000004364 calculation method Methods 0.000 claims description 25
- 238000009825 accumulation Methods 0.000 claims description 3
- 238000013461 design Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 7
- 230000009286 beneficial effect Effects 0.000 description 5
- 230000000694 effects Effects 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 238000004590 computer program Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 230000003068 static effect Effects 0.000 description 4
- 230000001360 synchronised effect Effects 0.000 description 4
- 101100233916 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) KAR5 gene Proteins 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 3
- 238000012795 verification Methods 0.000 description 3
- 238000010586 diagram Methods 0.000 description 2
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 1
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 1
- 101100012902 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) FIG2 gene Proteins 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3234—Power saving characterised by the action undertaken
- G06F1/3293—Power saving characterised by the action undertaken by switching to a less power-consuming processor, e.g. sub-CPU
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3234—Power saving characterised by the action undertaken
- G06F1/324—Power saving characterised by the action undertaken by lowering clock frequency
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3234—Power saving characterised by the action undertaken
- G06F1/325—Power saving in peripheral device
- G06F1/3275—Power saving in memory, e.g. RAM, cache
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Power Sources (AREA)
Abstract
Description
技术领域Technical Field
本发明涉及芯片技术领域,尤其涉及一种MCU低功耗模式检测方法、装置。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 technique
MCU的设计会结合不同的应用场景,设计不同功耗等级的低功耗模式,主要可分为正常工作模式,睡眠模式(SLEEP),停止模式(STOP)以及待机模式(STANDBY模式)等。在MCU的前期设计阶段,需要对设计的低功耗模式切换进行完整的验证,以确保设计的低功耗模式切换功能的完整无误。MCU通过关闭内核时钟、外设时钟、时钟源、存储器等内部部件来进入低功耗模式,降低功耗。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.
低功耗模式切换的现有方案中通常是,通过上位机发送指令,使MCU进入不同的低功耗模式,并监测MCU在这些模式下的电流消耗和状态信号,然后唤醒MCU回到正常工作模式,再次监测状态信号和电流消耗。通过比较MCU在低功耗模式和正常工作模式下的状态信号和电流消耗,判断MCU的低功耗模式切换是否正常。测试结果将反馈至上位机显示。但现有技术中低功耗模式无法实现精准性检测,尤其是无法判断具体是哪个低功耗模式,以及对应模式下内部模块的控制是否正常运行,在精准性无法完成的情况下造成了现有技术低功耗模式切换和检测无法在实际中得到广泛应用。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
为了解决现有技术MCU低功耗模式检测的精准性,根据本发明的一个方面,提供了一种MCU低功耗模式检测方法,所述检测方法包括,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:
基于预定义的初始值设置存储器,所述存储器为具备在低功耗状态下具有数据挥发特性的存储设备,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, wherein the value backed up in the backup domain is a third value.
响应于MCU从常规运行模式至低功耗模式、再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果,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,
所述MCU还包括外设寄存器,所述外设寄存器预存外设寄存器数值,The MCU also includes a peripheral register, and the peripheral register pre-stores a peripheral register value.
至少基于所述差异结果以及所述MCU外设寄存器数值得到MCU低功耗模式检测结果。The MCU low power consumption mode detection result is obtained based at least on the difference result and the MCU peripheral register value.
在一些实施方式中,所述存储器为静态随机访问存储器和同步动态随机访问存储器。In some embodiments, the memory is a static random access memory and a synchronous dynamic random access memory.
在一些实施方式中,所述基于预定义的初始值设置存储器,具体包括,在所述存储器中任一存储空间存储所述预定义的初始值。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.
在一些实施方式中,所述响应于MCU从常规运行模式至低功耗模式、再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果,具体包括,响应与MCU从常规运行模式至低功耗模式,停留低功耗模式第一预设时间后,再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果。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.
在一些实施方式中,所述计算模型完成基于低功耗模式切换前在常规运行模式下运行时间进行的计算。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.
在一些实施方式中,所述计算与所述预定义的初始值不同的第二数值,具体包括,在MCU从常规运行模式切换至低功耗模式之前,基于每隔第二预设时间执行一次累加运算的规则,以所述预定义的初始值为基础值,计算得到与常规运行状态时间关联的第二数值。In some embodiments, the calculation of the 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 the 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.
在一些实施方式中,所述备份域为RTC备份寄存器或者备份SRAM。In some implementations, the backup domain is an RTC backup register or a backup SRAM.
在一些实施方式中,所述至少基于所述差异结果以及所述MCU外设寄存器数值得到MCU低功耗模式检测结果,具体包括,基于所述差异结果、所述MCU外设寄存器数值以及所述从低功耗模式至常规运行模式后的系统时钟状态,得到MCU低功耗模式检测结果。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.
在一些实施方式中,基于所述差异结果、所述MCU外设寄存器数值以及所述从低功耗模式至常规运行模式后的内部时钟状态,得到MCU低功耗模式检测结果,具体包括,所述差异结果为相同,所述MCU外设寄存器数值为复位数值,判断所述MCU的睡眠模式切换正常。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.
在一些实施方式中,基于所述差异结果、所述MCU外设寄存器数值以及所述从低功耗模式至常规运行模式后的内部时钟状态,得到MCU低功耗模式检测结果,具体包括,所述差异结果为相同,所述MCU外设寄存器数值不是复位数值,所述MCU系统时钟为内部高速时钟,判断所述MCU停止模式切换正常。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.
在一些实施方式中,基于所述差异结果、所述MCU外设寄存器数值以及所述从低功耗模式至常规运行模式后的内部时钟状态,得到MCU低功耗模式检测结果,具体包括,所述差异结构为不同,所述MCU外设寄存器数值不是复位数值,所述MCU系统时钟为内部高速时钟,判断所述MCU开断模式切换正常。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 structure 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.
本发明第二方面提供了一种MCU低功耗模式检测装置,所述检测装置包括,A second aspect of the present invention provides a MCU low power consumption mode detection device, the detection device comprising:
设置单元,基于预定义的初始值设置存储器,所述存储器为具备在低功耗状态下具有数据挥发特性的存储设备,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, calculating a second value different from the predefined initial value,
备份单元,将第二数值备份存储在备份域,所述在备份域备份的数值为第三数值,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,
判断单元,响应于MCU从常规运行模式至低功耗模式、再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果,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.
检测单元,至少基于所述差异结果以及所述MCU外设寄存器数值得到MCU低功耗模式检测结果。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.
本发明第三方面提供了一种MCU芯片,包括了处理器及存储器,所述存储器存储有能够被所述处理器执行的计算机程序,所述处理器可执行所述计算机程序,以实现如上述本发明第一方面任一项所述的低功耗模式检测方法。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.
本发明的有益效果:Beneficial effects of the present invention:
本发明MCU低功耗模式检测方法,通过设置预定义的初始值并存储在存储器中,计算与所述预定义的初始值不同的第二数值,将第二数值备份存储在备份域中,在备份域备份的数值为第三数值,响应于MCU从常规运行模式至低功耗模式、再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果,至少基于所述差异结果以及所述MCU外设寄存器数值得到MCU低功耗模式检测结果。巧妙地通过不同低功耗模式下存储的第二数值和备份域第三数值的比较,配合外设寄存器在不同低功耗模式下的变化,实现了低功耗模式切换的准确检测,能够检测区分出不同的低功耗模式,实现了低功耗模式切换中内部模块是否关闭的验证,同时也实现了哪个低功耗模式的判断。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 also judgment of which low-power mode is achieved.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为本发明实施例一的MCU低功耗模式检测方法流程示意图;FIG1 is a schematic flow chart of a method for detecting a low power consumption mode of an MCU according to a first embodiment of the present invention;
图2为本发明实施例二的MCU低功耗模式检测方法流程示意图;FIG2 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;
图3为本发明实施例三的MCU低功耗模式检测装置示意图;FIG3 is a schematic diagram of a MCU low power consumption mode detection device according to a third embodiment of the present invention;
具体实施方式Detailed ways
下面结合附图对本发明作进一步详细的说明,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。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, rather than 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.
需要说明的是,术语“第一”、“第二”等仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。在本发明的描述中,“多个”的含义是至少两个,例如两个,三个等,除非另有明确具体的限定。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.
在本发明中,除非另有明确的规定和限定,术语“安装”、“连接”、“固定”等术语应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或成一体;可以是机械连接,也可以是电连接或彼此可通讯;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通或两个元件的相互作用关系,除非另有明确的限定。对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本发明中的具体含义。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.
在本发明中,除非另有明确的规定和限定,第一特征在第二特征“上”或“下”可以是第一和第二特征直接接触,或第一和第二特征通过中间媒介间接接触。而且,第一特征在第二特征“之上”、“上方”和“上面”可是第一特征在第二特征正上方或斜上方,或仅仅表示第一特征水平高度高于第二特征。第一特征在第二特征“之下”、“下方”和“下面”可以是第一特征在第二特征正下方或斜下方,或仅仅表示第一特征水平高度小于第二特征。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.
在以上描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。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.
实施例一:Embodiment 1:
如附图1所示,为本发明实施例一的MCU低功耗模式检测方法流程示意图。本发明实施例中MCU低功耗模式检测方法,应用于MCU芯片,MCU芯片是微控制单元(Microcontroller Unit)的简称,是把中央处理器(Central Process Unit;CPU)的频率与规格做适当缩减,并将内存(memory)、计数器(Timer)、USB、A/D转换、UART、PLC、DMA等功能模组都整合在单一芯片上,形成芯片级的微控计算机。As shown in Figure 1, it is a 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, which is the abbreviation of the microcontroller unit, and is a chip-level microcontroller computer formed by appropriately reducing the frequency and specifications of the central processing unit (CPU), and integrating the memory, timer, USB, A/D conversion, UART, PLC, DMA and other functional modules on a single chip.
当前的MCU设计结合了不同使用场景下的功能特点,设计了不同的工号模式,按功耗由高到低排列,具有运行常规运行模式、睡眠模式、停止模式和待机模式四种工作模式。上电复位后MCU处于运行状态,当内核不需要继续运行,就可以选择进入后面的三种低功耗模式降低功耗,这三种模式中,电源消耗不同、唤醒时间不同、唤醒源不同,用户需要根据应用需求,选择最佳的低功耗模式。当前现有技术中关于低功耗模式切换通常是,通过上位机发送指令,使MCU进入不同的低功耗模式,并监测MCU在这些模式下的电流消耗和状态信号,然后唤醒MCU回到正常工作模式,再次监测状态信号和电流消耗。通过比较MCU在低功耗模式和正常工作模式下的状态信号和电流消耗,判断MCU的低功耗模式切换是否正常。现有技术中的检测方法低功耗模式无法实现精准性检测,尤其是现有技术通过检测MCU进入低功耗模式电流的变化来验证MCU的低功耗是否正常,对内部模块是否关闭验证不够细致和准确,具体的无法通过电流的变化确认哪些IP电路进入低功耗,哪些IP电路没有进入低功耗,同时上述现有技术不能通过“验证内部模块是否关闭”从而具体判断进入哪种低功耗模式。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".
针对现有MCU低功耗模式检测中的上述问题,本发明实施例一提供了一种MCU低功耗模式检测方法,应用于MCU芯片,所述检测方法为MCU芯片响应于外部检测指令,自行执行完成的检测和判断步骤。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.
所述检测方法包括,The detection method comprises:
步骤S100,基于预定义的初始值设置存储器,所述存储器为具备在低功耗状态下具有数据挥发特性的存储设备;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;
本发明实施例中预定义的初始值可以是预设的任一非零数值,预设的方式可以是在MCU芯片出厂预先烧制的程序中基于计算规则由MCU自动生成并存储在存储器中,也可以是将预先人为设置好的一个非零数值通过预先烧制的程序设置并存储在存储器中。由于在不同低功耗模式下,唤醒后的存储部件中存储的变量会掉电归零,设置非0的定义的初始值能够方便的实现后续检测判断。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 is 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.
其中所述存储器为具备在低功耗状态下具有数据会发特性的存储设备,例如静态随机访问存储器(SRAM)和同步动态随机访问存储器(SDRAM),在这种模式下,由于供电中断或显著降低,无法维持存储单元中的数据,从而发生数据丢失。所述基于预定义的初始值设置存储器,具体包括,在所述存储器中任一存储空间存储所述预定义的初始值。需要说明的是,预定义的初始值设置存储器,一种实现方式为,选取存储器某一地址存储该预定义的初始值,并记录该存储器的存储地址用于后续方法流程中寻址使用。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.
步骤S101,通过计算模型计算与所述预定义的初始值不同的第二数值,并将第二数值备份存储在备份域,所述在备份域备份的数值为第三数值。所述MCU常规运行模式为MCU的正常工作模式。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.
本发明实施例中,在芯片正常工作模式下进行任意可以对所述在存储器存储的预定义的初始值的程序计算得到第二数值,所述第二数值是所述预定义的初始值进行计算模型处理后的数值;该计算模型处理可以为任意得到与预定义的初始值不同的第二数值的计算方法或计算模型,只要能够得到与定义的初始值不同的第二数值即可,一种优选便捷的实施方式,可以选择基于预定义的初始值和经历时间进行递增的计算方式,并且计算得到的第二数值可以存储在与定义的初始值一样的存储器中。在不同低功耗模式下,唤醒后的存储部件中存储的变量会掉电归零,对于检测判断来说,将将第二数值备份存储在备份域,将所述在备份域的备份数值记作第三数值,所述在备份域备份的数值为第三数值能够为后续检测判断提供基准数据。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.
本发明实施例中,所述备份域所述备份域为能够收到保护的备份存储区域,以防止意外掉电或者模式切换等带来的写访问,必须严格的执行某些特殊操作步骤才能够进行访问,因此能够在低功耗模式下保持数据的正常存储,实施例中一种可选的方式所述备份域包括RTC备份寄存器或者备份SRAM。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.
步骤S102,响应于MCU从常规运行模式至低功耗模式、再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果。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, the difference between the second value and the third value after the switching change is determined to obtain a difference result.
完成上述预定义初始值存储、第二数值的计算存储,以及在备份域的备份存储后得到的第三数值后,为了能够检测MCU低功耗模式的切换,所述MCU芯片响应于切换指令,从常规运行模式即正常工作模式切换至低功耗模式,在低功耗模式运行后,再从低功耗模式切换至常规运行模式,得到切换变化后的第二数值,在这个切换过程,由于第二数值存储在诸如静态随机访问存储器(SRAM)和同步动态随机访问存储器(SDRAM)区域,因此随时低功耗模式的切换,切换变化后的第二数值有可能与计算得到的与所述预定义的初始值不同的原始第二数值一样或者不一样,因此,将切换变化后的第二数值与第三数值进行差异判断,得到差异结果,这样能结合低功耗模式下,睡眠模式、停止模式下1.2V区域电源并未关闭,SRAM并未掉电,因此切换后的第二数值与备份域的第三数值并没有差异,而在待机模式下由于1.2V区域电源也进行了关闭,导致SRAM掉电,因此切换后的第二数值与备份域的第三数值存在差异,通过判断切换后的第二数值与第三数值的差异情况,能够实现低功耗模式下上述两种具体模式下的低功耗状态式准确的检测判断。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 low power mode is switched at any time, and the second value after the switching change may 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 SRAM power off. 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.
本发明实施例中,所述MCU还包括外设寄存器,所述外设寄存器预存外设寄存器数值。In the embodiment of the present invention, the MCU further includes a peripheral register, and the peripheral register pre-stores a peripheral register value.
步骤S103,至少基于所述差异结果以及所述MCU外设寄存器数值得到MCU低功耗模式检测结果。Step S103, obtaining an MCU low power consumption mode detection result based at least on the difference result and the MCU peripheral register value.
考虑到将切换变化后的第二数值域第三数值进行差异判断,仅能得到上述两种情况的基本检测,并不能够将睡眠模式和停止模式进行区分检测,本发明实施例设置了至少基于所述差异结果以及所述MCU外设寄存器数值得到MCU低功耗模式检测结果。由于在睡眠模式下,仅仅关闭了内核时钟,内核停止运行,在片上外设,核心的外设还正常运行,因此,外设寄存器为复位数值,而在停止模式和待机模式下均由于关闭了所有时钟,外设停止了工作,所述外设寄存器非复位数值,其中所谓的复位数值,就是指如果没有操作这个寄存器时,寄存器存放的默认值,一种实施方式中,外设寄存器的复位数值可以为0x4444 4444。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.
本发明实施例一中MCU低功耗模式检测方法的有效效果,通过设置预定义的初始值并存储在存储器中,计算与所述预定义的初始值不同的第二数值,将第二数值备份存储在备份域中,在备份域备份的数值为第三数值,响应于MCU从常规运行模式至低功耗模式、再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果,至少基于所述差异结果以及所述MCU外设寄存器数值得到MCU低功耗模式检测结果。巧妙地通过不同低功耗模式下存储的第二数值和备份域第三数值的比较,配合外设寄存器在不同低功耗模式下的变化,实现了低功耗模式切换的准确检测,能够检测区分出不同的低功耗模式,实现了低功耗模式切换中内部模块是否关闭的验证,同时也实现了哪个低功耗模式的判断。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 store the second value backup in the 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.
实施例二:Embodiment 2:
本发明实施例二MCU低功耗模式检测方法中,除了所述差异结果、所述MCU外设寄存器数值两个判断因素外,还基于所述MCU从低功耗模式切换至常规运行模式后的系统时钟状态,得到MCU低功耗模式检测结果,具体的,实施例二中所述MCU低功耗模式检测方法包括,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:
步骤S200:基于预定义的初始值设置存储器,所述存储器为具备在低功耗状态下具有数据挥发特性的存储设备;所述存储器可以选择设置为静态随机访问存储器或同步动态随机访问存储器。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.
步骤S201:计算与所述预定义的初始值不同的第二数值,并将第二数值备份存储在备份域,所述在备份域备份的数值为第三数值;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;
步骤S202:响应与MCU从常规运行模式至低功耗模式,停留低功耗模式预设时间后,再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果;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;
本发明实施例二中,所述响应于MCU从常规运行模式至低功耗模式、再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果,具体包括,响应与MCU从常规运行模式至低功耗模式,停留低功耗模式预设时间后,再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果。结合步骤S201,在设置了在低功耗模式停留第一预设时间后,再切换至常规运行模式,所述第一预设时间可根据MCU实际工作状态,在不影响正常运行和低功耗模式功能的情况下,能够实现两种模式之间间隔被机器反应并识别出由本领域技术人员选择设置。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 and set by those skilled in the art.
实施例二中S201可设置为,所述计算模型完成基于低功耗模式切换前在常规运行模式下运行时间进行的计算,也可以设置为在MCU从常规运行模式切换至低功耗模式之前,基于每隔第二预设时间执行一次累加运算的规则,以所述预定义的初始值为基础值,计算得到与常规运行状态时间关联的第二数值。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.
作为一种优选的实施方式,S201具体设置为包括,在MCU从常规运行模式切换至低功耗模式之前,基于每隔1s执行一次加1运算的规则,以所述预定义的初始值为基础值,计算得到与常规运行状态时间关联的第二数值。通过设置计算与所述预定义的初始值不同的第二数值规则与在步骤在低功耗模式停留时间相关联的计算规则,能够将结合低功耗模式停留过程关联,增加了每个MCU检测的独立性,防止了外部控制算法漏洞带来的检测失败,同时简单可行。As a preferred embodiment, 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 1s, 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.
步骤S203:基于所述差异结果、所述MCU外设寄存器数值以及所述从低功耗模式至常规运行模式后的系统时钟状态,得到MCU低功耗模式检测结果。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.
具体地,本发明实施例二中,对于低功耗模式中睡眠模式,基于所述差异结果、所述MCU外设寄存器数值以及所述从低功耗模式至常规运行模式后的内部时钟状态,得到MCU低功耗模式检测结果,具体包括,所述差异结果为相同,所述MCU外设寄存器数值为复位数值,判断所述MCU的睡眠模式切换正常。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.
本发明实施例二中,对于低功耗模式中停止模式,基于所述差异结果、所述MCU外设寄存器数值以及所述从低功耗模式至常规运行模式后的内部时钟状态,得到MCU低功耗模式检测结果,具体包括,所述差异结果为相同,所述MCU外设寄存器数值不是复位数值,所述MCU系统时钟为内部高速时钟,判断所述MCU停止模式切换正常。本发明实施例二中,对于低功耗模式中开断模式,基于所述差异结果、所述MCU外设寄存器数值以及所述从低功耗模式至常规运行模式后的内部时钟状态,得到MCU低功耗模式检测结果,具体包括,所述差异结构为不同,所述MCU外设寄存器数值不是复位数值,所述MCU系统时钟为内部高速时钟,判断所述MCU开断模式切换正常。本实施例中,优选地,所述MCU系统时钟为N倍的内部高速时钟。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 it is judged that the MCU stop mode switching is 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 structure 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 disconnect mode switching is normal. In this embodiment, preferably, the MCU system clock is N times the internal high-speed clock.
本发明实施例中结合停止模式下和待机模式下,MCU关闭内核时钟、大部分外设时钟、PLL、内部高速振荡器、外部高速振荡器、SRAM中的数据会丢失的特性,选择了所述切换变化后的第二数值与第三数值的差异、所述MCU外设寄存器数值、所处MCU系统时钟的检测结果综合判断低功耗模式中停止模式的切换结果,增加了检测精准性的同时,实现了现有技术无法检测低功耗模式下三种模式具体是进入了哪一种的缺陷。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 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.
本发明实施例二MCU低功耗模式检测方法的有益效果在实施例一的有益效果基础上,还在判断低功耗模式检测结果时,除了基于切换变化后的第二数值与第三数值的差异、所述外设寄存器数值外,加入了所述MCU从低功耗模式切换至常规运行模式后的系统时钟状态,能够更加精准判断出睡眠模式和停止模式,实现了更细致和更准确的检测。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.
本发明实施例二MCU低功耗模式检测方法与本发明实施例1中除了上述不同外,其他存在相同的实现方式的步骤、功能及效果,由于在上述实施例1中各个具体步骤的任意一种实现方式均进行了详细的记载,同样此处不在重复描述,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 implementation steps, functions and effects 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.
实施例三:Embodiment three:
本发明中MCU低功耗模式检测方法同样可以适用于多主体协同控制完成整个检测过程,即可适用于多主体执行过程。如本发明实施例三中MCU低功耗模式检测方法应用于所述MCU单元与外部检测设备协同控制过程,具体地,所述MCU低功耗模式检测方法,具体包括: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:
步骤S301:所述MCU单元基于预定义的初始值设置存储器,所述存储器为具备在低功耗状态下具有数据挥发特性的存储设备;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;
步骤S302:所述MCU单元计算与所述预定义的初始值不同的第二数值,并将第二数值备份存储在备份域,所述在备份域备份的数值为第三数值;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;
需要说明的是,在本发明实施例三中,步骤S302同样可以选择性的部分由外部检测设备完成,即外部检测设备在MCU常规运行模式下,基于预设的计算规则计算与所述预定义的初始值不同的第二数值,并将第二数值存储在MCU的存储器中,同时,所处MCU将第二数值备份存储在备份域,所述在备份域备份的数值为第三数值;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;
步骤S303:所述MCU单元响应于MCU从常规运行模式至低功耗模式、再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果。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.
需要说明的是,在本发明实施例三中,步骤S303同样可以选择性的由外部检测设备完成,所述外部检测设备判断切换变化后的第二数值域第三数值的差异,得到差异结果。该由外部检测设备完成步骤S303的实施方式中,所述MCU需与外部检测设备需要响应于相互的指令,完成对应的数据传输和操作步骤。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.
步骤S304:所述MCU单元至少基于所述差异结果以及所述MCU外设寄存器数值得到MCU低功耗模式检测结果。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.
需要说明的是,在本发明实施例三中,步骤S303同样可以选择性的由外部检测设备完成,所述外部检测设备判断切换变化后的第二数值域第三数值的差异,得到差异结果。该由外部检测设备完成步骤S303的实施方式中,所述MCU需与外部检测设备需要响应于相互的指令,完成对应的数据传输和操作步骤。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.
本发明实施例三MCU低功耗模式检测方法的有益效果在实施例一和实施例二有益效果的基础上,其各方法步骤能够适用于外部检测设备与MCU单元协同完成,实现了实际更多应用场景和更大的配置灵活性。The beneficial effects of the MCU low power mode detection method in embodiment 3 of the present invention are based on the beneficial effects of embodiments 1 and 2. Each method step 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.
本发明实施例三MCU低功耗模式检测方法与本发明实施例1中除了上述执行主体的不同说明外,其他存在相同的实现方式的步骤、功能及效果,由于在上述实施例1中各个具体步骤的任意一种实现方式均进行了详细的记载,同样此处不在重复描述,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.
实施例四:Embodiment 4:
附图3为本发明实施例四MCU低功耗模式检测装置示意图,如附图3所示,本发明实施例四MCU低功耗模式检测装置400包括:FIG3 is a schematic diagram of a low power consumption mode detection device for MCU according to a fourth embodiment of the present invention. As shown in FIG3 , the low power consumption mode detection device 400 for MCU according to the fourth embodiment of the present invention includes:
设置单元401,基于预定义的初始值设置存储器,所述存储器为具备在低功耗状态下具有数据挥发特性的存储设备,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,
计算单元402,计算与所述预定义的初始值不同的第二数值,The calculation unit 402 calculates a second value different from the predefined initial value,
备份单元403,将第二数值备份存储在备份域,所述在备份域备份的数值为第三数值,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.
判断单元404,响应于MCU从常规运行模式至低功耗模式、再从低功耗模式至常规运行模式的切换,判断切换变化后的第二数值与第三数值的差异,得到差异结果,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.
检测单元405,至少基于所述差异结果以及所述MCU外设寄存器数值得到MCU低功耗模式检测结果。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.
本发明实施例中MCU低功耗模式检测装置中各功能单元处理上述功能实现外,同时能够完成本发明实施例一到实施例三中所述MCU低功耗模式检测方法任意一种实现方式的步骤、功能及效果,由于在上述实施例一到实施例三中各个具体步骤的任意一种实现方式均进行了详细的记载,此处不在重复描述,任意一种实现方式与MCU低功耗模式检测装置中设置单元401、计算单元402、备份单元403、判断单元404、检测单元405的对应关系,均按照本发明实施例一到实施例三关于所述MCU低功耗模式检测方法各个步骤描述对应为准。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.
本发明实施例还示例公开了一种MCU芯片,所述MCU芯片包括了处理器及存储器,所述存储器存储有能够被所述处理器执行的计算机程序,所述处理器可执行所述计算机程序,以实现如本发明实施例一到实施例三任一项所述的MCU低功耗模式检测方法。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.
本发明电子设备中处理器执行指令执行的方法处理上述步骤外,同时能够完成本发明实施例一到实施例三任一项中MCU低功耗模式检测方法任意一种实现方式的步骤、功能及效果,由于在上述实施例一到实施例三任一项中各个具体步骤的任意一种实现方式均进行了详细的记载,同样此处不在重复描述,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.
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。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. Those of ordinary skill in the art may understand and implement it without creative work.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。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.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。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 (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410016062.5A CN117930960B (en) | 2024-01-03 | 2024-01-03 | MCU low-power mode detection method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410016062.5A CN117930960B (en) | 2024-01-03 | 2024-01-03 | MCU low-power mode detection method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN117930960A true CN117930960A (en) | 2024-04-26 |
CN117930960B CN117930960B (en) | 2024-12-03 |
Family
ID=90760683
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410016062.5A Active CN117930960B (en) | 2024-01-03 | 2024-01-03 | MCU low-power mode detection method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117930960B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105577969A (en) * | 2014-11-04 | 2016-05-11 | 佳能株式会社 | INFORMATION PROCESSING APPARATUS and CONTROL METHOD FOR THE SAME |
CN112198865A (en) * | 2020-09-29 | 2021-01-08 | 中电海康无锡科技有限公司 | Testing method, device and system for MCU low-power mode switching |
CN115509340A (en) * | 2021-06-07 | 2022-12-23 | 中移物联网有限公司 | Low-power-consumption management method of operating system, operating system and terminal |
CN115774484A (en) * | 2023-02-13 | 2023-03-10 | 苏州聚元微电子股份有限公司 | Low-power consumption management system of TOUCH MCU |
WO2023070890A1 (en) * | 2021-10-31 | 2023-05-04 | 歌尔股份有限公司 | Working mode control method for wearable device, wearable device, and medium |
-
2024
- 2024-01-03 CN CN202410016062.5A patent/CN117930960B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105577969A (en) * | 2014-11-04 | 2016-05-11 | 佳能株式会社 | INFORMATION PROCESSING APPARATUS and CONTROL METHOD FOR THE SAME |
CN112198865A (en) * | 2020-09-29 | 2021-01-08 | 中电海康无锡科技有限公司 | Testing method, device and system for MCU low-power mode switching |
CN115509340A (en) * | 2021-06-07 | 2022-12-23 | 中移物联网有限公司 | Low-power-consumption management method of operating system, operating system and terminal |
WO2023070890A1 (en) * | 2021-10-31 | 2023-05-04 | 歌尔股份有限公司 | Working mode control method for wearable device, wearable device, and medium |
CN115774484A (en) * | 2023-02-13 | 2023-03-10 | 苏州聚元微电子股份有限公司 | Low-power consumption management system of TOUCH MCU |
Non-Patent Citations (1)
Title |
---|
史兴强;范学仕;: "一种SoC低功耗模式设计与实现", 电子与封装, no. 02, 20 February 2018 (2018-02-20) * |
Also Published As
Publication number | Publication date |
---|---|
CN117930960B (en) | 2024-12-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6052793A (en) | Wakeup event restoration after power loss | |
US7779191B2 (en) | Platform-based idle-time processing | |
TWI464571B (en) | A power saving electronic device for a computer motherboard in a standby dormant state and a computer motherboard | |
US8762757B2 (en) | Power management method and device thereof | |
US10394307B2 (en) | Information processing apparatus, information processing method, and program | |
TWI525425B (en) | Leakage variation aware power management for multicore processors | |
US20110131427A1 (en) | Power management states | |
CN110806794A (en) | Power-down protection method, system, computer device and medium for storage system | |
US8949638B2 (en) | Embedded controller with an internal timer | |
TW201205322A (en) | Computer component power-consumption database | |
US9423847B2 (en) | Method and apparatus for transitioning a system to an active disconnect state | |
US11216053B2 (en) | Systems, apparatus, and methods for transitioning between multiple operating states | |
US9377833B2 (en) | Electronic device and power management method | |
JP2000305670A (en) | Device and method for controlling electric power saving and information processor | |
TWI534707B (en) | Computer system, shutdown and boot method thereof | |
US8886974B2 (en) | Controller | |
CN102736928B (en) | Quickly wake up computer system method and computer system | |
CN109933179A (en) | A kind of server intelligent boot control method, device and equipment | |
CN101162260A (en) | Function testing device and method for small electric quantity extra battery | |
CN119472961A (en) | Timing power on/off method and industrial computer based on ARM architecture core processor | |
CN101281416A (en) | Method for ensuring system shutdown completion | |
TWI601009B (en) | Thermal sensor dynamic shutdown | |
CN117930960A (en) | A method and device for detecting low power consumption mode of MCU | |
JP2001034370A (en) | Power-saving controller, power-saving control method, and computer system | |
CN116662092A (en) | Memory data testing method and device, storage medium and electronic equipment |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |