Method for improving determinacy of watchdog test
By conducting comprehensive inspection of the watchdog, including setting accuracy, timing function, timing accuracy and interrupt accuracy, traditional testing methods cannot meet the requirements of high-safe and high-reliability systems for watchdog monitoring time accuracy, achieving higher test certainty and system security.
Patent Information
- Application Number
- CN202411966683.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-06-20
AI Technical Summary
Traditional watchdog testing methods cannot meet the security and reliability requirements of high-security and high-reliability systems, especially the inability to effectively test the watchdog monitoring time accuracy.
A method to improve the certainty of the watchdog test is proposed, which detects the correctness of the watchdog's setting, timing function, timing accuracy, interrupt accuracy, timing status after the dog barking and the monitoring accuracy of the dog barking.
This method improves the certainty of watchdog testing, effectively improves the safety and reliability of the system, and ensures the correctness and reliability of watchdog functions.
Smart Images

Figure CN120179441A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to watchdog testing and airborne embedded computer software technology with high safety and high reliability requirements, and particularly to a method for improving the determinacy of watchdog testing. Background Art
[0002] In airborne embedded devices, due to the possibility that the operation of the airborne computer may be affected by external electromagnetic field interference and internal abnormal interrupts, the program may run wild and fall into an infinite loop, interrupting the normal operation of the program. The system controlled by the computer cannot continue to work, causing the entire system to stall, which will cause very serious consequences for the airborne system. Therefore, considering the need to monitor the running state of the computer in real time, a chip dedicated to monitoring the running state of the computer program, commonly known as the "watchdog" or Watch Dog, has been developed.
[0003] Generally, each airborne computer processor node provides one or more programmable watchdog timers, implemented by FPGA, using a decrement counting method. The counter width is 32 bits, and it is default disabled when powered on. It can be enabled or disabled by writing 1 or 0 to the register through software. The watchdog timing period can be set by setting the initial value of the timer in the register, and the current value of the watchdog timer can be queried through a read-only register. The watchdog timer should be fed by software every cycle. The feeding operation will cause the count value of the watchdog timer to return to the initial value and start decrementing again. When the software runs abnormally and the feeding operation is not performed for a long time, the watchdog timer decrements to zero and generates an alarm signal (usually called a barking signal). The barking signal will be reported to the processor in the form of an interrupt.
[0004] To ensure the correctness of the watchdog function, airborne software will perform watchdog testing before enabling the watchdog function. However, general testing methods only perform a single test on the watchdog monitoring function, that is, enabling the watchdog and not performing the feeding operation within the watchdog monitoring time to check whether the watchdog interrupt can be triggered, without testing the accuracy of the barking time monitored by the watchdog. Traditional testing methods cannot meet the requirements of airborne high-security systems for safety and reliability because functional testing cannot cover performance testing. If the accuracy error of the watchdog monitoring time exceeds the maximum range allowed by the system, it will cause very serious consequences for high-security systems, especially high-security control systems. Summary of the Invention
[0005] Based on the above background, the present invention provides a method for improving the determinacy of watchdog testing. This method can perform functional and performance tests on the watchdog respectively, and solves the problems of watchdog monitoring function and monitoring time accuracy testing.
[0006] In view of this, according to one aspect of the embodiments of the present invention, a method for improving the determinacy of watchdog testing is provided, including:
[0007] Step 1, check the correctness of the watchdog settings. The check content includes:
[0008] Whether the set bark time exceeds the maximum monitoring time allowed by the watchdog chip;
[0009] Whether the set bark time is the expected correct bark time.
[0010] Step 2, watchdog timing function detection. After enabling the watchdog, detect whether the watchdog timing function is running normally, and check whether the value of the watchdog timer changes within the interval.
[0011] Step 3, watchdog timing accuracy detection. After enabling the watchdog, detect whether the watchdog timing accuracy is within the error range. Obtain the values of the watchdog timer at three - quarters of the bark time, one - half of the bark time, and one - quarter of the bark time respectively, and determine whether the obtained values of the watchdog timer are within the allowed error range.
[0012] Step 4, watchdog interrupt detection. After detecting the bark time, check whether the watchdog interrupt is correctly triggered, and whether the watchdog interrupt service program is triggered and executed correctly.
[0013] Step 5, watchdog timing status detection after the watchdog barks. After detecting the bark time, check whether the watchdog timer stops timing, and check whether the values of the watchdog timer are equal within the interval.
[0014] Step 6, after detecting the bark time, check whether the monitoring accuracy of the bark time is within the allowed error range, and monitor the watchdog timing accuracy using other system clocks.
[0015] Optionally, the step of checking the correctness of the watchdog settings includes: initialization parameter check and initialization process check.
[0016] The initialization parameter check includes watchdog interrupt vector number check and watchdog monitoring cycle time check;
[0017] The initialization process check includes hooking the watchdog interrupt service program check;
[0018] If both the initialization parameter check and the initialization process check are normal, then go to Step 2; otherwise, record the fault code and go to Step 2.
[0019] Optionally, after the watchdog initialization is completed, obtain the value of the watchdog timer, and the value of the watchdog timer is equal to the watchdog monitoring cycle time set during the watchdog initialization.
[0020] Turn on the watchdog interrupt again and enable the watchdog, and obtain the clock value of the operating system clock as the first clock value;
[0021] Obtain the value of the watchdog timer again. If the values of the watchdog timer obtained twice are not equal, it means that the watchdog timer has started working, and go to step 3; otherwise, it means that the watchdog timer is not working, the watchdog function is abnormal, record the fault code, and go to step 3.
[0022] Optionally, after the watchdog timing function is detected correctly, obtain the value of the watchdog timer at three-quarters of the watchdog monitoring period time, half of the watchdog monitoring period time, and one-quarter of the watchdog monitoring period time respectively, and compare the obtained values of the watchdog timer with three-quarters of the watchdog monitoring period time, half of the watchdog monitoring period time, and one-quarter of the watchdog monitoring period time respectively. If the error range is within ±5%, it means that the watchdog timing accuracy is normal, and go to step 4; otherwise, it means that the watchdog timing accuracy is abnormal, record the fault code, and go to step 4.
[0023] Optionally, after the watchdog timing accuracy is detected correctly, wait for one-quarter of the watchdog monitoring period time and then trigger the watchdog interrupt, that is, the watchdog barks. The operating system will execute the watchdog interrupt service program. The execution process of the service program includes obtaining the clock value of the current system clock as the second clock value, setting the watchdog interrupt flag to valid, feeding the dog, disabling the watchdog, and turning off the watchdog interrupt. After the interrupt service program is executed, the program will resume running. The test program needs to detect whether the watchdog interrupt flag is valid. If it is valid, it means that the watchdog interrupt is triggered, and go to step 5; otherwise, it means that the watchdog interrupt is not triggered, record the fault code, and go to step 5.
[0024] Optionally, after the watchdog interrupt is detected correctly, obtain the value of the watchdog timer twice continuously, and judge whether the value of the watchdog timer is equal to 0 and whether the values obtained twice are equal,
[0025] If the value of the timer is equal to 0 and the values obtained twice are equal, it means that the dog feeding and dog disabling functions are normal, and go to step 6; otherwise, record the fault code, and go to step 6.
[0026] Optionally, after the timing state of the watchdog is detected correctly after it barks, calculate the absolute value a of the difference between the first clock value and the second clock value, and calculate the difference b between the absolute value a and the watchdog monitoring period time. If the error range of the difference b is within ±5%, it means that the watchdog monitoring time accuracy detection is normal, and go to step 7; otherwise, record the fault code, and go to step 7.
[0027] Step 7, return the watchdog determinism test result.
[0028] Optionally, check the correctness of the watchdog settings. The checking content includes whether the set barking time exceeds the maximum monitoring time allowed by the watchdog chip; whether the set barking time is the expected correct barking time.
[0029] In airborne embedded devices, due to the possibility that the operation of the airborne computer may be affected by external electromagnetic fields and internal abnormal interrupts, the program may run wild, thus falling into an "infinite loop", the normal operation of the program is interrupted, and the system controlled by the computer cannot continue to work, which will cause the entire system to stall, resulting in very serious consequences for the airborne system. Therefore, out of the consideration of real-time monitoring of the computer operation status, a chip dedicated to monitoring the operation status of the computer program, commonly known as the "watchdog", i.e., Watch Dog, has emerged. To ensure the correctness of the watchdog function, the airborne software will perform a watchdog test before enabling the watchdog function. However, the general test methods only perform a single test on the watchdog monitoring function, that is, only test the watchdog barking function, and do not test the accuracy of the barking time monitored by the watchdog. For airborne high-security and high-reliability systems, the traditional test methods cannot meet the requirements of system security and reliability. Aiming at the above deficiencies, the present invention proposes a method to improve the certainty of watchdog testing. The test content is shown in the attached drawings, including the detection of the setting correctness, timing function, timing accuracy, interrupt correctness, and the timing status after barking and the monitoring accuracy of the barking time of the watchdog. This method improves the certainty of watchdog testing compared with the traditional watchdog testing method. For high-security and high-reliability systems, this method effectively improves the security and reliability of the system. Description of the Drawings
[0030] Figure 1 It is the flowchart of the watchdog deterministic test.
[0031] Figure 2 It is the flowchart of the watchdog initialization. Detailed Embodiments
[0032] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0033] According to one aspect of the embodiments of the present invention, a method for improving the certainty of watchdog testing is provided, including:
[0034] Step 1, check the correctness of the watchdog settings. The checking content includes:
[0035] Whether the set barking time exceeds the maximum monitoring time allowed by the watchdog chip;
[0036] Whether the set barking time is the expected correct barking time.
[0037] Step 2, watchdog timing function detection. After enabling the watchdog, detect whether the watchdog timing function is running properly, and check whether the value of the watchdog timer changes within the interval.
[0038] Step 3, watchdog timing accuracy detection. After enabling the watchdog, detect whether the watchdog timing accuracy is within the error range. Obtain the values of the watchdog timer at three - quarters of the barking time, half of the barking time, and one - quarter of the barking time respectively, and determine whether the obtained values of the watchdog timer are within the allowed error range.
[0039] Step 4, watchdog interrupt detection. After detecting the barking time, check whether the watchdog interrupt is correctly triggered, and whether the watchdog interrupt service program is triggered and executed correctly.
[0040] Step 5, watchdog timing status detection after barking. After detecting the barking time, check whether the watchdog timer stops timing, and check whether the values of the watchdog timer are equal within the interval.
[0041] Step 6, after detecting the barking time, check whether the monitoring accuracy of the barking time is within the allowed error range, and monitor the watchdog timing accuracy using other system clocks.
[0042] Furthermore, the steps for checking the correctness of the watchdog settings include: initialization parameter check and initialization process check.
[0043] The initialization parameter check includes watchdog interrupt vector number check and watchdog monitoring cycle time check;
[0044] The initialization process check includes hooking up the watchdog interrupt service program check;
[0045] If both the initialization parameter check and the initialization process check are normal, go to Step 2; otherwise, record the fault code and go to Step 2.
[0046] Furthermore, after the watchdog initialization is completed, obtain the value of the watchdog timer, and the value of the watchdog timer is equal to the watchdog monitoring cycle time set during watchdog initialization;
[0047] Then turn on the watchdog interrupt and enable the watchdog, and obtain the clock value of the operating system clock as the first clock value;
[0048] Obtain the value of the watchdog timer again. If the values of the watchdog timer obtained twice are not equal, it indicates that the watchdog timer has started working, and proceed to step 3; otherwise, it indicates that the watchdog timer is not working, the watchdog function is abnormal, record the fault code, and proceed to step 3.
[0049] Further, after the watchdog timing function is detected correctly, obtain the value of the watchdog timer at three - quarters of the watchdog monitoring period, at half of the watchdog monitoring period, and at one - quarter of the watchdog monitoring period respectively, and compare the obtained values of the watchdog timer with three - quarters of the watchdog monitoring period, half of the watchdog monitoring period, and one - quarter of the watchdog monitoring period respectively. If the error range is within ±5%, it indicates that the watchdog timing accuracy is normal, and proceed to step 4; otherwise, it indicates that the watchdog timing accuracy is abnormal, record the fault code, and proceed to step 4.
[0050] Further, after the watchdog timing accuracy is detected correctly, wait for one - quarter of the watchdog monitoring period and then trigger the watchdog interrupt, that is, the watchdog barks. The operating system will execute the watchdog interrupt service program. The execution process of the service program includes obtaining the clock value of the current system clock as the second clock value, setting the watchdog interrupt flag to valid, feeding the dog, disabling the watchdog, and closing the watchdog interrupt. After the execution of the interrupt service program is completed, the program will resume running. The test program needs to detect whether the watchdog interrupt flag is valid. If it is valid, it indicates that the watchdog interrupt is triggered, and proceed to step 5; otherwise, it indicates that the watchdog interrupt is not triggered, record the fault code, and proceed to step 5.
[0051] Further, after the watchdog interrupt is detected correctly, obtain the value of the watchdog timer twice continuously, and judge whether the value of the watchdog timer is equal to 0 and whether the values obtained twice are equal.
[0052] If the value of the timer is equal to 0 and the values obtained twice are equal, it indicates that the dog - feeding and dog - disabling functions are normal, and proceed to step 6; otherwise, record the fault code, and proceed to step 6.
[0053] Further, after the timing state detection is correct after the watchdog barks, calculate the absolute value a of the difference between the first clock value and the second clock value, and calculate the difference b between the absolute value a and the watchdog monitoring period. If the error range of the difference b is within ±5%, it indicates that the watchdog monitoring time accuracy detection is normal, and proceed to step 7; otherwise, record the fault code, and proceed to step 7.
[0054] Step 7, return the watchdog deterministic test result.
[0055] Further, check the correctness of the watchdog settings. The check content includes whether the set watchdog barking time exceeds the maximum monitoring time allowed by the watchdog chip; whether the set watchdog barking time is the expected correct watchdog barking time.
[0056] Example 1
[0057] The present invention provides a method for improving the determinacy of watchdog testing, and its features include the following aspects:
[0058] 1. A watchdog testing method
[0059] Step 1: Check the correctness of the watchdog settings. The checking contents include:
[0060] Whether the set barking time exceeds the maximum monitoring time allowed by the watchdog chip;
[0061] Whether the set barking time is the expected correct barking time.
[0062] Step 2: Detect the watchdog timing function. After enabling the watchdog, detect whether the watchdog timing function runs normally, and check whether the value of the watchdog timer changes within the interval.
[0063] Step 3: Detect the watchdog timing accuracy. After enabling the watchdog, detect whether the watchdog timing accuracy is within the error range. Obtain the values of the watchdog timer at three - quarters of the barking time, one - half of the barking time, and one - quarter of the barking time respectively, and determine whether the obtained values of the watchdog timer are within the allowed error range.
[0064] Step 4: Detect the watchdog interrupt. After detecting the barking time, check whether the watchdog interrupt is correctly triggered, and whether the watchdog interrupt service program is triggered and executed correctly.
[0065] Step 5: Detect the timing state after the watchdog barks. After detecting the barking time, check whether the watchdog timer stops timing, and check whether the values of the watchdog timer are equal within the interval.
[0066] Step 6: After detecting the barking time, check whether the monitoring accuracy of the barking time is within the allowed error range, and monitor the watchdog timing accuracy using other system clocks.
[0067] 2. The steps for checking the correctness of the watchdog settings include: initialization parameter check and initialization process check.
[0068] The initialization parameter check includes the watchdog interrupt vector number check and the watchdog monitoring cycle time check;
[0069] The initialization process check includes the check for attaching the watchdog interrupt service program;
[0070] If both the initialization parameter check and the initialization process check are normal, proceed to step 2; otherwise, record the fault code and proceed to step 23. After the watchdog initialization is complete, obtain the value of the watchdog timer, and the value of the watchdog timer is equal to the watchdog monitoring cycle time set during watchdog initialization;
[0071] Then open the watchdog interrupt and enable the watchdog, and obtain the clock value of the operating system clock as the first clock value;
[0072] Obtain the value of the watchdog timer again. If the values of the watchdog timer obtained twice are not equal, it means the watchdog timer has started working, and proceed to step 3; otherwise, it means the watchdog timer is not working, the watchdog function is abnormal, record the fault code, and proceed to step 3.
[0073] 4. After the watchdog timing function is detected correctly, obtain the value of the watchdog timer at three - quarters of the watchdog monitoring cycle time, half of the watchdog monitoring cycle time, and one - quarter of the watchdog monitoring cycle time respectively, and compare the obtained values of the watchdog timer with three - quarters of the watchdog monitoring cycle time, half of the watchdog monitoring cycle time, and one - quarter of the watchdog monitoring cycle time respectively. If the error range is within ±5%, it means the watchdog timing accuracy is normal, and proceed to step 4; otherwise, it means the watchdog timing accuracy is abnormal, record the fault code, and proceed to step 4.
[0074] 5. After the watchdog timing accuracy is detected correctly, wait for one - quarter of the watchdog monitoring cycle time and then trigger the watchdog interrupt, that is, the watchdog barks. The operating system will execute the watchdog interrupt service program. The execution process of the service program includes obtaining the clock value of the current system clock as the second clock value, setting the watchdog interrupt flag to valid, feeding the dog, disabling the watchdog, and closing the watchdog interrupt. After the interrupt service program is executed, the program will resume running. The test program needs to detect whether the watchdog interrupt flag is valid. If it is valid, it means the watchdog interrupt is triggered, and proceed to step 5; otherwise, it means the watchdog interrupt is not triggered, record the fault code, and proceed to step 5.
[0075] 6. After the watchdog interrupt is detected correctly, obtain the value of the watchdog timer twice continuously, and judge whether the value of the watchdog timer is equal to 0 and whether the values obtained twice are equal.
[0076] If the value of the timer is equal to 0 and the values obtained twice are equal, it means the dog - feeding and dog - disabling functions are normal, and proceed to step 6; otherwise, record the fault code and proceed to step 6.
[0077] 7. After the watchdog barks and the timing status is detected correctly, calculate the absolute value a of the difference between the first clock value and the second clock value. Then calculate the difference b between the absolute value a and the watchdog monitoring cycle time. If the error range of the difference b is within ±5%, it indicates that the watchdog monitoring time accuracy test is normal, and proceed to step 7; otherwise, record the fault code and proceed to step 7. 8. In step 7, count the fault codes in steps 1 to 6.
[0078] If the tested fault code is non-zero, return that the watchdog deterministic test fails and return the fault code; otherwise, return that the watchdog deterministic test succeeds.
[0079] Check the correctness of the watchdog settings. The checking content includes whether the set barking time exceeds the maximum monitoring time allowed by the watchdog chip; whether the set barking time is the expected correct barking time.
[0080] 1. After enabling the watchdog, detect whether the watchdog timing function is running normally, that is, check whether the value of the watchdog timer changes within the interval.
[0081] 2. After enabling the watchdog, detect whether the watchdog timing accuracy is within the error range, that is, obtain the values of the watchdog timer at three-quarters of the barking time, half of the barking time, and one-quarter of the barking time respectively, and determine whether the value is within the allowed error range.
[0082] 3. After detecting the barking time, check whether the watchdog interrupt is triggered correctly, that is, whether the watchdog interrupt service program is triggered and executed correctly.
[0083] 4. After detecting the barking time, check whether the watchdog timer stops timing, that is, check whether the values of the watchdog timer are equal within the interval.
[0084] 5. After detecting the barking time, check whether the monitoring accuracy of the barking time is within the allowed error range, that is, monitor the watchdog timing accuracy using other system clocks.
[0085] Embodiment 2
[0086] The present invention provides a method for improving the determinacy of watchdog testing. This method can perform functional and performance tests on the watchdog respectively, and solves the problems of watchdog monitoring function and monitoring time accuracy testing.
[0087] The present invention includes the following contents:
[0088] 1. First, check the correctness of the watchdog settings. The checking content includes whether the set barking time exceeds the maximum monitoring time allowed by the watchdog chip; whether the set barking time is the expected correct barking time.
[0089] 2. After enabling the watchdog, detect whether the watchdog timing function is operating properly, that is, check whether the value of the watchdog timer changes within the interval.
[0090] 3. After enabling the watchdog, detect whether the watchdog timing accuracy is within the error range, that is, obtain the values of the watchdog timer at three - quarters of the bark time, half of the bark time, and one - quarter of the bark time respectively, and determine whether the value is within the allowed error range.
[0091] 4. After detecting the bark time, check whether the watchdog interrupt is correctly triggered, that is, whether the watchdog interrupt service routine is triggered and executed correctly.
[0092] 5. After detecting the bark time, check whether the watchdog timer stops timing, that is, check whether the values of the watchdog timer are equal within the interval.
[0093] 6. After detecting the bark time, check whether the monitoring accuracy of the bark time is within the allowed error range, that is, monitor the watchdog timing accuracy using other system clocks.
[0094] Embodiment 3
[0095] As Figure 1-2 shown, the present invention provides a method for improving the determinacy of watchdog testing. It includes the detection of the setting correctness, timing function, timing accuracy, interrupt correctness of the watchdog, as well as the timing state after barking and the monitoring accuracy of the bark time. For high - security and high - reliability airborne systems, this method effectively improves the safety and reliability of the system using the watchdog function.
[0096] Step 1 Detection of watchdog setting correctness: Before the watchdog test, the watchdog needs to be initialized. The initialization process is as Figure 2 shown. The initialization content mainly includes the watchdog interrupt vector number, hooking up the watchdog interrupt service routine, and setting the watchdog monitoring cycle time.
[0097] Exemplarily, the test process of the present invention will check the correctness of the watchdog initialization parameters and process.
[0098] Initialize the watchdog interrupt vector number and the watchdog monitoring cycle time. The initialization process check includes hooking up the watchdog interrupt service routine. The watchdog interrupt vector number check is to determine whether the watchdog signal reported to the processor interrupt is correct. The interrupt types in an embedded system are complex. If each external signal requires the processor to respond immediately, it needs to inform the processor through the interrupt method. The interrupt vector number check can effectively prevent incorrect responses of different types of interrupts. The watchdog monitoring cycle time check is to prevent the set watchdog monitoring time from exceeding the maximum monitoring time provided by the watchdog chip and avoid setting overflow. The watchdog interrupt service routine hookup check is to check whether the watchdog interrupt service routine is successfully hooked up with the operating system's watchdog interrupt handling, to avoid the program returning a null pointer when the operating system responds to the watchdog interrupt, resulting in program exceptions. If all the above check processes are normal, go to step 2; otherwise, record the fault code and go to step 2.
[0099] Step 2 Timing function: After enabling the watchdog, detect whether the watchdog timing function is running properly, that is, check whether the value of the watchdog timer changes within the interval time.
[0100] Exemplarily, after the watchdog initialization is completed, it is necessary to first obtain the value of the watchdog timer, which should be equal to the watchdog monitoring cycle time set during watchdog initialization. Then, open the watchdog interrupt and enable the watchdog, obtain the system clock 1, and obtain the value of the watchdog timer again. If the values of the watchdog timer obtained twice are not equal, it means that the watchdog timer has started working, and go to step 3; otherwise, it means that the watchdog timer is not working, the watchdog function is abnormal, record the fault code, and go to step 3.
[0101] Step 3 Timing accuracy: After enabling the watchdog, detect whether the watchdog timing accuracy is within the error range, that is, obtain the value of the watchdog timer at three-quarters of the dog barking time, one-half of the dog barking time, and one-quarter of the dog barking time respectively, and determine whether the value is within the allowed error range.
[0102] Exemplarily, after the watchdog timing function is detected correctly, obtain the value of the watchdog timer at three-quarters of the watchdog monitoring cycle time, one-half of the watchdog monitoring cycle time, and one-quarter of the watchdog monitoring cycle time respectively, and compare the obtained values of the watchdog timer with three-quarters of the watchdog monitoring cycle time, one-half of the watchdog monitoring cycle time, and one-quarter of the watchdog monitoring cycle time respectively. If the error range is within ±5%, it means that the watchdog timing accuracy is normal, and go to step 4; otherwise, it means that the watchdog timing accuracy is abnormal, record the fault code, and go to step 4.
[0103] Step 4 Interrupt correctness: After detecting the dog barking time, check whether the watchdog interrupt is triggered correctly, that is, whether the watchdog interrupt service routine is triggered and executed correctly.
[0104] Exemplarily, after the watchdog timing accuracy test is correct, wait for a quarter of the watchdog monitoring cycle time and then trigger the watchdog interrupt, i.e., the dog barks. The operating system will execute the watchdog interrupt service program. The execution process of the service program includes obtaining the current system clock 2, setting the watchdog interrupt flag to valid, feeding the dog (clearing the interrupt), disabling the watchdog, and closing the watchdog interrupt. After the interrupt service program finishes execution, the program will resume running. The test program needs to detect whether the watchdog interrupt flag is valid. If it is valid, it means the watchdog interrupt is triggered, and go to step 5; otherwise, it means the watchdog interrupt is not triggered, record the fault code, and go to step 5.
[0105] Step 5 Timing status after the dog barks: After detecting the dog barking time, check whether the watchdog timer stops timing, that is, check whether the values of the watchdog timer are equal within the interval time.
[0106] Exemplarily, after the watchdog interrupt detection is correct, obtain the values of the watchdog timer twice continuously, and judge whether the value of the watchdog timer is equal to 0 and whether the two continuously obtained values are equal. Because the dog feeding (clearing the interrupt) and watchdog disabling settings have been made in the watchdog interrupt service program, at this time, the value of the watchdog timer should be equal to 0, and the values of the watchdog timer obtained within the interval time remain unchanged. If the value of the timer is equal to 0 and the two obtained values are equal, it means the dog feeding and watchdog disabling functions are normal, and go to step 6; otherwise, record the fault code, and go to step 6.
[0107] Step 6 Monitoring accuracy of the dog barking time: After detecting the dog barking time, check whether the monitoring accuracy of the dog barking time is within the allowable error range, that is, use other system clocks to monitor the watchdog timing accuracy.
[0108] Exemplarily, after the timing status detection after the watchdog barks is correct, calculate the absolute value of the time difference delta between the system clock time 1 obtained in step 2 and the system clock time 2 obtained in the watchdog interrupt service program in step 4, and calculate the difference between delta and the watchdog monitoring cycle time. If the error range is within ±5%, it means the watchdog monitoring time accuracy test is normal, and go to step 7; otherwise, record the fault code, and go to step 7.
[0109] Step 7, return the watchdog determinism test result.
[0110] Exemplarily, if the test fault code is non-zero, return that the watchdog determinism test fails and return the fault code; otherwise, return that the watchdog determinism test succeeds.
[0111] The above are only specific embodiments of the present invention. The present invention has been described in detail, and the parts not elaborated are conventional technologies. However, the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. The protection scope of the present invention shall be subject to the protection scope of the claims described above.
Claims
1. A method for improving the certainty of a watchdog test, characterized in that: include: Step 1: Check the correctness of the watchdog settings. The check includes: Whether the set barking time exceeds the maximum monitoring time allowed by the watchdog chip; Check whether the set barking time is the expected correct barking time. Step 2: Check the watchdog timing function. After enabling the watchdog, check whether the watchdog timing function is running normally and whether the value of the watchdog timer changes within a certain period of time. Step 3, watchdog timing accuracy detection, after enabling the watchdog, detect whether the watchdog timing accuracy is within the error range, obtain the watchdog timer value at three quarters of the dog barking time, one half of the dog barking time, and one quarter of the dog barking time, and determine whether the obtained watchdog timer value is within the allowable error range. Step 4, watchdog interrupt detection, after detecting the dog barking time, whether the watchdog interrupt is triggered correctly, and whether the watchdog interrupt service program is triggered and executed correctly. Step 5, the timing status detection after the watchdog barks, whether the watchdog timer stops timing after the dog barks, and whether the values of the watchdog timers are equal within the interval time. Step 6, after detecting the barking time, whether the monitoring accuracy of the barking time is within the allowable error range, and using other system clocks to monitor the watchdog timing accuracy.
2. The method according to claim 1, characterized in that The steps to check the correctness of the watchdog settings include: initialization parameter check and initialization process check. Initialization parameter check includes watchdog interrupt vector number check and watchdog monitoring cycle time check; The initialization process check includes the watchdog interrupt service routine check; If both the initialization parameter check and the initialization process check are normal, go to step 2; otherwise, record the fault code and go to step 2.
3. The method according to claim 1, characterized in that After the watchdog is initialized, the value of the watchdog timer is obtained. The value of the watchdog timer is equal to the watchdog monitoring cycle time set by the watchdog initialization; Then open the watchdog interrupt and enable the watchdog, and obtain the clock value of the operating system clock as the first clock value; Get the value of the watchdog timer again. If the values of the watchdog timer obtained twice are not equal, it means that the watchdog timer has started working, and go to step 3; otherwise, it means that the watchdog timer has not worked, the watchdog function is abnormal, record the fault code, and go to step 3.
4. The method according to claim 1, characterized in that: After the watchdog timing function is detected correctly, obtain the value of the watchdog timer at three quarters of the watchdog monitoring cycle time, one half of the watchdog monitoring cycle time, and one quarter of the watchdog monitoring cycle time, and compare the obtained watchdog timer value with three quarters of the watchdog monitoring cycle time, one half of the watchdog monitoring cycle time, and one quarter of the watchdog monitoring cycle time. If the error range is within ±5%, it means that the watchdog timing accuracy is normal, and go to step 4; otherwise, it means that the watchdog timing accuracy is abnormal, record the fault code, and go to step 4.
5. The method according to claim 1, characterized in that After the watchdog timing accuracy is detected correctly, the watchdog interrupt is triggered after waiting for one quarter of the watchdog monitoring cycle time, that is, the dog barks. The operating system will execute the watchdog interrupt service program. The service program execution process includes obtaining the clock value of the current system clock as the second clock value, setting the watchdog interrupt flag to be valid, feeding the dog, disabling the watchdog, and turning off the watchdog interrupt. After the interrupt service program is executed, the program will resume running. The test program needs to detect whether the watchdog interrupt flag is valid. If it is valid, it means that the watchdog interrupt is triggered, and go to step 5; Otherwise, it means that the watchdog interrupt is not triggered, record the fault code, and go to step 5.
6. The method according to claim 1, characterized in that After the watchdog interrupt is detected correctly, the watchdog timer value is obtained twice in succession to determine whether the watchdog timer value is equal to 0 and whether the values obtained twice in succession are equal. If the timer value is equal to 0 and the two values obtained are equal, it means that the dog feeding and dog blocking functions are normal, and go to step 6; otherwise, record the fault code and go to step 6.
7. The method according to claim 1, characterized in that After the timing status detection is correct after the watchdog barks, calculate the absolute value a of the difference between the first clock value and the second clock value, and then calculate the difference b between the absolute value a and the watchdog monitoring cycle time. If the error range of the difference b is within ±5%, it means that the watchdog monitoring time accuracy detection is normal, and go to step 7. Otherwise, record the fault code and go to step 7. Step 7, return the watchdog deterministic test result.
8. The method according to claim 1, characterized in that Check the correctness of the watchdog settings, including whether the set barking time exceeds the maximum monitoring time allowed by the watchdog chip; whether the set barking time is the expected correct barking time.