Method for monitoring peripheral circuit and microcontroller chip

By monitoring the signal validity, timing, and combination of peripheral circuits, the problem of the lack of a general monitoring module in MCU chips is solved, thereby improving the reusability and security of the chip.

CN117991670BActive Publication Date: 2026-11-10JINAN BYD SEMICON TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211340674.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-28
Publication Date
2026-11-10
Estimated Expiration
2042-10-28

AI Technical Summary

Technical Problem

Existing MCU chips lack a general monitoring module for peripheral devices, which makes it impossible to monitor abnormal behavior of peripheral modules, reducing chip reusability and development workload.

Method used

By selecting a target signal from the signals emitted by the peripheral circuit, monitoring its validity, timing and signal combination, determining whether it meets the preset requirements, and identifying whether the peripheral circuit is malfunctioning.

Benefits of technology

It improves the reusability and security of MCU chips, simplifies anomaly analysis, and enables monitoring of various peripheral circuits.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117991670B_ABST
    Figure CN117991670B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a kind of peripheral circuit monitoring method and a kind of microcontroller chip, the present application discloses by selecting target signal needing monitoring from the signal sent by peripheral circuit, can satisfy the monitoring requirement of different signal to user;By judging the validity of target signal first, when target signal is valid, in turn, judge whether the timing of target signal meets the preset timing requirement, whether the combination of target signal meets the preset combination requirement, when there is any one of target signal invalid, the timing of target signal does not meet the preset timing requirement, the signal combination of target signal does not meet the preset combination requirement, then determine that peripheral circuit works abnormally, alleviate the problem that the abnormal analysis complexity of microcontroller chip is improved due to lack of monitoring circuit for peripheral circuit, and make the MCU chip work has certain security guarantee, improve the reusability of microcontroller chip.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of chip technology, and in particular to a monitoring method for peripheral circuits and a microcontroller chip. Background Technology

[0002] In current MCU (Microcontroller Unit) chip designs, there are common modules such as watchdog timers and PC counters for monitoring whether the processing and running programs in the MCU kernel are functioning normally.

[0003] However, in current technology, there is no universal monitoring module that supports all peripheral device modules of the MCU chip. This makes it impossible for the MCU chip to monitor the abnormal behavior of the peripheral modules, or each peripheral device module only has monitoring of its corresponding key logic circuit. This results in poor reusability in MCU design and increased development workload. Summary of the Invention

[0004] In view of the above problems, embodiments of the present invention are proposed to provide a monitoring method for peripheral circuits and a microcontroller chip that overcomes or at least partially solves the above problems.

[0005] To address the above problems, this invention discloses a method for monitoring peripheral circuits, the method comprising:

[0006] Select the target signal to be monitored from the signals emitted by the peripheral circuit, and monitor the effectiveness of the target signal;

[0007] When the target signal is valid, determine whether the timing of the target signal meets the preset timing requirements;

[0008] When the timing of the target signal meets the preset timing requirements, it is determined whether the signal combination of the target signal meets the preset combination requirements;

[0009] If any of the following conditions are met: the target signal is invalid, the timing of the target signal does not meet the preset timing requirements, or the signal combination of the target signal does not meet the preset combination requirements, then the peripheral circuit is determined to be malfunctioning.

[0010] Optionally, monitoring the effectiveness of the target signal includes:

[0011] Obtain the valid timing value corresponding to the target signal;

[0012] Determine whether the timing value of the target signal matches the valid timing value;

[0013] If the timing value of the target signal matches the valid timing value, then the target signal is determined to be valid.

[0014] Optionally, determining whether the timing value of the target signal matches the valid timing value includes:

[0015] Acquire a sampling signal at a preset frequency;

[0016] The target signal is sampled using the sampling signal, and the timing value of the target signal is obtained;

[0017] Determine whether the timing value of the target signal matches the valid timing value.

[0018] Optionally, the peripheral circuit includes an ADC analog-to-digital converter circuit, and the target signal includes an ADC enable signal, an ADC conversion end signal, a trigger PWM signal, and a PWM enable signal; the step of determining whether the timing of the target signal meets the preset timing requirements includes:

[0019] If, within a first preset time after the ADC enable signal is detected, the ADC conversion end signal is detected, and within a second preset time after the ADC conversion end signal is detected, the trigger PWM signal and the PWM enable signal are detected, then it is determined that the timing of the target signal meets the preset timing requirements.

[0020] Optionally, determining whether the signal combination of the target signal meets the preset combination requirements includes:

[0021] If the PWM enable signal is monitored after the trigger PWM signal is monitored, then it is determined that the signal combination of the target signal meets the preset combination requirements.

[0022] Optionally, monitoring the effectiveness of the target signal includes:

[0023] Obtain the working time, which includes the start time and end time;

[0024] The effectiveness of the target signal is monitored during the time period between the start time and the end time.

[0025] This invention also discloses a microcontroller chip, including: peripheral circuitry, monitoring signal selection circuitry, and monitoring circuitry;

[0026] The monitoring signal selection circuit is connected to both the peripheral circuit and the monitoring circuit. The monitoring signal selection circuit is used to select the target signal to be monitored from the signals emitted by the peripheral circuit and feed it back to the monitoring circuit.

[0027] The monitoring circuit is used to monitor the validity of the target signal. When the target signal is valid, it determines whether the timing of the target signal meets the preset timing requirements. When the timing of the target signal meets the preset timing requirements, it determines whether the signal combination of the target signal meets the preset combination requirements. If the target signal is invalid, the timing of the target signal does not meet the preset timing requirements, or the signal combination of the target signal does not meet the preset combination requirements, then it is determined that the peripheral circuit is malfunctioning.

[0028] Optionally, the monitoring circuit is used to acquire the valid timing value corresponding to the target signal; determine whether the timing value of the target signal matches the valid timing value; if the timing value of the target signal matches the valid timing value, then the target signal is determined to be valid.

[0029] Optionally, the chip further includes a counter connected to the monitoring circuit, the counter being used to generate a sampling signal at a preset frequency;

[0030] The monitoring circuit is used to acquire a sampling signal at the preset frequency, use the sampling signal to sample the target signal, and acquire the timing value of the target signal; and determine whether the timing value of the target signal matches the valid timing value.

[0031] Optionally, the peripheral circuit includes an ADC analog-to-digital converter circuit, which includes an ADC enable signal generation circuit, an ADC conversion end signal generation circuit, an ADC trigger PWM signal generation circuit, and a PWM enable signal generation circuit; the ADC enable signal generation circuit, the ADC conversion end signal generation circuit, the ADC trigger PWM signal generation circuit, and the PWM enable signal generation circuit are respectively connected to the monitoring signal selection circuit.

[0032] The ADC enable signal generation circuit is used to generate an ADC enable signal, the ADC conversion end signal generation circuit is used to generate an ADC conversion end signal, the ADC trigger PWM signal generation circuit is used to generate an ADC trigger PWM signal, and the PWM enable signal generation circuit is used to generate a PWM enable signal.

[0033] The monitoring signal selection circuit is used to select the ADC enable signal, ADC conversion end signal, ADC trigger PWM signal, and PWM enable signal as the target signal to be monitored and send them to the monitoring circuit.

[0034] Optionally, the monitoring circuit is configured to, within a first preset time after monitoring the ADC enable signal, if monitoring the ADC conversion end signal, and within a second preset time after monitoring the ADC conversion end signal, if monitoring the trigger PWM signal and the PWM enable signal, determine that the timing of the target signal meets the preset timing requirements.

[0035] Optionally, the monitoring circuit is used to determine that the signal combination of the target signal meets the preset combination requirements if the PWM enable signal is monitored after the trigger PWM signal is monitored.

[0036] Optionally, the chip further includes a register connected to the monitoring circuit, the register being used to set the operating time;

[0037] The monitoring circuit is used to acquire the working time, which includes a start time and an end time; and to monitor the effectiveness of the target signal during the time period between the start time and the end time.

[0038] The embodiments of the present invention have the following advantages:

[0039] This invention discloses a method to select target signals to be monitored from signals emitted by peripheral circuits, thereby satisfying users' monitoring requirements for different signals. By first determining the validity of the target signal, and then, if the target signal is valid, sequentially determining whether the timing of the target signal meets preset timing requirements and whether the combination of target signals meets preset combination requirements, the peripheral circuit is determined to be malfunctioning if any of the following conditions are met: the target signal is invalid, the timing of the target signal does not meet preset timing requirements, or the combination of target signals does not meet preset combination requirements. This alleviates the problem of increased complexity in anomaly analysis caused by the lack of monitoring modules for peripheral circuits in microcontroller chips, improves the reusability of microcontroller chips, and provides a certain degree of safety assurance for MCU chip operation. Furthermore, it allows for the monitoring of different peripheral circuits according to actual needs, thus realizing the monitoring of multiple peripheral circuits. Attached Figure Description

[0040] Figure 1 This is a flowchart illustrating the steps of a monitoring method for peripheral circuits provided in an embodiment of the present invention.

[0041] Figure 2 This is a flowchart of another method for monitoring peripheral circuits provided in an embodiment of the present invention;

[0042] Figure 3 This is a structural block diagram of a microcontroller chip provided in an embodiment of the present invention;

[0043] Figure 4This is a structural block diagram of another microcontroller chip provided in an embodiment of the present invention. Detailed Implementation

[0044] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0045] In existing technologies, the core processing and running programs in the MCU are generally monitored by modules such as watchdog timers and PC counters. However, peripheral modules of the MCU chip are rarely monitored. This makes it difficult to detect peripheral module failures in a timely manner, reducing the reusability of the chip.

[0046] Based on this, one of the core concepts of this invention is to propose a monitoring method for peripheral circuits of a microcontroller. By selecting the target signal to be monitored from the signals emitted by the peripheral circuit, the validity of the target signal is monitored. When the target signal is valid, the timing of the target signal is then judged to meet the preset timing requirements, and the combination of the target signals is judged to meet the preset combination requirements. When any of the following situations exist: the target signal is invalid, the timing of the target signal does not meet the preset timing requirements, or the combination of the target signals does not meet the preset combination requirements, the peripheral circuit is determined to be malfunctioning. This alleviates the problem of increased complexity in anomaly analysis caused by the lack of a monitoring module for peripheral circuits in microcontroller chips, improves the reusability of microcontroller chips, and provides a certain degree of security for the operation of microcontroller chips.

[0047] Reference Figure 1 The diagram illustrates a flowchart of a monitoring method for peripheral circuits according to an embodiment of the present invention. The method may include the following steps:

[0048] Step 101: Select the target signal to be monitored from the signals emitted by the peripheral circuit, and monitor the effectiveness of the target signal.

[0049] In this embodiment of the invention, peripheral circuits generally refer to the serial port control circuit, SPI (Serial Peripheral Interface) circuit, I2C circuit (Inter-Integrated Circuit), ADC (Analog to Digital Converter) circuit, PWM (Pulse-width Modulation) circuit, CAN (Controller Area Network) circuit, and EEPROM (Erasable Programmable Read Only) circuit within the microcontroller chip. Memory (Electrically Erasable Programmable Read-Only Memory), comparator circuits, etc., are all integrated inside the microcontroller and have corresponding internal control registers, which can be directly controlled by microcontroller instructions. Different peripheral circuits require corresponding logic signals to achieve their respective functions. For example, when the peripheral circuit is an ADC circuit, the ADC circuit needs to send ADC enable signal, ADC conversion end signal, ADC trigger PWM signal, PWM enable signal, and some other basic function signals to complete the digital-to-analog conversion. When the ADC enable signal, ADC conversion end signal, ADC trigger PWM signal, and PWM enable signal are abnormal, the function of the ADC circuit will also be affected. Therefore, the target signal to be monitored can be selected from multiple signals sent by the peripheral circuit, and then the target signal can be monitored to meet the different monitoring needs of users.

[0050] When monitoring the target signal, valid or invalid target signals will be detected. When an invalid target signal is detected, it indicates that the peripheral circuit is malfunctioning. At this time, the abnormal target signal can be output so that troubleshooting personnel can know which signal has failed, thus improving the efficiency of troubleshooting.

[0051] In one embodiment of the present invention, monitoring the validity of the target signal includes:

[0052] Acquire working time, including start and end times; monitor the effectiveness of the target signal during the time period between the start and end times.

[0053] In this embodiment of the invention, the target signal can be monitored within the time period between the start and end times of the working time set by the user, thereby meeting the monitoring needs of different users. Alternatively, the target signal can be monitored according to the time from the start to the end of the peripheral circuit's operation, thereby monitoring within the working time of the peripheral circuit, avoiding invalid monitoring, and improving monitoring efficiency.

[0054] Step 102: When the target signal is valid, determine whether the timing of the target signal meets the preset timing requirements.

[0055] In this embodiment of the invention, the preset timing requirement refers to whether the timing of multiple target signals meets the preset timing requirement, and whether the effective time of multiple target signals meets the preset duration. For example, the target signals include signal A, signal B, and signal C. When signals A, B, and C are all monitored as effective, if signal B is monitored as effective within a first preset time after signal A is monitored as effective, and signal C is monitored as effective within a second preset time after signal B is monitored as effective, then signals A, B, and C meet the preset timing requirement. If signal B is monitored as effective only after the first preset time after signal A is monitored as effective, then signal B does not meet the preset timing requirement. If signal B is monitored as effective within the first preset time after signal A is monitored as effective, and signal C is monitored as effective only after the second preset time after signal B is monitored as effective, then signal C does not meet the preset timing requirement.

[0056] Step 103: When the timing of the target signal meets the preset timing requirements, determine whether the signal combination of the target signal meets the preset combination requirements.

[0057] In this embodiment of the invention, the preset combination requirement refers to the combination method between target signals that satisfies the combination method of each target signal when the peripheral circuit is working normally. For example, in a peripheral circuit, the target signals that need to be monitored are signal A, signal B, and signal C. Signal A, signal B, and signal C are all monitored and are valid. The preset timing requirement is that signal B and signal C are monitored and are valid within the first preset time after signal A is monitored and is valid. The preset combination requirement is that signal B is monitored and is valid before signal C. If the target signal meets the preset timing requirement and the preset combination requirement, it means that the target signal is working normally.

[0058] It should be noted that the preset combination requirements can be set according to the working mode of different peripheral circuits, and are not limited here.

[0059] Step 104: If any of the following conditions exist: the target signal is invalid, the timing of the target signal does not meet the preset timing requirements, or the signal combination of the target signal does not meet the preset combination requirements, then the peripheral circuit is determined to be malfunctioning.

[0060] In this embodiment of the invention, when the target signal is found to be invalid, or the timing of the target signal does not meet the preset timing requirements, or the signal combination of the target signal does not meet the preset combination requirements, it indicates that the peripheral circuit is malfunctioning. At this time, the abnormal target signal can be output to the troubleshooting personnel.

[0061] For example, the target signals are signals A, B, and C. The preset timing requirement is that after signal A is monitored as valid, signals B and C should be monitored as valid within 2ms. The preset combination requirement is that signal B should be monitored as valid before signal C. If only signals A and C are monitored as valid, and signal B is monitored as invalid, it indicates that the peripheral circuit is malfunctioning due to a fault in signal B, and the output signal B is invalid. If signals A, B, and C are all monitored as valid, but the monitoring of signal B occurs 2.1ms after signal A is monitored as valid, the output signal B is invalid. If signals B and C are valid, it means that signals B and C do not meet the preset timing requirements. In this case, the output signals B and C do not meet the preset timing requirements. If signals A, B, and C are all valid and meet the preset timing requirements, but signal B is detected as valid 1.8ms after signal A is detected as valid, and signal C is detected as valid 1.5ms after signal A is detected as valid, that is, signal C is detected as valid before signal B, it means that signals B and C do not meet the preset combination requirements. In this case, the output signals B and C do not meet the preset combination requirements.

[0062] This invention discloses a method to select target signals to be monitored from signals emitted by peripheral circuits, thereby satisfying users' monitoring requirements for different signals. By first determining the validity of the target signal, and then, if the target signal is valid, sequentially determining whether the timing of the target signal meets preset timing requirements and whether the combination of target signals meets preset combination requirements, the invention identifies an abnormal operation of the peripheral circuit when any of the following conditions are met: the target signal is invalid, the timing of the target signal does not meet preset timing requirements, or the combination of target signals does not meet preset combination requirements. This alleviates the problem of increased complexity in anomaly analysis caused by the lack of monitoring modules for peripheral circuits in microcontroller chips, and provides a certain degree of safety assurance for the operation of MCU chips. Furthermore, it allows for the monitoring of different peripheral circuits according to actual needs, thereby achieving monitoring of multiple peripheral circuits.

[0063] Reference Figure 2 The diagram illustrates a flowchart of another method for monitoring peripheral circuits provided by an embodiment of the present invention. The method may include the following steps:

[0064] Step 201: Select the target signal to be monitored from the signals emitted by the peripheral circuit, obtain the valid timing value corresponding to the target signal, and determine whether the timing value of the target signal matches the valid timing value. If the timing value of the target signal matches the valid timing value, then the target signal is determined to be valid.

[0065] In this embodiment of the invention, the effective timing values ​​corresponding to different target signals are different. Therefore, the validity of a target signal can be determined by whether the timing value of the target signal collected during the monitoring process matches the effective timing value. For example, if the effective timing value of the target signal is a, the validity of signal A can be determined by judging whether the timing value of the collected target signal is a. When the timing value of signal A is a, signal A is determined to be valid. When the timing value of signal A is not a, signal A is invalid.

[0066] In one embodiment of the present invention, determining whether the timing value of the target signal matches a valid timing value includes:

[0067] Acquire a sampling signal at a preset frequency; use the sampling signal to sample the target signal and obtain the timing value of the target signal; determine whether the timing value of the target signal matches the valid timing value.

[0068] In this embodiment of the invention, the preset frequency refers to the frequency at which the target signal can be sampled. The frequency of the target signal is generally no more than 100 kHz. In order to sample each target signal, the preset frequency can be set to a frequency higher than that of the target signal. In one example, the preset frequency is 1 MHz, so that the timing value of the target signal can be sampled. Then, the timing value of the sampled target signal is compared with the valid timing value. If they match, the target signal is valid; if they do not match, the target signal is invalid.

[0069] Step 202: When the target signal is valid, determine whether the timing of the target signal meets the preset timing requirements.

[0070] In one embodiment of the present invention, the peripheral circuit includes an ADC analog-to-digital converter circuit, and the target signal includes an ADC enable signal, an ADC conversion end signal, a trigger PWM signal, and a PWM enable signal; determining whether the timing of the target signal meets preset timing requirements includes:

[0071] If an ADC conversion completion signal is detected within a first preset time after the ADC enable signal is detected, and if a trigger PWM signal and a PWM enable signal are detected within a second preset time after the ADC conversion completion signal is detected, then the timing of the target signal is determined to meet the preset timing requirements.

[0072] Specifically, taking the target signal emitted by the ADC analog-to-digital converter circuit as an example, the target signal can include the ADC enable signal, the ADC conversion end signal, the trigger PWM signal, and the PWM enable signal. After the ADC enable signal takes effect, the ADC conversion end signal generally takes effect within 2ms, and after the ADC conversion end signal takes effect, the trigger PWM signal and the PWM enable signal generally take effect within 100us. Therefore, a first preset time can be set to 2ms and a second preset time to 100us. Then, the timing of the target signal can be judged based on the effective time of each signal to determine whether the timing meets the preset timing requirements. For example, when the target signal is effective, if the ADC conversion end signal is monitored 2.05ms after the ADC enable signal is monitored, it indicates that the ADC conversion end signal is abnormal. If the ADC conversion end signal is monitored 1.5ms after the ADC enable signal is monitored, and the trigger PWM signal and the PWM enable signal are monitored 120us after the ADC conversion end signal is monitored, it indicates that the trigger PWM signal and the PWM enable signal are abnormal.

[0073] Step 203: When the timing of the target signal meets the preset timing requirements, determine whether the signal combination of the target signal meets the preset combination requirements.

[0074] In one embodiment of the present invention, determining whether the signal combination of the target signal meets a preset combination requirement includes:

[0075] If a PWM enable signal is detected after the PWM trigger signal is detected, then it is determined that the signal combination of the target signal meets the preset combination requirements.

[0076] Specifically, the PWM enable signal generally takes effect only after the trigger PWM signal is activated. For example, if the trigger PWM signal is detected 50µs after the ADC conversion completion signal is detected, and the PWM enable signal is detected 10µs after the trigger PWM signal is detected, then the signal combination of the target signal meets the preset combination requirements. If the trigger PWM signal and the PWM enable signal are both activated 50µs after the ADC conversion completion signal is detected, then the preset combination requirements are not met.

[0077] Step 204: If any of the following conditions exist: the target signal is invalid, the timing of the target signal does not meet the preset timing requirements, or the signal combination of the target signal does not meet the preset combination requirements, then the peripheral circuit is determined to be malfunctioning.

[0078] For example, if any one of the following signals is found to be invalid: ADC enable signal, ADC conversion end signal, PWM trigger signal, or PWM enable signal, then the peripheral circuit is determined to be malfunctioning, and the invalid target signal is output.

[0079] If the ADC enable signal, ADC conversion end signal, trigger PWM signal, and PWM enable signal are all valid, but the ADC conversion end signal is only monitored as valid after 2.1ms after the ADC enable signal is detected, then it is determined that the ADC conversion end signal does not meet the preset timing requirements.

[0080] If the ADC enable signal, ADC conversion end signal, trigger PWM signal, and PWM enable signal are all valid and meet the preset timing requirements, but the PWM enable signal is detected as valid before the ADC trigger PWM signal, then it is determined that the PWM enable signal does not meet the preset combination requirements.

[0081] If the ADC enable signal, ADC conversion end signal, trigger PWM signal, and PWM enable signal are all detected as valid, and after the ADC enable signal is detected as valid, the ADC conversion end signal is detected as valid after 1.5ms, and then the trigger PWM signal and PWM enable signal are detected after 120us, then it is determined that the trigger PWM signal and PWM enable signal do not meet the preset timing requirements.

[0082] If the ADC enable signal, ADC conversion end signal, trigger PWM signal, and PWM enable signal are all valid and meet the preset timing requirements, but the PWM enable signal and the ADC trigger PWM signal are both valid, then it is determined that the PWM enable signal and the ADC trigger PWM signal do not meet the preset combination requirements.

[0083] This invention discloses a method to select target signals to be monitored from signals emitted by peripheral circuits, thereby satisfying users' monitoring requirements for different signals. By first determining the validity of the target signal, and then, if the target signal is valid, sequentially determining whether the timing of the target signal meets preset timing requirements and whether the combination of the target signals meets preset combination requirements, the peripheral circuit is determined to be malfunctioning if any of the following conditions are met: the target signal is invalid, the timing of the target signal does not meet preset timing requirements, or the combination of the target signals does not meet preset combination requirements. This alleviates the problem of increased complexity in anomaly analysis caused by the lack of monitoring modules for peripheral circuits in microcontroller chips. Furthermore, it allows for monitoring of different peripheral circuits according to actual needs, thereby achieving monitoring of multiple peripheral circuits, improving the reusability of MCU chips, and providing a certain level of security for MCU chip operation.

[0084] like Figure 3 The diagram shows a structural block diagram of a microcontroller chip 30 provided in an embodiment of the present invention. The microcontroller chip 30 may include peripheral circuit 301, monitoring signal selection circuit 302, and monitoring circuit 303.

[0085] The monitoring signal selection circuit 302 is connected to the peripheral circuit 301 and the monitoring circuit 303 respectively. The monitoring signal selection circuit 302 is used to select the target signal to be monitored from the signal sent by the peripheral circuit 301 and feed it back to the monitoring circuit 303.

[0086] The monitoring circuit 303 is used to monitor the validity of the target signal. When the target signal is valid, it determines whether the timing of the target signal meets the preset timing requirements. When the timing of the target signal meets the preset timing requirements, it determines whether the signal combination of the target signal meets the preset combination requirements. If the target signal is invalid, the timing of the target signal does not meet the preset timing requirements, or the signal combination of the target signal does not meet the preset combination requirements, then it is determined that the peripheral circuit 301 is malfunctioning.

[0087] In one embodiment of the present invention, the monitoring circuit 303 is used to acquire the valid timing value corresponding to the target signal; determine whether the timing value of the target signal matches the valid timing value; if the timing value of the target signal matches the valid timing value, then the target signal is determined to be valid.

[0088] In one embodiment of the present invention, the chip 30 further includes a counter 304, which is connected to the monitoring circuit 303 and is used to generate a sampling signal of a preset frequency.

[0089] The monitoring circuit 303 is used to acquire a sampling signal at a preset frequency, use the sampling signal to sample the target signal, and acquire the timing value of the target signal; and determine whether the timing value of the target signal matches the valid timing value.

[0090] In one embodiment of the present invention, reference is made to... Figure 4 This diagram illustrates a structural block diagram of another microcontroller chip 30 provided in an embodiment of the present invention. The peripheral circuit 301 includes an ADC analog-to-digital converter circuit 3011, which includes an ADC enable signal generation circuit 30111, an ADC conversion end signal generation circuit 30112, an ADC trigger PWM signal generation circuit 30113, and a PWM enable signal generation circuit 30114. The ADC enable signal generation circuit 30111, the ADC conversion end signal generation circuit 30112, the ADC trigger PWM signal generation circuit 30113, and the PWM enable signal generation circuit 30114 are respectively connected to the monitoring signal selection circuit 302.

[0091] The ADC enable signal generation circuit 30111 is used to generate the ADC enable signal, the ADC conversion end signal generation circuit 30112 is used to generate the ADC conversion end signal, the ADC trigger PWM signal generation circuit 30113 is used to generate the ADC trigger PWM signal, and the PWM enable signal generation circuit 30114 is used to generate the PWM enable signal.

[0092] The monitoring signal selection circuit 302 is used to select the ADC enable signal, ADC conversion end signal, ADC trigger PWM signal, and PWM enable signal as the target signals to be monitored and send them to the monitoring circuit 303.

[0093] In embodiments of the present invention, such as Figure 4 As shown, there are n channels between the peripheral circuit 301 and the monitoring signal selection circuit 302 that use transmission signals CH1-CH1. n The monitoring signal selection circuit 302 can open the channel containing the signal that needs to be monitored and shield the channel containing the signal that does not need to be monitored. As a result, the monitoring circuit 303 will not monitor the signal in the shielded channel, but only the signal in the unshielded channel. For example, when there are 8 channels and the corresponding signals are CH1-CH8, and the signals that need to be monitored are CH1-CH4, the monitoring signal selection circuit 302 can open the channel containing CH1-CH4 and shield the channel containing CH5-CH8, thereby avoiding monitoring some signals that do not need to be monitored and improving the monitoring efficiency.

[0094] In one embodiment of the present invention, the monitoring circuit 303 is used to determine that the timing of the target signal meets the preset timing requirements if an ADC conversion end signal is detected within a first preset time after the ADC enable signal is detected, and if a trigger PWM signal and a PWM enable signal are detected within a second preset time after the ADC conversion end signal is detected.

[0095] In one embodiment of the present invention, the monitoring circuit 303 is used to determine that the signal combination of the target signal meets the preset combination requirements if a PWM enable signal is monitored after a trigger PWM signal is monitored.

[0096] In one embodiment of the present invention, the chip 30 further includes a register 305, which is connected to the monitoring circuit 303 and is used to set the working time.

[0097] The monitoring circuit 305 is used to acquire the working time, which includes the start time and the end time; and to monitor the validity of the target signal during the time period between the start time and the end time.

[0098] In this embodiment of the invention, register 305 can set the working time range monitored by monitoring circuit 303, so that monitoring circuit 305 monitors the effectiveness of target signal according to the working time range set by the user. The working time can also be set according to the time from the start to the end of the peripheral circuit, so that monitoring is carried out within the working time of the peripheral circuit, avoiding invalid monitoring and improving the efficiency of monitoring.

[0099] This invention discloses a method for selecting target signals to be monitored from signals emitted by peripheral circuits through a monitoring signal selection circuit and sending them to a monitoring circuit. This allows the monitoring circuit to perform targeted monitoring of signals emitted by peripheral circuits. In this invention, the monitoring circuit can monitor the operation of general peripheral circuits in MCU chips, which can alleviate the problem of increased complexity in anomaly analysis caused by the lack of monitoring circuits for peripherals in MCU chips. It can also monitor different peripheral circuits according to actual needs, thereby realizing the monitoring of multiple peripheral circuits and providing a certain degree of safety assurance for the operation of MCU chips.

[0100] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0101] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0102] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.

[0103] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0104] The above provides a detailed description of a monitoring method for peripheral circuits and a microcontroller chip provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for monitoring peripheral circuits, characterized in that, The method includes: The monitoring signal selection circuit selects the target signal to be monitored from the signals emitted by the peripheral circuit, and monitors the effectiveness of the target signal. When the target signal is valid, the monitoring circuit determines whether the timing of the target signal meets the preset timing requirements. When the timing of the target signal meets the preset timing requirements, it is determined whether the signal combination of the target signal meets the preset combination requirements; If any of the following conditions are met: the target signal is invalid, the timing of the target signal does not meet the preset timing requirements, or the signal combination of the target signal does not meet the preset combination requirements, then the peripheral circuit is determined to be malfunctioning. The peripheral circuit includes an ADC analog-to-digital converter circuit, which includes an ADC enable signal generation circuit, an ADC conversion end signal generation circuit, an ADC trigger PWM signal generation circuit, and a PWM enable signal generation circuit. The ADC enable signal generation circuit, the ADC conversion end signal generation circuit, the ADC trigger PWM signal generation circuit, and the PWM enable signal generation circuit are respectively connected to the monitoring signal selection circuit. The ADC enable signal generation circuit is used to generate an ADC enable signal, the ADC conversion end signal generation circuit is used to generate an ADC conversion end signal, the ADC trigger PWM signal generation circuit is used to generate an ADC trigger PWM signal, and the PWM enable signal generation circuit is used to generate a PWM enable signal. The monitoring signal selection circuit is used to select the ADC enable signal, ADC conversion end signal, ADC trigger PWM signal, and PWM enable signal as the target signal to be monitored and send them to the monitoring circuit; the monitoring circuit is used to determine that the timing of the target signal meets the preset timing requirements if the ADC conversion end signal is monitored within a first preset time after the ADC enable signal is monitored, and if the trigger PWM signal and the PWM enable signal are monitored within a second preset time after the ADC conversion end signal is monitored; the monitoring circuit is used to determine that the signal combination of the target signal meets the preset combination requirements if the PWM enable signal is monitored after the trigger PWM signal is monitored; there are n channels between the peripheral circuit and the monitoring signal selection circuit for signal transmission.

2. The method according to claim 1, characterized in that, The monitoring of the effectiveness of the target signal includes: Obtain the valid timing value corresponding to the target signal; Determine whether the timing value of the target signal matches the valid timing value; If the timing value of the target signal matches the valid timing value, then the target signal is determined to be valid.

3. The method according to claim 2, characterized in that, The step of determining whether the timing value of the target signal matches the valid timing value includes: Acquire a sampling signal at a preset frequency; The target signal is sampled using the sampling signal, and the timing value of the target signal is obtained; Determine whether the timing value of the target signal matches the valid timing value.

4. The method according to claim 1, characterized in that, The monitoring of the effectiveness of the target signal includes: Obtain the working time, which includes the start time and end time; The effectiveness of the target signal is monitored during the time period between the start time and the end time.

5. A microcontroller chip, characterized in that, include: Peripheral circuits, monitoring signal selection circuits, and monitoring circuits; The monitoring signal selection circuit is connected to the peripheral circuit and the monitoring circuit respectively. The monitoring signal selection circuit is used to select the target signal to be monitored from the signal emitted by the peripheral circuit and feed it back to the monitoring circuit. The monitoring circuit is used to monitor the validity of the target signal. When the target signal is valid, it determines whether the timing of the target signal meets the preset timing requirements. When the timing of the target signal meets the preset timing requirements, it determines whether the signal combination of the target signal meets the preset combination requirements. If the target signal is invalid, the timing of the target signal does not meet the preset timing requirements, or the signal combination of the target signal does not meet the preset combination requirements, then it is determined that the peripheral circuit is malfunctioning. The peripheral circuit includes an ADC analog-to-digital converter circuit, which includes an ADC enable signal generation circuit, an ADC conversion end signal generation circuit, an ADC trigger PWM signal generation circuit, and a PWM enable signal generation circuit. The ADC enable signal generation circuit, the ADC conversion end signal generation circuit, the ADC trigger PWM signal generation circuit, and the PWM enable signal generation circuit are respectively connected to the monitoring signal selection circuit. The ADC enable signal generation circuit is used to generate an ADC enable signal, the ADC conversion end signal generation circuit is used to generate an ADC conversion end signal, the ADC trigger PWM signal generation circuit is used to generate an ADC trigger PWM signal, and the PWM enable signal generation circuit is used to generate a PWM enable signal. The monitoring signal selection circuit is used to select the ADC enable signal, ADC conversion end signal, ADC trigger PWM signal, and PWM enable signal as the target signal to be monitored and send them to the monitoring circuit; the monitoring circuit is used to determine that the timing of the target signal meets the preset timing requirements if the ADC conversion end signal is monitored within a first preset time after the ADC enable signal is monitored, and if the trigger PWM signal and the PWM enable signal are monitored within a second preset time after the ADC conversion end signal is monitored; the monitoring circuit is used to determine that the signal combination of the target signal meets the preset combination requirements if the PWM enable signal is monitored after the trigger PWM signal is monitored; there are n channels between the peripheral circuit and the monitoring signal selection circuit for signal transmission.

6. The chip according to claim 5, characterized in that, The monitoring circuit is used to acquire the valid timing value corresponding to the target signal; determine whether the timing value of the target signal matches the valid timing value; if the timing value of the target signal matches the valid timing value, then the target signal is determined to be valid.

7. The chip according to claim 6, characterized in that, The chip also includes a counter, which is connected to the monitoring circuit and is used to generate a sampling signal at a preset frequency. The monitoring circuit is used to acquire a sampling signal at the preset frequency, use the sampling signal to sample the target signal, and acquire the timing value of the target signal; and determine whether the timing value of the target signal matches the valid timing value.

8. The microcontroller chip according to claim 5, characterized in that, The chip also includes a register connected to the monitoring circuit, and the register is used to set the working time. The monitoring circuit is used to acquire the working time, which includes a start time and an end time; and to monitor the effectiveness of the target signal during the time period between the start time and the end time.

Citation Information

Patent Citations

  • Monitoring method, device and system for circuit fault

    CN107256186A

  • Bus monitoring and debugging control device

    CN202267954U