Method, device and system for diagnosing program run time anomaly
Patent Information
- Application Number
- CN202011531290.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-22
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-12-22
AI Technical Summary
It is difficult to efficiently diagnose chip program running time anomalies with the existing technology, especially when monitoring multiple codes, it takes up a lot of resources, has low diagnostic efficiency, and has limited applicable scenarios.
Through the cooperation between MCU and FPGA, counters are used to provide timing functions. MCU controls the start and pause of FPGA timing, compares preset type data with thresholds, outputs abnormal diagnosis results, and supports multiple code monitoring and task status identification.
It improves the efficiency of diagnosing time problems, shortens the diagnostic process, provides a convenient and reliable diagnostic method, can monitor multiple codes at one time, and reduces resource occupation and the complexity of reset troubleshooting.
Smart Images

Figure CN112667423B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method, a device and a system for diagnosing program running time abnormality. Background Art
[0002] With the iterative development of chip software functions, the time resources in the chip are becoming increasingly tight. Under such circumstances, there are some hidden dangers caused by human errors when designers iterate the software.
[0003] For example, code that increases the running time and only occurs under certain conditions can easily evade testing. When the conditions are met, the program runs longer than expected, causing various problems and, in severe cases, causing the chip to reset.
[0004] Currently, developers usually add pin change instructions before and after a program starts and ends to troubleshoot timing issues. They use an oscilloscope or logic analyzer to observe the duration of the pin change to troubleshoot timing issues. The above method generally only checks the running time of one code at a time. If you want to check more than one place, it will occupy multiple pin resources and oscilloscope interfaces, making diagnosis more difficult. Summary of the invention
[0005] The present invention aims at the problem that it is difficult to diagnose the cause of chip reset, and provides a method, device and system for diagnosing program running time anomalies.
[0006] The technical solution proposed by the present invention for the above-mentioned technical problem is as follows:
[0007] In a first aspect, the present invention provides a method for diagnosing program run-time anomalies, the method comprising:
[0008] Utilizing the MCU to obtain preset type data, and comparing the obtained preset type data with a preset threshold value of a corresponding type, wherein the preset type data includes the running time of the target code and / or the count value of the FPGA; wherein the FPGA is connected to the MCU via an external pin, and the FPGA provides timing for the MCU via a counter; and the MCU controls the start and pause of the FPGA timing;
[0009] If the comparison difference is greater than the preset difference, a diagnostic result indicating an abnormality is output.
[0010] According to the above method for diagnosing program run time anomalies, the using of the MCU to obtain preset type data and comparing the obtained preset type data with a preset threshold value of a corresponding type includes:
[0011] When power is on and reset, the FPGA automatically pauses counting of the counter;
[0012] After power-on reset, the MCU obtains the monitored target code running time from the FPGA, where the running time includes the interrupt running time or the task running time;
[0013] The running time is compared with a preset running time threshold.
[0014] According to the above method for diagnosing program run time abnormality, the using MCU to obtain preset type data and comparing the obtained data with the corresponding preset type data includes:
[0015] When power is on and reset, the FPGA automatically pauses counting of the counter;
[0016] After power-on reset, the MCU obtains the count value at the reset time;
[0017] The count value is compared with a preset count threshold.
[0018] According to the above method for diagnosing program runtime anomalies, using the MCU to control the start and pause of the FPGA timing includes:
[0019] When the MCU executes the interrupt task function and the preset task enters the task interrupt state, pausing the counting of the counter corresponding to the preset task;
[0020] If the preset task resumes the running state, the count of the corresponding counter is restored; otherwise, the count of the corresponding counter is not restored;
[0021] The preset task refers to the task that the MCU is running and requires the counter to perform running counting.
[0022] According to the above method for diagnosing program running time anomalies, if it is identified that the preset task resumes the running state, the count of the corresponding counter is restored, otherwise, the count of the corresponding counter is not restored, including:
[0023] When the MCU executes an interrupt task function, a nested value is changed, wherein the nested value is a preset variable for indicating a nested level; the change processing rule is that the nested value is increased when the MCU executes an interrupt task function, and the nested value is decreased when the MCU completes the execution of an interrupt task function;
[0024] When the MCU completes executing an interrupt task function, judging whether there is interrupt task function nesting according to the current nesting value;
[0025] If the current nesting value is greater than the preset value, it is identified as the presence of interrupt task function nesting, and the preset task has not resumed the running state, so the count of the corresponding counter is not resumed.
[0026] According to the above method for diagnosing program runtime anomalies, using the MCU to control the start and pause of the FPGA timing includes:
[0027] If the MCU enters a high priority task and the preset task enters a task interrupt state, the counting of the counter corresponding to the preset task is suspended;
[0028] If the preset task resumes the running state, the count of the corresponding counter is resumed; otherwise, the count of the corresponding counter is not resumed;
[0029] The preset task refers to the task that the MCU is running and requires the counter to perform running counting.
[0030] According to the above method for diagnosing program running time anomalies, if the preset task resumes the running state, the count of the corresponding counter is restored, otherwise, the count of the corresponding counter is not restored, including:
[0031] When the MCU executes a high-priority task function, a nested value is changed, wherein the nested value is a preset variable used to represent the nested level; the change processing rule is that the nested value is increased when the MCU executes a high-priority task function, and the nested value is decreased when the MCU completes the execution of the high-priority task function;
[0032] When the MCU completes executing a high-priority task function, judging whether there is a high-priority task function nesting according to the current nesting value;
[0033] If the current nesting value is greater than the preset value, it is identified as the presence of high-priority task function nesting, and the preset task has not resumed the running state, so the count of the corresponding counter is not resumed.
[0034] In a second aspect, the present invention provides a diagnostic device for diagnosing program run time anomalies, the device comprising:
[0035] A comparison module, used to obtain preset type data using the MCU, and compare the obtained preset type data with a preset threshold value of a corresponding type, wherein the preset type data includes the running time of the target code and / or the count value of the FPGA; wherein the FPGA is connected to the MCU via an external pin, and the FPGA provides timing for the MCU via a counter; and the MCU controls the start and pause of the FPGA timing;
[0036] The diagnosis output module is used to output a diagnosis result representing an abnormality when the comparison difference is greater than a preset difference.
[0037] According to the above-mentioned diagnostic device for diagnosing program running time abnormality, the device also includes:
[0038] The identification module is used to identify whether a preset task has resumed its running state, wherein the preset task refers to a task currently being run by the MCU and requiring a counter to perform running counting.
[0039] In a third aspect, the present invention further provides a diagnostic system for diagnosing program execution time anomalies, which comprises the diagnostic device for diagnosing program execution time anomalies as described above.
[0040] The technical solution provided by the embodiment of the present invention has the following beneficial effects:
[0041] By using the counting and interactive data functions provided by MCU and FPGA, maintenance or developers can monitor multiple codes at one time. After determining the monitored code, the MCU time anomaly diagnostic program can be switched from idle mode (in this mode, the diagnostic code does not run) to diagnostic mode. The MCU controls the corresponding control register in the FPGA through external pins to start, stop, and clear the corresponding counter. After the MCU obtains the time data of the target code from the FPGA, it makes a time anomaly judgment and can upload it to the host computer or display it to the maintenance or developer for observation in other ways.
[0042] Compared with the traditional diagnostic method: first select the monitoring target code, find the reserved available pins, then observe the results with the help of an oscilloscope, narrow the scope of the problem, then reselect the monitoring target code, and then observe the results. This method is troublesome and has limited application scenarios to locate the timing problem. The present invention improves the efficiency of diagnosing timing problems, shortens the process of diagnosing timing problems, and provides a convenient and reliable diagnostic method for the reset phenomenon caused by occasional timing problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0044] Figure 1 A flowchart showing the principle of the method for diagnosing program run time anomalies provided by the present invention;
[0045] Figure 2 A schematic diagram of the connection relationship between the MCU and the FPGA of the present invention;
[0046] Figure 3 A specific flow chart of the method for diagnosing program run-time anomalies provided by the present invention;
[0047] Figure 4 The task nesting recognition flow chart provided by the present invention;
[0048] Figure 5 A structural block diagram of a diagnostic device for diagnosing program runtime anomalies provided by the present invention. DETAILED DESCRIPTION
[0049] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0050] The present invention provides a method, device and system for diagnosing abnormal program running time in order to facilitate maintenance or developers to learn abnormal conditions of MCU program running time.
[0051] See also Figure 1 , which is a flowchart of a method for diagnosing program runtime anomalies provided by the present invention. The method for diagnosing program runtime anomalies is mainly used in a diagnostic system, which at least includes an MCU (Microcontroller Unit) and an FPGA (Field Programmable Gate Array), which are electrically connected through external pins.
[0052] like Figure 1 As shown, the method for diagnosing program run time abnormality may include the following steps:
[0053] S101: Utilize MCU to obtain preset type data, and compare the obtained preset type data with a preset threshold value of a corresponding type, wherein the preset type data includes the running time of the target code and / or the count value of the FPGA; wherein the FPGA is connected to the MCU via an external pin, and the FPGA provides timing for the MCU via a counter; and the MCU controls the start and pause of the FPGA timing.
[0054] In this step, the FPGA provides timing for the MCU through a counter, and the MCU controls the control register in the FPGA (the area in the FPGA used to receive MCU commands, that is, the parallel bus sends data control) through external pins to control the corresponding counter.
[0055] It is understandable that after obtaining the count value of the corresponding counter, the unit conversion can be performed and the maximum value, minimum value and average value can be calculated. Afterwards, the data can be saved or directly uploaded to the host computer for maintenance or developer observation according to actual needs.
[0056] In this step, the preset type data may be the running time of the target code in the MCU, which may include the interrupt running time or the task running time. Of course, the preset type data may also be the count value of the counter in the FPGA. Corresponding to the interrupt running time, the preset threshold is the interrupt running time threshold; corresponding to the task running time, the preset threshold is the task running time threshold; corresponding to the count value, the preset threshold is the count threshold.
[0057] In this step, in some implementations, the use of the MCU to control the start and pause of the FPGA timing may specifically include the following sub-steps: when the MCU executes the interrupt task function and the preset task enters the task interrupt state, the count of the counter corresponding to the preset task is paused, where the preset task refers to the task that the MCU is running and requires the counter to run and count; if the preset task resumes the running state, the count of the corresponding counter is resumed, otherwise, the count of the corresponding counter is not resumed.
[0058] Here, when the preset task resumes the running state, the restoration of the count of the corresponding counter may specifically include: 1) When the MCU executes an interrupt task function, the nested value is changed, wherein the nested value is a preset variable used to represent the nesting level; the change processing rule is to increase the nested value when the MCU executes an interrupt task function, and to decrease the nested value when the MCU completes the execution of an interrupt task function; 2) When the MCU completes the execution of an interrupt task function, it is determined whether there is an interrupt task function nesting according to the current nested value, that is, whether the preset task resumes the running state; 3) If the current nested value is greater than the preset value (that is, the initial value of the nested value), it is identified that there is an interrupt task function nesting, and it is determined that the preset task has not resumed the running state, so the count of the corresponding counter is not restored. Of course, when it is determined that the preset task resumes the running state, the count of the corresponding counter is restored.
[0059] In other embodiments, the use of the MCU to control the start and pause of the FPGA timing may also specifically include the following sub-steps: if the MCU enters a high-priority task and the preset task enters a task interrupt state, the counting of the counter corresponding to the preset task is paused. Similar to the previous embodiment, the preset task refers to the task that the MCU is running and requires the counter to run and count; if the preset task resumes the running state, the counting of the corresponding counter is restored, otherwise, the counting of the corresponding counter is not restored.
[0060] Here, if the preset task resumes the running state, then the count of the corresponding counter is restored, which may specifically include: 1) When the MCU executes a high-priority task function, the nested value is changed, wherein the nested value is a preset variable used to represent the nesting level; the change processing rule is to increase the nested value when the MCU executes a high-priority task function, and to decrease the nested value when the MCU completes the execution of a high-priority task function; 2) When the MCU completes the execution of a high-priority task function, it is determined whether there is a nested high-priority task function based on the current nested value, that is, it corresponds to whether the preset task has resumed the running state. 3) If the current nested value is greater than the preset value, it is identified that there is a nested high-priority task function, and it is determined that the preset task has not resumed the running state, so the count of the corresponding counter is not restored. Of course, when it is determined that the preset task has resumed the running state, the count of the corresponding counter is restored.
[0061] S102: If the comparison difference is greater than a preset difference, a diagnosis result indicating an abnormality is output.
[0062] In this step, the diagnostic result representing the abnormality may be data reflecting abnormal information or the judgment result itself. The preset difference may preferably be zero, that is, when the acquired preset type data is greater than the preset threshold of the corresponding type, it is judged as abnormal, and then the diagnostic result representing the abnormality is output.
[0063] In combination with step S101, in some embodiments, when the preset type data is the running time, the MCU obtains the preset type data specifically by: using the MCU to monitor the running of the target code, and obtaining the running time or interrupt running time of the target code. At this time, the comparison of the obtained preset type data with the preset threshold of the corresponding type is respectively specifically: comparing the obtained running time with the running time threshold, and comparing the obtained interrupt running time with the interrupt running time threshold. Here, if the preset type data is the interrupt running time, the output of the diagnostic result representing the abnormality may be: interrupt running timeout. If the preset type data is the task running time, the output of the diagnostic result representing the abnormality may be: task running timeout.
[0064] In other embodiments, when the preset type data is a count value, the MCU obtains the preset type data specifically by: the MCU obtains the count value of the counter from the FPGA. At this time, the comparison of the obtained preset type data with the preset threshold of the corresponding type is specifically: comparing the count value with the count threshold. Here, the output of the diagnostic result representing the abnormality may be: a timeout causes a reset.
[0065] In the present invention, by using the counting and interactive data functions provided by MCU and FPGA, maintenance or development personnel can monitor multiple codes at one time. After determining the monitored code, the MCU time anomaly diagnosis program can be switched from idle mode (in this mode, the diagnostic code does not run) to diagnostic mode. The MCU controls the corresponding control register in the FPGA to start, stop, and clear the corresponding counter through an external pin. After the MCU obtains the time data of the target code from the FPGA, it makes a time anomaly judgment, and can upload it to the host computer or display it to the maintenance or development personnel for observation by other methods.
[0066] Compared with the traditional diagnostic method: first select the monitoring target code, find the reserved available pins (need to see the schematic diagram), then use the oscilloscope to observe the results, narrow the scope of the problem, then reselect the monitoring target code, and then observe the results. This method is troublesome and has limited application scenarios to locate the timing problem. The present invention improves the efficiency of diagnosing timing problems, shortens the process of diagnosing timing problems, and provides a convenient and reliable diagnostic method for reset and other phenomena caused by occasional timing problems.
[0067] See also Figure 2 , is a schematic diagram of the connection relationship between the MCU and the FPGA of the present invention. The MCU controls the control register in the FPGA (the area in the FPGA used to receive MCU commands, that is, the parallel bus sends data control) through an external pin to control the corresponding counter to start counting. The mapping relationship between the register and the counter can be: Bit0: Counter 0, Bit1: Counter 1...Bit15: Counter 15. After the diagnostic program obtains the value of the corresponding counter, the unit is converted to us, and the maximum value, minimum value, and average value are calculated, and then the data is saved or directly uploaded to the host computer for maintenance or development personnel to observe according to actual needs.
[0068] See also Figure 3 and Figure 4 ,in Figure 3 A specific flow chart of the method for diagnosing program run-time anomalies provided by the present invention; Figure 4 The task nesting recognition flow chart provided by the present invention. Figure 1 , Figure 2, when powered on and reset, the FPGA automatically detects the reset and pauses all counters. After the power-on reset, the MCU obtains the running time of the target code when it is reset from the FPGA, and compares the running time with the preset running time threshold to determine whether the time is abnormal. If the comparison difference is greater than the preset running time threshold, the judgment result is a time abnormality, and the diagnostic result representing the abnormality is output: a prompt message indicating that this reset is caused by a timeout. If the comparison difference is less than or equal to the preset running time threshold, the judgment result is normal, and the MCU enters the idle mode. In this mode, the diagnostic code is not run, and only whether the diagnostic function is started is cycled.
[0069] If the diagnostic function is enabled, there are:
[0070] For the running task: the target code running time is obtained from the FPGA (16 target code monitoring locations can be supported). If the target code is completed, its running time is determined to be abnormal. If it is abnormal, the maximum, minimum and average values of the abnormal data are calculated and uploaded to the host computer for maintenance or developer observation. Of course, the corresponding data can also be saved locally. If the target code is not completed or is determined to be normal, the target code is continuously monitored.
[0071] It is understandable that when the MCU enters a high-priority task, that is, executes a high-priority task function, the preset task enters the task interrupt state, thereby suspending the count of the counter corresponding to the preset task (the counter currently in use), and resuming the count of the corresponding counter when leaving. As for the nesting of high-priority tasks, that is, the existence of higher-priority tasks in the high-priority tasks, the counting control of the counter according to the above rules may cause the problem of abnormal removal of the high-priority task duration. When the high-priority task is in a nested state, each high-priority task will resume counting when leaving. If it is in a high-priority task nesting at this time, that is, the actual low-priority task is still in the waiting state, but the count is resumed, then there is no problem of removing the time occupied by all high-priority tasks in the low-priority tasks. Therefore, in order to solve the problem of abnormal removal of the high-priority task duration, it is necessary to determine whether the high-priority task is in a nested state before determining whether to resume counting, so there is the following process:
[0072] For high-priority tasks or task interrupts (here, task interrupts are also regarded as high-priority tasks, and the process is the same): first, determine whether to remove the time occupied by the high-priority task, and when the judgment result is yes, the high-priority task execution starts, and the registers that the FPGA is currently counting are paused and the register status is saved. When the judgment result is no, it can be determined that the high-priority task execution has ended, that is, the MCU has completed executing a high-priority task function. Afterwards, determine whether the high-priority task is nested. Specifically, it can be determined based on the current nesting value whether there is a high-priority task function nested in the current preset task, and when the judgment result is no, restore the FPGA counting state, and start counting until the high-priority task execution ends. When it is determined to be in high-priority nesting, the count of the corresponding counter will not be restored until the high-priority task execution ends. If Figure 4 As shown, a tag quantity can be set to represent the task level A. Afterwards, if a high-priority task is entered, that is, a high-priority task function is executed, there is a change process: A is increased or otherwise changed as a nesting value for nesting identification. Then the level of the task level A is judged. If the task level A is judged to be the first level, A is reduced or otherwise changed as another variable value for nesting identification, and then the nesting state is returned. If the task level A is judged not to be the first level, the current task is judged to be in a nesting state.
[0073] More specifically, in a specific application example, each time a preset task executes a high-priority task function, the nesting value determined when the high-priority task function was last executed is incremented by one, and when the high-priority task function is exited from execution, the nesting value is decremented by one. Therefore, if the variable is greater than 1 before exiting, there is a nesting of high-priority tasks, and the count is not restored when leaving the high-priority task state; if the variable is equal to 1, it means that there is no nesting of high-priority tasks, and the count is restored when leaving.
[0074] See also Figure 5 , is a structural block diagram of a diagnostic device for diagnosing program running time abnormalities provided by the present invention, wherein the diagnostic device 1 for diagnosing program running time abnormalities comprises a comparison module 11, a diagnosis output module 12 and an identification module 13, wherein:
[0075] The comparison module 11 is used to obtain preset type data using the MCU, and compare the obtained preset type data with the preset threshold of the corresponding type, wherein the preset type data includes the running time of the target code and / or the count value of the FPGA; wherein the FPGA is connected to the MCU through an external pin, and the FPGA provides timing for the MCU through a counter; and the MCU controls the start and pause of the FPGA timing.
[0076] The diagnosis output module 12 is used to output a diagnosis result indicating an abnormality when the comparison difference is greater than a preset difference.
[0077] The identification module 13 is used to identify whether a preset task has resumed its running state, wherein the preset task refers to a task that the MCU is running and requires a counter to perform running counting.
[0078] During operation, the diagnostic device 1 for diagnosing program running time anomalies can utilize the counting and interactive data functions provided by the MCU and FPGA. Maintenance or developers can monitor multiple codes at once. After determining the monitored code, the MCU time anomaly diagnostic program can be switched from idle mode (in this mode, the diagnostic code does not run) to diagnostic mode. The MCU controls the corresponding control register in the FPGA to start, stop, and clear the corresponding counter through an external pin. After the MCU obtains the time data of the target code from the FPGA, it makes a time anomaly judgment and can upload it to the host computer or display it to the maintenance or developer for observation in other ways.
[0079] The present invention also provides a diagnostic system for diagnosing program running time anomalies, which may include the above-mentioned diagnostic device for diagnosing program running time anomalies, and when applied, the counting and interactive data functions provided by the MCU and FPGA are also used, and the maintenance or development personnel can monitor multiple codes at one time. After determining the monitored code, the MCU time anomaly diagnostic program can be switched from idle mode (in this mode, the diagnostic code does not run) to diagnostic mode. The MCU controls the corresponding control register in the FPGA to start, stop, and clear the corresponding counter through an external pin. After the MCU obtains the time data of the target code from the FPGA, it makes a time anomaly judgment, and can upload it to the host computer or display it to the maintenance or development personnel for observation by other methods.
[0080] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for diagnosing program run-time anomalies, characterized in that: The method comprises: Utilize MCU to obtain preset type data, compare the obtained preset type data with the preset threshold value of the corresponding type, the preset type data includes the running time of the target code and / or the count value of FPGA; wherein, the FPGA is connected to the MCU through an external pin, and the FPGA provides timing for the MCU through a counter; the MCU controls the start and pause of the FPGA timing, including: when the MCU executes the interrupt task function and the preset task enters the task interrupt state, suspending the count of the counter corresponding to the preset task; if the preset task resumes the running state, then the count of the corresponding counter is resumed, otherwise, the count of the corresponding counter is not resumed; the preset task refers to the task that the MCU is running and requires the counter to perform running counting; the method of obtaining the preset type data by MCU and comparing the obtained preset type data with the preset threshold value of the corresponding type includes: Upon power-on reset, the FPGA automatically pauses the counter counting: After power-on reset, the MCU obtains the monitored target code running time from the FPGA: compares the running time with a preset running time threshold; or, When the power is on and reset, the FPGA automatically pauses the counter counting; after the power is on and reset, the MCU obtains the count value at the reset time; and compares the count value with the pre-designed value: If the comparison difference is greater than the preset difference, a diagnostic result indicating an abnormality is output.
2. The method for diagnosing program run-time anomalies according to claim 1, characterized in that: If the preset task resumes the running state, the count of the corresponding counter is resumed, otherwise, the count of the corresponding counter is not resumed, including: When the MCU executes an interrupt task function, a nesting value is changed, wherein the nesting value is a preset variable used to represent the nesting level; the rule of the change processing is that the nesting value is increased when the MCU executes an interrupt task function, and the nesting value is decreased when the MCU completes the execution of the interrupt task function; When the MCU completes executing an interrupt task function, judging whether there is interrupt task function nesting according to the current nesting value; If the current nesting value is greater than the preset value, it is identified as the presence of interrupt task function nesting, and the preset task is not restored to the running state, and the count of the corresponding counter is not restored.
3. The method for diagnosing program run-time anomalies according to claim 1, characterized in that: The MCU controls the start and pause of the FPGA timing, and further includes: If the MCU enters a high priority task function and the preset task enters a task interrupt state, the counting of the counter corresponding to the preset task is suspended.
4. The method for diagnosing program run-time anomalies according to claim 3, characterized in that: If the preset task resumes the running state, the count of the corresponding counter is resumed, otherwise, the count of the corresponding counter is not resumed, including: When the MCU executes a high-priority task function, a nested value is changed, wherein the nested value is a preset variable for indicating a nested level; the rule of the change processing is that the nested value is increased when the MCU executes a high-priority task function, and the nested value is decreased when the MCU completes the execution of the high-priority task function; When the MCU completes executing a high-priority task function, judging whether there is a high-priority task function nesting according to the current nesting value; If the current nesting value is greater than the preset value, it is identified as the presence of high-priority task function nesting, and the preset task is not restored to the running state, and the count of the corresponding counter is not restored.
5. A diagnostic device for implementing the method for diagnosing program run time anomalies according to any one of claims 1 to 4, characterized in that: The diagnostic device comprises: A comparison module is used to use the MCU to obtain preset type data, and compare the obtained preset type data with a preset threshold value of a corresponding type, wherein the preset type data includes the running time of the target code and / or the count value of the FPGA; wherein the FPGA is connected to the MCU through an external pin, and the FPGA provides timing for the MCU through a counter; the MCU controls the start and pause of the FPGA timing, including: when the MCU executes an interrupt task function and the preset task enters a task interrupt state, pausing the count of the counter corresponding to the preset task; if the preset task resumes the running state, then resuming the count of the corresponding counter, otherwise, not resuming the count of the corresponding counter: the preset task refers to a task that the MCU is running and requires the counter to perform running counting; using the MCU to obtain the preset type data, and comparing the obtained preset type data with the preset threshold value of the corresponding type includes: When the power is on, the FPGA automatically pauses the counter counting; after the power is on, the MCU obtains the monitored target code running time from the FPGA; and compares the running time with a preset running time threshold; or, At power-on reset, the FPGA automatically pauses the counter counting: After power-on reset, at power-on reset, the FPGA obtains the count value at the reset time from the MCU; compares the count value with the pre-designed value: The diagnosis output module is used to output a diagnosis result representing an abnormality when the comparison difference is greater than a preset difference.
6. The diagnostic device according to claim 5, characterized in that The diagnostic device also includes: An identification module, used to identify whether the preset task has resumed running; The preset task refers to the task that the MCU is running and requires the counter to perform running counting.
7. A diagnostic system for diagnosing program run-time anomalies, characterized in that: Comprising a diagnostic device as claimed in any one of claims 5 to 6.
