CN111624918A - Method, device and system for acquiring working state of microcontroller and readable storage medium - Google Patents

Method, device and system for acquiring working state of microcontroller and readable storage medium Download PDF

Info

Publication number
CN111624918A
CN111624918A CN202010513604.1A CN202010513604A CN111624918A CN 111624918 A CN111624918 A CN 111624918A CN 202010513604 A CN202010513604 A CN 202010513604A CN 111624918 A CN111624918 A CN 111624918A
Authority
CN
China
Prior art keywords
microcontroller
event
current
timestamp
voltage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010513604.1A
Other languages
Chinese (zh)
Inventor
朱晓飞
李保海
万峰
陈光胜
张旭华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Neusoft Carrier Intelligent Internet Of Things Technology Co ltd
Shanghai Eastsoft Microelectronics Co ltd
Original Assignee
Guangdong Neusoft Carrier Intelligent Internet Of Things Technology Co ltd
Shanghai Eastsoft Microelectronics Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Neusoft Carrier Intelligent Internet Of Things Technology Co ltd, Shanghai Eastsoft Microelectronics Co ltd filed Critical Guangdong Neusoft Carrier Intelligent Internet Of Things Technology Co ltd
Priority to CN202010513604.1A priority Critical patent/CN111624918A/en
Publication of CN111624918A publication Critical patent/CN111624918A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • G05B19/042Programme control other than numerical control, i.e. in sequence controllers or logic controllers using digital processors
    • G05B19/0423Input/output
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/20Pc systems
    • G05B2219/25Pc structure of the system
    • G05B2219/25257Microcontroller

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Automation & Control Theory (AREA)
  • Debugging And Monitoring (AREA)

Abstract

A method, a device, a system and a readable storage medium for acquiring the working state of a microcontroller are provided, wherein the acquisition method comprises the following steps: acquiring current and voltage of a microcontroller and a first timestamp set corresponding to the acquired current and voltage; searching a sleeping awakening event output by the microcontroller and a second timestamp corresponding to the sleeping awakening event, a program running event output by the microcontroller and a third timestamp corresponding to the program running event from the first timestamp set; calculating the average transient power consumption of the microcontroller according to the current and the voltage of the microcontroller, and drawing an average transient power consumption curve of the microcontroller; calculating the average transient power consumption corresponding to each event according to the second time stamp, the third time stamp and the current and voltage of the microcontroller; and identifying a sleep awakening event and a program running event on the average transient power consumption curve. By the scheme, the tester can accurately know the specific working state of the MCU in real time.

Description

Method, device and system for acquiring working state of microcontroller and readable storage medium
Technical Field
The invention relates to the technical field of microcontrollers, in particular to a method, a device and a system for acquiring the working state of a microcontroller and a readable storage medium.
Background
With the development of Internet of Things (IoT), various IoT products have been derived, and the IoT products have higher and higher requirements on power consumption of a Microcontroller (MCU). Therefore, the MCU needs to be debugged to measure the specific power consumption of the MCU.
In the prior art, an online debugging technology is usually adopted to perform online debugging on an application system of an MCU. However, when the application system of the MCU is debugged by using the online debugging technology, the tester cannot accurately know the current specific working state of the MCU in real time, including the sleep mode and the power consumption condition.
Disclosure of Invention
The technical problem solved by the embodiment of the invention is that when an application system of the MCU is debugged, a tester cannot accurately know the current specific working state of the MCU in real time.
In order to solve the above technical problem, an embodiment of the present invention provides a method for acquiring a working state of a microcontroller, including: acquiring current and voltage of the microcontroller and a first timestamp set corresponding to the acquired current and voltage; the first timestamp set is generated when the equal time interval is generated and the current change exceeds a threshold; searching a sleep wake-up event output by the microcontroller and a second timestamp corresponding to the sleep wake-up event, a program running event output by the microcontroller and a third timestamp corresponding to the program running event from the first timestamp set; calculating the average transient power consumption of the microcontroller according to the current and the voltage of the microcontroller, and drawing an average transient power consumption curve of the microcontroller; calculating the average transient power consumption corresponding to each event according to the second time stamp, the third time stamp and the current and voltage of the microcontroller; the events comprise the sleep wake-up event and the program running event; and identifying a sleep wakeup event corresponding to the second timestamp and a program running event corresponding to the third timestamp on the average transient power consumption curve.
Optionally, after acquiring the current and the voltage of the microcontroller, the method further includes: self-calibrating the acquired current of the microcontroller.
Optionally, the self-calibrating the acquired current of the microcontroller includes: determining a target measuring range corresponding to the acquired current of the microcontroller; selecting a preset current calibration function corresponding to the target measuring range; and calibrating the acquired current of the microcontroller by adopting the current calibration function.
Optionally, the calculating an average transient power consumption corresponding to each sleep/wake-up event and each program running event includes: acquiring the starting time and the ending time of the ith event; acquiring all timestamps in the ith event period and the current and the voltage of the microcontroller in the running period according to the starting time and the ending time of the ith event; calculating the average transient power consumption corresponding to the ith event period by adopting the following formula:
Figure BDA0002529326710000021
wherein T0 is a start time corresponding to the ith event, T is an end time corresponding to the ith event, i (T) is a current of the microcontroller sampled at each timestamp during the ith event, u (T) is a voltage of the microcontroller sampled at each timestamp during the ith event, and Δ T is a time interval between a current timestamp and an upper timestamp.
In order to solve the above technical problem, an embodiment of the present invention further provides a system for acquiring a working state of a microcontroller, including: client and debugging device, wherein: the debugging device is coupled with the client and the microcontroller and is suitable for acquiring the current and the voltage of the microcontroller and sending a first timestamp set corresponding to the acquired current and voltage to the client; the first timestamp set is generated when the equal time interval is generated and the current change exceeds a threshold; the client is connected with the debugging device and is suitable for searching a sleeping wakeup event output by the microcontroller and a second timestamp corresponding to the sleeping wakeup event, a program running event output by the microcontroller and a third timestamp corresponding to the program running event from the first timestamp set; calculating the average transient power consumption of the microcontroller according to the current and the voltage of the microcontroller, and drawing an average transient power consumption curve of the microcontroller; calculating the average transient power consumption corresponding to each event according to the second time stamp, the third time stamp and the current and voltage of the microcontroller; the events comprise the sleep wake-up event and the program running event; and identifying a sleep wakeup event corresponding to the second timestamp and a program running event corresponding to the third timestamp on the average transient power consumption curve.
Optionally, the client is further adapted to perform self-calibration on the current of the microcontroller after acquiring the current of the microcontroller.
Optionally, the client is adapted to determine a target range corresponding to the acquired current of the microcontroller; selecting a preset current calibration function corresponding to the target measuring range; and calibrating the acquired current of the microcontroller by adopting the current calibration function.
Optionally, the client is adapted to obtain a start time and an end time of an ith event; the events comprise the sleep wake-up event and the program running event; acquiring all timestamps in the ith event period and the current and the voltage of the microcontroller in the running period according to the starting time and the ending time of the ith event; calculating the average transient power consumption corresponding to the ith event period by adopting the following formula:
Figure BDA0002529326710000031
wherein t0 is the ithThe starting time corresponding to the event, T is the ending time corresponding to the ith event, i (T) is the current of the microcontroller sampled by each timestamp during the ith event, u (T) is the voltage of the microcontroller sampled by each timestamp during the ith event, and Δ T is the time interval between the current timestamp and the last timestamp.
The embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium is a non-volatile storage medium or a non-transitory storage medium, and a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program executes any of the steps of the microcontroller operating state obtaining method described above.
The embodiment of the invention also provides a microcontroller working state acquisition device, which comprises a memory and a processor, wherein the memory is stored with a computer program capable of running on the processor, and the processor executes any one of the steps of the microcontroller working state acquisition method when running the computer program.
Compared with the prior art, the technical scheme of the embodiment of the invention has the following beneficial effects:
the method comprises the steps of obtaining the current and the voltage of a microcontroller and a first timestamp set corresponding to the current and the voltage, searching a sleep wake-up event output by the microcontroller and a second timestamp corresponding to the sleep wake-up event, a program running event output by the microcontroller and a third timestamp corresponding to the program running event from the first timestamp set. And drawing an average transient power consumption curve of the microcontroller according to the current and the voltage of the microcontroller, and calculating the average transient power consumption of each event. And identifying each dormancy awakening event and each program running event on the average transient power consumption curve, so that a tester can intuitively know the specific working state of the microcontroller in real time.
Drawings
Fig. 1 is a schematic structural diagram of a microcontroller operating state acquiring system in an embodiment of the present invention;
FIG. 2 is a flow chart of a method for acquiring an operating state of a microcontroller according to an embodiment of the present invention;
FIG. 3 is a graph of average transient power consumption of a microcontroller in an embodiment of the invention;
fig. 4 is a schematic structural diagram of an amplifying circuit in an embodiment of the present invention.
Detailed Description
In practical application, when an application system of the MCU is debugged using an online debugging technique, a tester cannot know the specific operating state of the MCU in real time.
In the embodiment of the invention, the current and the voltage of the microcontroller and the corresponding first time stamp set are obtained, and the sleep wake-up event output by the microcontroller and the corresponding second time stamp thereof, the program running event output by the microcontroller and the corresponding third time stamp thereof are searched from the first time stamp set. And drawing an average transient power consumption curve of the microcontroller according to the current and the voltage of the microcontroller, and calculating the average transient power consumption of each event. And identifying each dormancy awakening event and each program running event on the average transient power consumption curve, so that a tester can intuitively know the specific working state of the microcontroller in real time.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
The embodiment of the invention provides a system for acquiring the working state of a microcontroller, and the system for acquiring the working state of the microcontroller is described in detail below with reference to fig. 1.
In a specific implementation, the microcontroller operation state acquiring system may include a client 11 and a debugging device 12. The client 11 may be connected with the debugging apparatus 12 to communicate with the debugging apparatus 12. The commissioning device 12 may be connected to a microcontroller 14.
In the embodiment of the present invention, the client 11 and the debugging apparatus 12 may be connected through wired communication or wireless communication. In an embodiment of the present invention, the client 11 and the debugging apparatus 12 are both provided with USB interfaces, and are connected through a USB connection line.
In a specific implementation, the microcontroller 14 may be disposed on the target board 13, and the target board 13 may be disposed with a peripheral circuit for ensuring the microcontroller 14 to work normally. A power supply may be provided on the target board 13 to power the microcontroller 14. The target board 13 may also be powered externally to the microcontroller 14.
In an embodiment of the present invention, the target board 13 may be powered through a USB interface. The programmable voltage can be output to the target board 13 by adopting PWM regulation, 5V, 3.3V, 2.5V and other voltages are supported, and the stability of the voltage is controlled by adopting a PID algorithm.
In a specific implementation, the debugging means 12 may be connected to the target board 13, thereby enabling communication with the microcontroller 14. The debug apparatus 12 may collect the current and voltage of the microcontroller 14. The debugging device 12 may acquire the current and the voltage of the microcontroller 14 in real time, may acquire the current and the voltage of the microcontroller 14 AT regular time, and may acquire the current and the voltage of the microcontroller 14 according to an input instruction (such as an AT instruction) of a tester.
In the embodiment of the present invention, the debugging apparatus 12 may acquire the current and the voltage of the microcontroller 14 according to a preset acquisition cycle, and acquire a first set of timestamps corresponding to the current and the voltage of the microcontroller 14. The acquisition period can be set according to the actual application scene or the requirements of testers. For example, the acquisition period is set to 100 ms. As another example, the acquisition period is set to 50 ms. When the current change of the microcontroller 14 exceeds the threshold, the debugging apparatus may also record a timestamp corresponding to the exceeding of the threshold, where the timestamp also belongs to the first timestamp set.
In a specific implementation, when the current change of the microcontroller 14 exceeds a threshold, it generally means that a sleep wake-up event and/or a program run event occurs in the microcontroller 14. Thus, when a sleep wake event and/or a program run event occurs in microcontroller 14, debug device 12 records its corresponding timestamp.
That is, in the embodiment of the present invention, the time points at which the debugging device 12 collects the current and the voltage of the microcontroller 14 are: the acquisition time points are periodic and the time points at which the current change of the microcontroller 14 exceeds a threshold.
After collecting the current and voltage of the microcontroller 14, the debugging device 12 may output the collected current and voltage of the microcontroller 14 to the client 11.
In practical applications, the client 11 may be a personal computer or other electronic devices with a screen display function.
In a specific implementation, when the current and the voltage of the microcontroller 14 are collected, since the current and the voltage of the microcontroller 14 are small, the current and the voltage of the microcontroller 14 are usually amplified by using an amplifying circuit, and the amplified current and voltage are collected by the debugging device 12. In other words, the debugging device 12 is coupled to an amplifying circuit, which is coupled to the microcontroller 14, and the current and voltage are collected by the debugging device 12 and amplified by the amplifier.
In practical application, the amplification circuit and the peripheral circuit have discreteness, so that the amplification factor of the amplification circuit has certain errors, and in order to ensure the measurement precision, the amplification circuit can be calibrated by adopting a high-precision resistor.
Referring to fig. 4, a schematic structural diagram of an amplifying circuit in an embodiment of the present invention is shown. In fig. 4, Ra, Rb, and Rc are calibration resistors, and R1 is a sampling resistor. The sampling resistor R1, the calibration resistor Ra, the calibration resistor Rb, and the calibration resistor Rc are all high-precision resistors. The sampling resistor R1 has a first terminal connected to the input terminal "-" of the amplifying circuit, and a second terminal coupled to the input terminal "+" of the amplifying circuit and the fixed terminal of the multiplexer. The active end of the multiplexer is selectively connected with the first end of the calibration resistor Ra, the first end of the calibration resistor Rb and the first end of the calibration resistor Rc, that is, when a certain calibration resistor is selected, the active end of the multiplexer is connected with the first end of the calibration resistor.
The second ends of the calibration resistor Ra, the calibration resistor Rb, and the calibration resistor Rc are coupled to ground. Calibration resistor Ra, calibration resistor Rb, and calibration resistor Rc are virtually in parallel.
A resistor R2 is connected between the input terminal "-" and the output terminal of the amplifying circuit, a second terminal of the resistor R2 is coupled to a first terminal of the resistor R3, and a second terminal of the resistor R3 outputs the ADC sampling voltage. The input of the amplification circuit "-" inputs the voltage Vi.
In a specific implementation, the calibration resistors Ra, Rb and Rc may be measured in advance through experiments, and the real current values of the calibration resistors Ra, Rb and Rc and the corresponding ADC sampling voltages are obtained. And establishing a linear function relation between the ADC sampling voltage and the real current value by taking the real current value as an x axis and the corresponding ADC sampling value as a y axis. In the embodiment of the present invention, the first-order functional relationship between the ADC sampling voltage and the real current value is also: a current calibration function. For each calibration resistor, there may be a one-to-one current calibration function.
For example, when the active terminal of the multiplexer is connected to the first terminal between the calibration resistor Ra, the first current value I1 and the corresponding ADC sampling voltage ADC1 can be measured, and then the linear function between the ADCs 1 and I1 can be determined as: i1 ═ a1 × ADC1+ B1.
Accordingly, when the active terminal of the multiplexer is connected to the first terminal of the calibration resistor Rb, the second current value I2 and the corresponding ADC sampling voltage ADC2 can be measured, and then the linear function between the ADCs 2 and I2 can be determined as: i2 ═ a2 × ADC2+ B2.
It should be noted that only three calibration resistors are shown in fig. 4. In practical applications, the number of calibration resistors may also be 1 or more. In addition, Ra, Rb, and Rc are also only illustrative of calibration resistors, and Ra, Rb, and Rc may be resistors with different resistances, or may be different resistances corresponding to one adjustable resistor. Ra, Rb, Rc correspond to different current ranges, for example, Ra corresponds to current range of the order of μ a and Rb corresponds to current range of the order of mA.
In a specific implementation, the client 11 may also self-calibrate the received microcontroller current after receiving the microcontroller current and voltage.
In the embodiment of the present invention, the client 11 may determine a target range corresponding to the acquired current of the microcontroller; then, selecting a preset current calibration function corresponding to the target measuring range; and calibrating the acquired current of the microcontroller by adopting a current calibration function.
That is to say, in the embodiment of the present invention, different current calibration functions are selected for different ranges of measurement range, so that the acquired current of the microcontroller can be calibrated more accurately. The current calibration function may be different for different ranges of span.
In a specific implementation, corresponding current calibration functions may be generated in advance for different ranges of measurement ranges and stored in the client 11 in advance.
In a specific implementation, since the current acquired by the client 11 is the current acquired through an analog-to-digital converter (ADC), when selecting the target range, the client substantially selects the corresponding target range according to the current acquired by the analog-to-digital converter (ADC). The analog-to-digital converter may be provided in the commissioning apparatus 12.
In particular implementations, the power consumption of the microcontroller 14 may change when the microcontroller 14 wakes up from a sleep state. Typically, the microcontroller 14 wakes up due to both exception events and interrupt event triggers. For convenience of description, in the embodiment of the present invention, an exception event, an interrupt event, and the like are referred to as a sleep wake event.
After waking from the sleep state, the microcontroller 14 may send a sleep wake event to the debugging apparatus 12, that is, send an exception event and an interrupt event to the debugging apparatus 12, which trigger the wake event. After receiving the sleep wake-up event output by the microcontroller 14, the debugging apparatus 12 may forward the sleep wake-up event and a second timestamp corresponding to the sleep wake-up event to the client 11.
The microcontroller 14, upon waking up, may record the entry and exit addresses of each task function, and the entry and exit addresses of each interrupt service routine. When the microcontroller 14 runs the program, the address corresponding to the program running event will be detected in real time. When the address corresponding to the program execution event matches each of the task function entry address and exit address, and each of the interrupt service program entry address and exit address, the microcontroller 14 may output the program execution event and the corresponding third timestamp to the debugging apparatus 12. The debugging apparatus 12 may output the program running event and the corresponding third timestamp to the client 11.
In a specific implementation, the client 11 may receive the current and voltage of the microcontroller 14 and the first set of timestamps output by the debugging apparatus 12, the sleep wake-up event of the microcontroller 14 and the second timestamp corresponding to the sleep wake-up event, and the program running event and the third timestamp corresponding to the program running event. The client can calculate the average transient power consumption of the microcontroller according to the current and the voltage of the microcontroller, and draw an average transient power consumption curve of the microcontroller according to the calculated average transient power consumption of the microcontroller. Referring to fig. 3, a graph of average transient power consumption of a microcontroller in an embodiment of the invention is shown.
In a specific implementation, the client 11 may calculate an average transient power consumption corresponding to the second timestamp according to the second timestamp and the current and voltage of the microcontroller, that is, the average transient power consumption of the sleep wake-up event corresponding to the second timestamp. Accordingly, the client 11 may calculate the average transient power consumption corresponding to the third timestamp according to the third timestamp and the current and voltage of the microcontroller, that is, the average transient power consumption of the program running event corresponding to the third timestamp.
After the average transient power consumption graph of the microcontroller, the average transient power consumption corresponding to the second timestamp and the average transient power consumption corresponding to the third timestamp are obtained through calculation, a sleep wake-up event corresponding to the second timestamp and a program running event corresponding to the third timestamp can be identified on the average transient power consumption graph.
Typically, a sleep wake-up event causes a significant change in the power consumption of the microcontroller 14. A large ripple will occur on the average transient power consumption curve corresponding to the microcontroller. Thus, by identifying a sleep wake-up event on the average transient power consumption curve, the point in time at which the microcontroller 14 is awakened can be made visually known to the tester.
Referring to fig. 3, a current curve corresponding to a sleep wake-up event in an embodiment of the present invention is shown. As can be seen from fig. 3, the sleep wakeup events occur from T0 to T1, and the average transient power consumption corresponding to the microcontroller fluctuates to a relatively large extent when the sleep wakeup events occur.
Accordingly, program run events can cause significant changes in the power consumption of the microcontroller 14. The program running event may also cause the average transient power consumption curve to fluctuate greatly corresponding to the average transient power consumption curve of the microcontroller. Therefore, by identifying the program operation event on the average transient power consumption curve, the test personnel can intuitively know the execution time of the program operation event and the generated power consumption.
As can be seen from FIG. 3, program run events occur from time T1 to time T2. At time T2-T3, the microcontroller reenters the sleep state.
By adopting the scheme, the client can acquire the power consumption corresponding to each event, and the events comprise a sleep wakeup event and a program running event. After obtaining the power consumption corresponding to each event, the client 11 may generate and display the power consumption percentage corresponding to each event and the time period occupied by each event according to the total power consumption of the microcontroller 14, and a tester may visually obtain the power consumption percentage and the time period of each event, so as to evaluate whether each event meets expectations and whether a further optimization space exists.
In the embodiment of the invention, the client can acquire the starting time and the ending time of the ith event, and acquire all timestamps in the ith event period and the current and the voltage of the microcontroller in the running period according to the starting time and the ending time of the ith event; calculating the average transient power consumption corresponding to the ith event period by adopting the following formula:
Figure BDA0002529326710000091
wherein T0 is a start time corresponding to the ith event, T is an end time corresponding to the ith event, i (T) is a current of the microcontroller sampled by each timestamp during the ith event, u (T) is a voltage of the microcontroller sampled by each timestamp during the ith event, and Δ T is a time interval between a current timestamp and an upper timestamp.
In a specific implementation, when the current and voltage of the microcontroller 14 are collected, the current value of the microcontroller 14 may be collected by a sampling resistor connected in series to a power supply loop of the microcontroller 14. The current sampling circuit can be formed by N amplifying circuits with different measuring ranges, different amplifying coefficients are used in different current ranges, and N is more than or equal to 2. The power supply circuit and the current sampling circuit are both arranged on the target board 13.
In specific implementation, the debugging apparatus 12 may also perform adaptive adjustment of power consumption. Debug apparatus 12 may record a current over threshold event or a power consumption over high event. If the user enables the power consumption adaptive adjustment option of the debugging device through the client terminal 11, when the running program is debugged, before the event of high power consumption is triggered, the power consumption configuration is automatically reduced, for example, the main frequency of the microcontroller 14 is reduced, the bit rate of the communication serial port is changed, and the like. After the power-high event operation is finished, the debugging device 12 restores the initial configuration.
The method for acquiring the working state of the microcontroller provided in the embodiment of the present invention is explained in detail below. Referring to fig. 2, a flowchart of a method for acquiring an operating state of a microcontroller according to an embodiment of the present invention is shown, and the following description is made with reference to fig. 1 and fig. 2.
Step S201, obtaining a current and a voltage of the microcontroller, and a first timestamp set corresponding to the obtained current and voltage.
In particular implementations, debug device 12 may collect the current and voltage of microcontroller 14. The debugging device 12 may acquire the current and voltage of the microcontroller 14 in real time, may also acquire the current and voltage of the microcontroller 14 at regular time, and may also acquire the current and voltage of the microcontroller 14 according to an input instruction of a tester.
In the embodiment of the present invention, the debugging apparatus 12 may acquire the current and the voltage of the microcontroller 14 according to a preset acquisition cycle, and acquire timestamps corresponding to the current and the voltage of the microcontroller 14. The acquisition period can be set according to the actual application scene or the requirements of testers. For example, the acquisition period is set to 100 ms. As another example, the acquisition period is set to 50 ms. When the current change of the microcontroller 14 exceeds the threshold, the debugging apparatus may also record a timestamp corresponding to the exceeding of the threshold, where the timestamp also belongs to the first timestamp set.
In a specific implementation, when the current change of the microcontroller 14 exceeds a threshold, it generally means that a sleep wake-up event and/or a program run event occurs in the microcontroller 14. Thus, when a sleep wake event and/or a program run event occurs in microcontroller 14, debug device 12 records its corresponding timestamp.
That is, in the embodiment of the present invention, the time points at which the debugging device 12 collects the current and the voltage of the microcontroller 14 are: the acquisition time points are periodic and the time points at which the current change of the microcontroller 14 exceeds a threshold.
After collecting the current and voltage of the microcontroller 14, the debugging device 12 may output the collected current and voltage of the microcontroller 14 to the client 11. The client 11 may obtain the current and the voltage of the microcontroller sent by the debugging apparatus, and a first set of timestamps corresponding to the current and the voltage
Step S202, searching for the sleep wake-up event output by the microcontroller and the second timestamp corresponding to the sleep wake-up event, the program running event output by the microcontroller and the third timestamp corresponding to the program running event from the first timestamp set.
In an implementation, the client 11 may search for the sleep/wake event and the corresponding second timestamp, the program running event and the corresponding third timestamp from the first timestamp set.
Step S203, calculating the average transient power consumption of the microcontroller according to the current and the voltage of the microcontroller, and drawing an average transient power consumption curve of the microcontroller.
Step S204, calculating the average transient power consumption corresponding to each event according to the second time stamp, the third time stamp and the current and voltage of the microcontroller; the event comprises the sleep wake-up event and the program running event.
Step S205, identify a sleep wake-up event corresponding to the second timestamp and a program running event corresponding to the third timestamp on the average transient power consumption curve.
In a specific implementation, the client 11 may also self-calibrate the received microcontroller current after receiving the microcontroller current and voltage.
In the embodiment of the present invention, the client 11 may determine a target range corresponding to the acquired current of the microcontroller; then, selecting a preset current calibration function corresponding to the target measuring range; and calibrating the acquired current of the microcontroller by adopting a current calibration function.
That is to say, in the embodiment of the present invention, different current calibration functions are selected for different ranges of measurement range, so that the acquired current of the microcontroller can be calibrated more accurately. The current calibration function may be different for different ranges of span.
In a specific implementation, corresponding current calibration functions may be generated in advance for different ranges of measurement ranges and stored in the client 11 in advance.
In a specific implementation, since the current acquired by the client 11 is the current acquired through an analog-to-digital converter (ADC), when selecting the target range, the client substantially selects the corresponding target range according to the current acquired by the analog-to-digital converter (ADC). The analog-to-digital converter may be provided in the commissioning apparatus 12.
In a specific implementation, the execution process of step S201 to step S205 may refer to the above description about the microcontroller operating state obtaining system, which is not described herein again.
In summary, the current and the voltage of the microcontroller and the corresponding first timestamp set are obtained, and the sleep wake-up event output by the microcontroller and the corresponding second timestamp thereof, the program running event output by the microcontroller and the corresponding third timestamp thereof are searched from the first timestamp set. And drawing an average transient power consumption curve of the microcontroller according to the current and the voltage of the microcontroller, and calculating the average transient power consumption of each event. And identifying each dormancy awakening event and each program running event on the average transient power consumption curve, so that a tester can intuitively know the specific working state of the microcontroller in real time.
The embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium is a non-volatile storage medium or a non-transitory storage medium, and a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program executes the steps of the method for acquiring the working state of the microcontroller provided in any of the above embodiments of the present invention.
The embodiment of the present invention further provides a data processing device, which includes a memory and a processor, where the memory stores a computer program that can be run on the processor, and when the processor runs the computer program, the processor executes the steps of the method for acquiring the working state of the microcontroller provided in any of the above embodiments of the present invention.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by instructing the relevant hardware through a program, which may be stored in a computer-readable storage medium, and the storage medium may include: ROM, RAM, magnetic or optical disks, and the like.
Although the present invention is disclosed above, the present invention is not limited thereto. Various changes and modifications may be effected therein by one skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (10)

1. A method for acquiring the working state of a microcontroller is characterized by comprising the following steps:
acquiring current and voltage of the microcontroller and a first timestamp set corresponding to the acquired current and voltage; the first timestamp set is generated when the equal time interval is generated and the current change exceeds a threshold;
searching a sleep wake-up event output by the microcontroller and a second timestamp corresponding to the sleep wake-up event, a program running event output by the microcontroller and a third timestamp corresponding to the program running event from the first timestamp set;
calculating the average transient power consumption of the microcontroller according to the current and the voltage of the microcontroller, and drawing an average transient power consumption curve of the microcontroller;
calculating the average transient power consumption corresponding to each event according to the second time stamp, the third time stamp and the current and voltage of the microcontroller; the events comprise the sleep wake-up event and the program running event;
and identifying a sleep wakeup event corresponding to the second timestamp and a program running event corresponding to the third timestamp on the average transient power consumption curve.
2. The microcontroller operation state acquisition method according to claim 1, further comprising, after acquiring the current and voltage of the microcontroller:
self-calibrating the acquired current of the microcontroller.
3. The microcontroller operation state acquisition method according to claim 2, wherein the self-calibrating the acquired current of the microcontroller comprises:
determining a target measuring range corresponding to the acquired current of the microcontroller;
selecting a preset current calibration function corresponding to the target measuring range;
and calibrating the acquired current of the microcontroller by adopting the current calibration function.
4. The method for acquiring the working state of the microcontroller according to claim 1, wherein the calculating the average transient power consumption corresponding to each sleep wakeup event and program running event comprises:
acquiring the starting time and the ending time of the ith event;
acquiring all timestamps in the ith event period and the current and the voltage of the microcontroller in the running period according to the starting time and the ending time of the ith event;
calculating the average transient power consumption corresponding to the ith event period by adopting the following formula:
Figure FDA0002529326700000021
wherein T0 is a start time corresponding to the ith event, T is an end time corresponding to the ith event, i (T) is a current of the microcontroller sampled at each timestamp during the ith event, u (T) is a voltage of the microcontroller sampled at each timestamp during the ith event, and Δ T is a time interval between a current timestamp and an upper timestamp.
5. A microcontroller operating state acquisition system, comprising: client and debugging device, wherein:
the debugging device is coupled with the client and the microcontroller and is suitable for acquiring the current and the voltage of the microcontroller and sending a first timestamp set corresponding to the acquired current and voltage to the client; the first timestamp set is generated when the equal time interval is generated and the current change exceeds a threshold;
the client is connected with the debugging device and is suitable for searching a sleeping wakeup event output by the microcontroller and a second timestamp corresponding to the sleeping wakeup event, a program running event output by the microcontroller and a third timestamp corresponding to the program running event from the first timestamp set; calculating the average transient power consumption of the microcontroller according to the current and the voltage of the microcontroller, and drawing an average transient power consumption curve of the microcontroller; calculating the average transient power consumption corresponding to each event according to the second time stamp, the third time stamp and the current and voltage of the microcontroller; the events comprise the sleep wake-up event and the program running event; and identifying a sleep wakeup event corresponding to the second timestamp and a program running event corresponding to the third timestamp on the average transient power consumption curve.
6. The microcontroller operation state acquisition system of claim 5 wherein the client is further adapted to self-calibrate the current of the microcontroller after acquiring the current of the microcontroller.
7. The system for acquiring the working state of the microcontroller according to claim 6, wherein the client is adapted to determine a target range corresponding to the acquired current of the microcontroller; selecting a preset current calibration function corresponding to the target measuring range; and calibrating the acquired current of the microcontroller by adopting the current calibration function.
8. The microcontroller operation state acquisition system according to claim 5, wherein the client is adapted to acquire a start time and an end time of an ith event; the events comprise the sleep wake-up event and the program running event; acquiring all timestamps in the ith event period and the current and the voltage of the microcontroller in the running period according to the starting time and the ending time of the ith event; calculating the average transient power consumption corresponding to the ith event period by adopting the following formula:
Figure FDA0002529326700000031
wherein T0 is a start time corresponding to the ith event, T is an end time corresponding to the ith event, i (T) is a current of the microcontroller sampled at each timestamp during the ith event, u (T) is a voltage of the microcontroller sampled at each timestamp during the ith event, and Δ T is a time interval between a current timestamp and an upper timestamp.
9. A computer-readable storage medium, which is a non-volatile storage medium or a non-transitory storage medium, and on which a computer program is stored, wherein the computer program is executed by a processor when running, and the method for acquiring the working state of the microcontroller according to any one of claims 1-4 is performed.
10. An apparatus for acquiring an operating state of a microcontroller, comprising a memory and a processor, wherein the memory stores a computer program operable on the processor, and the processor executes the computer program to perform the steps of the method for acquiring an operating state of a microcontroller according to any one of claims 1 to 4.
CN202010513604.1A 2020-06-08 2020-06-08 Method, device and system for acquiring working state of microcontroller and readable storage medium Pending CN111624918A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010513604.1A CN111624918A (en) 2020-06-08 2020-06-08 Method, device and system for acquiring working state of microcontroller and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010513604.1A CN111624918A (en) 2020-06-08 2020-06-08 Method, device and system for acquiring working state of microcontroller and readable storage medium

Publications (1)

Publication Number Publication Date
CN111624918A true CN111624918A (en) 2020-09-04

Family

ID=72270240

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010513604.1A Pending CN111624918A (en) 2020-06-08 2020-06-08 Method, device and system for acquiring working state of microcontroller and readable storage medium

Country Status (1)

Country Link
CN (1) CN111624918A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116736076A (en) * 2023-05-12 2023-09-12 珠海妙存科技有限公司 Chip dormancy state detection method and system, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101282526A (en) * 2007-12-20 2008-10-08 袁玉芳 Handset standby current, standby time as well as test equipment for charging flow
CN102596302A (en) * 2009-10-29 2012-07-18 皇家飞利浦电子股份有限公司 Illumination device with wake-up function
CN110297171A (en) * 2019-06-14 2019-10-01 合肥格易集成电路有限公司 A kind of the power consumption test system and equipment of chip
CN110308321A (en) * 2019-07-05 2019-10-08 珠海格力智能装备有限公司 The detection method and device of dynamic current
CN111209160A (en) * 2019-12-31 2020-05-29 深圳云天励飞技术有限公司 Power consumption abnormity analysis method and device, terminal equipment and readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101282526A (en) * 2007-12-20 2008-10-08 袁玉芳 Handset standby current, standby time as well as test equipment for charging flow
CN102596302A (en) * 2009-10-29 2012-07-18 皇家飞利浦电子股份有限公司 Illumination device with wake-up function
CN110297171A (en) * 2019-06-14 2019-10-01 合肥格易集成电路有限公司 A kind of the power consumption test system and equipment of chip
CN110308321A (en) * 2019-07-05 2019-10-08 珠海格力智能装备有限公司 The detection method and device of dynamic current
CN111209160A (en) * 2019-12-31 2020-05-29 深圳云天励飞技术有限公司 Power consumption abnormity analysis method and device, terminal equipment and readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116736076A (en) * 2023-05-12 2023-09-12 珠海妙存科技有限公司 Chip dormancy state detection method and system, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
Sigrist et al. Measurement and validation of energy harvesting IoT devices
US9696353B2 (en) Measuring power consumption of circuit component operating in run mode
JP2017011263A (en) Method and system for monitoring electrolytic capacitor state online
CN105680860B (en) Improve the circuit and method of microcontroller A/D conversion accuracy
CN105388445A (en) Automatic meter calibration method for single-phase electric energy meter
CN102736967A (en) Test system and method of watchdog timer
CN111624918A (en) Method, device and system for acquiring working state of microcontroller and readable storage medium
CN114499521A (en) Signal calibration method and device, computer equipment and storage medium
WO2016101661A1 (en) Battery capacity calculation system and method
CN116955027A (en) MCU chip test system and test method thereof
CN109211981B (en) Method and device for calibrating probe of TDS detector and TDS detector
CN114563753B (en) Method, device, equipment and computer readable storage medium for detecting power failure of electric energy meter
Nguyen et al. Energy consumption measurements as a basis for computational offloading for android smartphones
GB2565877A (en) Low power measurement of skin electrical properties
WO2022047767A1 (en) Battery power detection method and apparatus, and portable electronic device
CN115839696B (en) Tire pattern depth measurement method, device, storage medium and system
JPS5828665A (en) Watthour meter
CN116185784B (en) Calibration device, calibration system and acquisition system
Meyer et al. An energy measurement system for characterization of energy harvesting systems
CN217484401U (en) Transient current acquisition circuit and MCU low-power consumption test system
US11630134B2 (en) Rapid sensing value estimation circuit and method thereof
CN112946562B (en) Power failure protection method and device for double-core intelligent electric meter and double-core intelligent electric meter
CN107703352B (en) Openpower platform-based power consumption monitoring method and system
WO2022183976A1 (en) Coulombmeter-based method and system for measuring remaining electric quantity of battery
CN112415141B (en) Compensation method and compensation device for formaldehyde measurement concentration display value

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