Method for avoiding repeated execution or mistaken execution of external interrupt service function

By detecting the triggering method of external interrupts and adopting corresponding control methods, the problem of repeated or incorrect execution of external interrupt service functions is solved, and the reliability and security of embedded devices are improved.

CN119829235APending Publication Date: 2025-04-15XIAN AVIATION COMPUTING TECH RES INST OF AVIATION IND CORP OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411810085.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

External interrupt service functions are prone to repeated or mis-execution due to level or glitch triggering in embedded devices, resulting in incorrect operation of the device and affecting reliability and security.

Method used

By detecting the triggering method of external interrupts, the subsequent execution of the external interrupt service function is controlled by using the method of level trigger, double jump edge trigger or single jump edge trigger, including turning off enable, setting timer and restoring enable to avoid repeated execution or incorrect execution.

Benefits of technology

It effectively avoids duplicate or incorrect execution of external interrupt service functions, and improves the reliability and security of onboard embedded devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829235A_ABST
    Figure CN119829235A_ABST
Patent Text Reader

Abstract

The invention provides a method for avoiding repeated execution or mistaken execution of an external interrupt service function, which comprises the following steps: acquiring a trigger mode of an external interrupt, the trigger mode comprising level trigger, single-hop edge trigger and double-hop edge trigger; detecting whether a trigger level appears or not according to the trigger mode, if yes, triggering external interruption, and executing an external interruption service function; if the triggering mode is level triggering, controlling subsequent execution of the external interrupt service function through a method under the level triggering mode; if the triggering mode is double-jump-edge triggering, subsequent execution of the external interrupt service function is controlled through a method under the double-jump-edge triggering mode; if the triggering mode is single-hop edge triggering, subsequent execution of the external interrupt service function is controlled through a method in the single-hop edge triggering mode. The purpose of improving the safety and reliability of the airborne embedded equipment is achieved by avoiding repeated execution or mistaken execution of an external interrupt service function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of embedded computer software, and in particular to a method for preventing repeated execution or erroneous execution of an external interrupt service function. Background Art

[0002] External interrupts are a common type of interrupt in the CPU. They are often used to quickly respond to critical external events / signals and are widely used in airborne embedded devices. External interrupts have two types of triggering modes: level triggering and edge triggering. They can be specifically divided into high level triggering, low level triggering, rising edge triggering, falling edge triggering, and transition edge triggering. Figure 1 shown.

[0003] In the level trigger mode, the CPU will repeatedly execute the external interrupt service function during the duration of the trigger level. In addition, the interference level or transition edge burr with a very short duration will also trigger the external interrupt by mistake. Figure 2 and Figure 3 Taking low-level triggering as an example, the process of repeated execution and erroneous execution of external interrupt service functions in level triggering mode is demonstrated.

[0004] In the edge trigger mode, due to the existence of edge glitches, when the external interrupt service routine (EXTISR) takes a very short time, the CPU will repeatedly execute the external interrupt service routine during the duration of the rising edge glitch and the falling edge glitch. Figure 4 Demonstrates the situation where falling edge glitches and rising edge glitches cause the external interrupt service function to be executed repeatedly.

[0005] Repeated execution or erroneous triggering of external interrupt service functions will lead to erroneous operation of the device, which will not cause serious harm in most computer application fields. However, in airborne embedded computer devices, repeated execution or erroneous triggering of external interrupt service functions will lead to erroneous operation of the airborne device, which will seriously endanger the reliability and safety of the device, which is unacceptable for safety-critical airborne embedded devices.

[0006] In order to ensure the safety and reliability of airborne embedded devices, a method is needed to prevent external interrupt service functions from being repeatedly executed or erroneously executed. Summary of the invention

[0007] In view of this, the embodiments of the present specification provide a method for preventing repeated execution or erroneous execution of an external interrupt service function, so as to achieve the purpose of improving the security and reliability of an onboard embedded device.

[0008] The embodiments of this specification provide the following technical solutions:

[0009] A method for preventing repeated execution or erroneous execution of an external interrupt service function, comprising:

[0010] Get the trigger mode of the external interrupt, where the trigger modes include level trigger, single jump edge trigger and double jump edge trigger;

[0011] According to the trigger mode, detect whether the trigger level appears. If it appears, the external interrupt is triggered and the external interrupt service function is executed;

[0012] If the trigger mode is level trigger, the subsequent execution of the external interrupt service function is controlled by the method in the level trigger mode;

[0013] If the trigger mode is double-edge trigger, the subsequent execution of the external interrupt service function is controlled by the method under the double-edge trigger mode;

[0014] If the trigger mode is single-edge trigger, the subsequent execution of the external interrupt service function is controlled by the method under the single-edge trigger mode.

[0015] Furthermore, the subsequent execution of the external interrupt service function is controlled by a level-triggered method, including:

[0016] Disable the external interrupt enable;

[0017] Set the first timer, set the mode of the first timer to single timing, and set the timing time to T a1 , start the first timer;

[0018] CPU exits external interrupt service function;

[0019] When the first timer ends, the CPU automatically executes the interrupt service function of the first timer.

[0020] Furthermore, the CPU automatically executes the interrupt service function of the first timer, including:

[0021] In the interrupt service function of the first timer, detect whether the current pin level is the trigger level;

[0022] If it is a trigger level, execute the user processing program;

[0023] Set the second timer, set the mode of the second timer to single timer, and set the timer time to T a2 , start the second timer;

[0024] The CPU exits the interrupt service function of the first timer;

[0025] When the second timer ends, the CPU automatically executes the interrupt service function of the second timer;

[0026] In the interrupt service function of the second timer, the external interrupt is enabled and the interrupt service function of the second timer is exited.

[0027] Furthermore, it also includes:

[0028] If it is not a trigger level, restore the enable of external interrupt;

[0029] The entire process ends after the CPU exits the timer interrupt service function.

[0030] Furthermore, the subsequent execution of the external interrupt service function is controlled by a method in a double-edge trigger mode, including:

[0031] Disable the external interrupt enable;

[0032] Execute user handler;

[0033] Set the third timer, set the mode of the third timer to single timing, and set the timing time to T b , start the third timer;

[0034] CPU exits external interrupt service function;

[0035] When the third timer ends, the CPU automatically executes the interrupt service function of the third timer;

[0036] Restore the enable of external interrupts and exit the interrupt service function of the third timer.

[0037] Further, the subsequent execution of the external interrupt service function is controlled by a method in a single-edge trigger mode, including:

[0038] Disable the external interrupt enable;

[0039] Execute user handler;

[0040] Set the fourth timer, set the mode of the fourth timer to single timing, and set the timing time to T c1 , start the fourth timer;

[0041] CPU exits external interrupt service function;

[0042] When the fourth timer ends, the CPU automatically executes the interrupt service function of the fourth timer;

[0043] The trigger mode of the external interrupt is set to level trigger, the trigger level is the starting level of the single jump edge, and the external interrupt is restored to enable;

[0044] The CPU exits the interrupt service function of the fourth timer;

[0045] The single jump edge is one of the rising edge and the falling edge, and the trigger level is one of the high level and the low level;

[0046] The single transition edge ends, the pin level is restored to the starting level of the single transition edge, an external interrupt is triggered, and the CPU enters the external interrupt service function again;

[0047] Disable the external interrupt enable;

[0048] A fifth timer is set, and subsequent execution of the external interrupt service function is controlled by the fifth timer.

[0049] Further, a fifth timer is set, and the subsequent execution of the external interrupt service function is controlled by the fifth timer, including:

[0050] Set the fifth timer mode to single timer and set the timer time to T c2 , start the fifth timer;

[0051] CPU exits external interrupt service function;

[0052] When the fifth timer ends, the CPU automatically executes the interrupt service function of the fifth timer;

[0053] Setting the trigger mode of the external interrupt to the single-jump edge trigger mode, and restoring the enable of the external interrupt;

[0054] Exit the interrupt service function of the fifth timer.

[0055] Compared with the prior art, the at least one technical solution adopted in the embodiments of this specification can achieve the following beneficial effects:

[0056] Avoid repeated execution or erroneous execution of the processor's external interrupt service function, avoid erroneous actions of the onboard embedded device, and improve the reliability and safety of the onboard embedded device. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0058] Figure 1 This is a schematic diagram of the classification of external interrupt triggering methods;

[0059] Figure 2 This is a schematic diagram of the repeated execution of the external interrupt service function;

[0060] Figure 3This is a schematic diagram of the external interrupt service function being executed incorrectly;

[0061] Figure 4 It is a schematic diagram of the external interrupt service function being repeatedly executed due to the glitch;

[0062] Figure 5 is a flow chart of a method for preventing repeated execution or erroneous execution of an external interrupt service function according to an embodiment of the present invention;

[0063] Figure 6 is a flow chart of a method in a level triggering mode according to an embodiment of the present invention;

[0064] Figure 7 is a flow chart of a method in a double-jump edge triggering mode according to an embodiment of the present invention;

[0065] Figure 8 It is a flow chart of the method in the single jump edge triggering mode of an embodiment of the present invention. DETAILED DESCRIPTION

[0066] The embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0067] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0068] like Figure 5 As shown, a method for preventing repeated execution or erroneous execution of an external interrupt service function includes:

[0069] S101, obtaining a trigger mode of an external interrupt, wherein the trigger mode includes level trigger, single-edge trigger and double-edge trigger;

[0070] S102, detecting whether a trigger level appears according to the trigger mode, if so, the external interrupt is triggered and the external interrupt service function is executed;

[0071] S103, if the trigger mode is level trigger, then control the subsequent execution of the external interrupt service function by the method in the level trigger mode;

[0072] S104, if the trigger mode is double-jump edge trigger, then control the subsequent execution of the external interrupt service function by the method under the double-jump edge trigger mode;

[0073] S105. If the trigger mode is single-edge trigger, the subsequent execution of the external interrupt service function is controlled by the method in the single-edge trigger mode, wherein the single-edge trigger mode is divided into rising edge trigger and falling edge trigger.

[0074] This method includes the following sub-methods:

[0075] (1) Methods to avoid repeated execution or false triggering of EXTISR in level trigger mode;

[0076] (2) Method to avoid repeated execution of EXTISR in double-edge trigger mode;

[0077] (3) Method to avoid repeated execution of EXTISR in single-edge trigger mode.

[0078] Specifically, the following functions can be realized:

[0079] For level triggering, it can achieve:

[0080] (1) After being triggered, the external interrupt service function will not be executed repeatedly until the pin level changes to the non-trigger level;

[0081] (2) The interrupt service function is executed only when the trigger level meets the certain time, so as to avoid the external interrupt being mistakenly triggered by the interference level with extremely short duration.

[0082] For the transition edge triggering mode (including the single transition edge triggering mode and the double transition edge triggering mode), it can be achieved that the edge glitch will not cause the external interrupt service function to be executed repeatedly.

[0083] Specifically, Figure 6 As shown, the method in the level triggering mode includes the following steps:

[0084] 1. Configure the external interrupt as level trigger mode, whether it is high level trigger or low level trigger depends on actual needs;

[0085] 2. The trigger level appears and the external interrupt is triggered;

[0086] 3.CPU enters the external interrupt service function;

[0087] 4. Turn off the external interrupt enable to prevent the external interrupt from being continuously triggered by the trigger level;

[0088] 5. Set the timer to single timing mode, and the timing time is T a1 And start the timing, the purpose is to pass the timing T a1 Detect whether the trigger level duration reaches T a1 Duration, to avoid very short-duration interference levels or glitches from falsely triggering external interrupts;

[0089] 6.CPU exits the external interrupt service function;

[0090] 7. Timing time T a1 At this time, the CPU enters the interrupt service function of the timer;

[0091] 8. Check whether the pin level is still the trigger level. If not, restore the external interrupt enable and end the entire process after the CPU exits the timer interrupt service function. If yes, proceed to the next step. The trigger level is one of the high level and the low level.

[0092] 9. Execute the user processing program originally to be executed in the external interrupt service function in the timer ISR;

[0093] 10. Set the timer to single timing mode, and the timing time is T a2 And start the timing, the purpose is to pass the timing T a2 Skip the time period when the trigger level lasts and the burrs when the trigger level disappears;

[0094] 11.CPU exits the timer interrupt service function;

[0095] 12. Timing time T a2 When the timer is reached, the CPU enters the ISR (interrupt service function) of the timer again, restores the external interrupt enable, and the CPU exits the ISR (interrupt service function) of the timer again;

[0096] 13. The end.

[0097] like Figure 7 As shown, the method under the double-edge triggering mode includes the following steps:

[0098] 1. Configure the external interrupt to be edge triggered;

[0099] 2. The transition edge appears, the external interrupt is triggered, and the CPU enters the external interrupt service function;

[0100] 3. Turn off the external interrupt enable to prevent the current transition edge glitch from triggering the transition edge interrupt again;

[0101] 4. Execute user processing program;

[0102] 5. Set the timer to single timing mode, and the timing time is T b And start the timing, the purpose is to pass the timing T b To skip the glitch of this transition edge and restore the external interrupt enable;

[0103] 6.CPU exits the external interrupt service function;

[0104] 7. Timing time T b At this time, the CPU enters the interrupt service function of the timer;

[0105] 8. Restore external interrupt enable;

[0106] 9.CPU exits the timer interrupt service function;

[0107] 10. End.

[0108] like Figure 8 As shown, the method under the single jump edge trigger mode (divided into falling edge trigger mode and rising edge trigger mode) includes the following steps:

[0109] 1. Configure the external interrupt as falling edge trigger (if the trigger mode is rising edge trigger, configure the external interrupt as rising and falling edge trigger);

[0110] 2. A falling edge occurs (if the trigger mode is rising edge trigger, a rising edge occurs), the external interrupt is triggered, and the CPU enters the external interrupt service function;

[0111] 3. Turn off the external interrupt enable to avoid the edge glitch triggering the falling edge interrupt again;

[0112] 4. Execute user processing program;

[0113] 5. Set the timer to single timing mode, and the timing time is T c1 , and start the timing, the purpose is to pass the timing T c1 To skip along the burr;

[0114] 6.CPU exits the external interrupt service function;

[0115] 7. Timing time T c1 At this time, the CPU enters the interrupt service function of the timer;

[0116] 8. Set the external interrupt to level trigger mode, the trigger level is the starting level of a single jump edge, and restore the external interrupt enable to capture the moment when the level is restored to the starting level of a single jump edge;

[0117] 9.CPU exits the timer interrupt service function;

[0118] 10. The rising edge appears (if the trigger mode is rising edge trigger, the falling edge appears), and its high level (if the trigger mode is rising edge trigger, the low level) triggers the external interrupt, and the CPU enters the external interrupt service function again;

[0119] 11. Disable external interrupt enable, set the timer to single timing mode, and set the timing time to T c2 , and start the timer, the purpose is to pass the timing T c2 The edge glitch in the process of skipping the level and restoring to the high level (if the trigger mode is rising edge trigger, low level);

[0120] 12.CPU exits the external interrupt service function;

[0121] 13. Timing time T c2 At this time, the CPU enters the interrupt service function of the timer;

[0122] 14. Set the external interrupt to the falling edge (if the trigger mode is rising edge trigger, rising edge), and restore the external interrupt enable;

[0123] 15.CPU exits the timer interrupt service function;

[0124] 16. The end.

[0125] Beneficial effects of the embodiments of the present invention:

[0126] A method for preventing a CPU external interrupt service function from being repeatedly or mistakenly executed is provided, which can prevent an external interrupt service function from being repeatedly or mistakenly executed in all external interrupt triggering modes (high level triggering, low level triggering, rising edge triggering, falling edge triggering, and transition edge triggering), so that key actions executed in the external interrupt service function, such as cumulative counting, instruction capture, missile launch, etc., will not be mistakenly or repeatedly executed, effectively improving the reliability and safety of airborne equipment.

[0127] The above is only a specific embodiment of the present invention, and cannot be used to limit the scope of the invention. Therefore, the replacement of equivalent components, or equivalent changes and modifications made according to the scope of protection of the patent of the present invention, should still fall within the scope of this patent. In addition, the technical features of the present invention can be freely combined with each other, with each other, and with each other.

Claims

1. A method for preventing repeated or erroneous execution of an external interrupt service function, characterized in that: include: Obtaining a trigger mode of an external interrupt, wherein the trigger mode includes level triggering, single-edge triggering, and double-edge triggering; Detecting whether a trigger level occurs according to the trigger mode, if so, an external interrupt is triggered and an external interrupt service function is executed; If the trigger mode is the level trigger, the subsequent execution of the external interrupt service function is controlled by the method in the level trigger mode; If the trigger mode is the double-edge trigger, the subsequent execution of the external interrupt service function is controlled by the method under the double-edge trigger mode; If the trigger mode is the single-jump edge trigger, the subsequent execution of the external interrupt service function is controlled by the method under the single-jump edge trigger mode.

2. The method for preventing repeated or erroneous execution of an external interrupt service function according to claim 1, characterized in that: The subsequent execution of the external interrupt service function is controlled by a method in a level-triggered manner, including: Turn off the enable of the external interrupt; Set the first timer, set the mode of the first timer to single timing, and set the timing time to T a1 , start the first timer; The CPU exits the external interrupt service function; When the first timer ends, the CPU automatically executes the interrupt service function of the first timer.

3. The method for preventing repeated or erroneous execution of an external interrupt service function according to claim 2, characterized in that: The CPU automatically executes the interrupt service function of the first timer, including: In the interrupt service function of the first timer, detecting whether the current pin level is a trigger level; If it is the trigger level, executing the user processing program in the external interrupt service function, the trigger level is one of a high level and a low level; Set the second timer, set the mode of the second timer to single timing, and set the timing time to T a2 , start the second timer; The CPU exits the interrupt service function of the first timer; When the second timer ends, the CPU automatically executes the interrupt service function of the second timer; In the interrupt service function of the second timer, the enabling of the external interrupt is restored, and the interrupt service function of the second timer is exited.

4. The method for preventing repeated or erroneous execution of an external interrupt service function according to claim 3, characterized in that: Also includes: If it is not the trigger level, resuming the enabling of the external interrupt; The entire process ends after the CPU exits the interrupt service function of the first timer.

5. The method for preventing repeated or erroneous execution of an external interrupt service function according to claim 1, characterized in that: The method of controlling the subsequent execution of the external interrupt service function in a double-edge triggering mode includes: Turn off the enable of the external interrupt; Execute user handler; Set a third timer, set the mode of the third timer to single timing, and set the timing time to T b , start the third timer; The CPU exits the external interrupt service function; When the third timer ends, the CPU automatically executes the interrupt service function of the third timer; Restore the enabling of the external interrupt and exit the interrupt service function of the third timer.

6. The method for preventing repeated or erroneous execution of an external interrupt service function according to claim 1, characterized in that: The method of controlling the subsequent execution of the external interrupt service function in a single-edge trigger mode includes: Turn off the enable of the external interrupt; Execute user handler; Set the fourth timer, set the mode of the fourth timer to single timing, and set the timing time to T c1 , start the fourth timer; The CPU exits the external interrupt service function; When the fourth timer ends, the CPU automatically executes the interrupt service function of the fourth timer; Setting the trigger mode of the external interrupt to level trigger, the trigger level being the starting level of the single transition edge, and restoring the enabling of the external interrupt; The CPU exits the interrupt service function of the fourth timer; The single transition edge is one of a rising edge and a falling edge, and the trigger level is one of a high level and a low level; The single transition edge ends, the pin level is restored to the starting level of the single transition edge, the external interrupt is triggered, and the CPU enters the external interrupt service function again; Turn off the enable of the external interrupt; A fifth timer is set, and the subsequent execution of the external interrupt service function is controlled by the fifth timer.

7. The method for preventing repeated or erroneous execution of an external interrupt service function according to claim 6, characterized in that: Setting a fifth timer, and controlling subsequent execution of the external interrupt service function by the fifth timer, comprises: Set the mode of the fifth timer to single timing, and set the timing time to T c2 , start the fifth timer; The CPU exits the external interrupt service function; When the fifth timer ends, the CPU automatically executes the interrupt service function of the fifth timer; Setting the trigger mode of the external interrupt to the single-edge trigger mode, and restoring the enabling of the external interrupt; The CPU exits the interrupt service function of the fifth timer.