CN-116149968-B - Chip timer diagnostic method and device
Abstract
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for diagnosing a chip timer. The method comprises the steps of obtaining a first accumulated value of a timer in a current period and a second accumulated value of a processor in the current period, determining a first duration contained in the current period according to the first accumulated value and a first working frequency of the timer, determining a second working frequency of the processor in the current period according to the first duration and the second accumulated value, obtaining a third working frequency corresponding to the processor in a previous period, and judging whether the timer is in a normal working state or not based on the second working frequency and the third working frequency. Based on the corresponding relation between the timer and the working frequency of the processor, the working frequency of the processor is calculated in different time periods, so that whether the timer runs stably or not can be accurately determined, and the effect of real-time monitoring is achieved.
Inventors
- YANG LI
- SUN AIJUN
Assignees
- 展讯通信(天津)有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20230307
Claims (9)
- 1. A method for diagnosing a chip timer, comprising: acquiring a first accumulated value of a timer in a current period and a second accumulated value of a processor in the current period; determining a first duration included in the current period according to the first accumulated value and a first working frequency of the timer; Determining a second operating frequency of the processor in the current period according to the first duration and the second accumulated value; Acquiring a third working frequency corresponding to the processor in a previous period, and judging whether the timer is in a normal working state or not based on the second working frequency and the third working frequency; The acquiring a first accumulated value of a timer in a current period and a second accumulated value of a processor in the current period includes: Acquiring a first count value of the timer and a second count value of the processor; Running a delay program; after the delay program is detected to finish running, acquiring a third count value of the timer and a fourth count value of the processor; The difference between the third count value and the first count value is determined as the first accumulated value, and the difference between the fourth count value and the second count value is determined as the second accumulated value.
- 2. The method of claim 1, wherein the acquiring a first accumulated value of a timer during a current time period and a second accumulated value of a processor during the current time period, the method further comprising: circularly running a delay program and acquiring the running total time length of the delay program in real time; And stopping running the delay program when the running total time is detected to be longer than a first threshold value, and executing the steps of acquiring a first accumulated value of the timer in a current period and a second accumulated value of the processor in the current period.
- 3. The method of claim 1, wherein the determining whether the timer is in a normal operating state based on the second operating frequency and the third operating frequency comprises: determining a frequency difference between the second operating frequency and the third operating frequency; And if the frequency difference value is smaller than a frequency threshold value and the second working frequency is larger than a preset lowest frequency, determining that the timer is in a normal working state.
- 4. The method of claim 1, wherein the determining whether the timer is in a normal operating state based on the second operating frequency and the third operating frequency comprises: and if the second working frequency is equal to the third working frequency and the second working frequency is larger than a preset lowest frequency, determining that the timer is in a normal working state.
- 5. The method according to claim 4, wherein the method further comprises: And if the second working frequency is not equal to the third working frequency, executing the steps of acquiring the first accumulated value of the timer in the current period and the second accumulated value of the processor in the current period again in the next period and the subsequent diagnosis flow.
- 6. The method of claim 5, wherein the method further comprises: setting a counter, wherein the initial value of the counter is zero; And after each diagnosis process is executed, adding one to the counter, if the value of the counter exceeds a second threshold value, not executing the next diagnosis process, and determining that the counter is in an abnormal working state.
- 7. A chip timer diagnostic apparatus, comprising: The acquisition module is used for acquiring a first accumulated value of the timer in a current period and a second accumulated value of the processor in the current period; the determining module is used for determining a first duration included in the current period according to the first accumulated value and a first working frequency of the timer; the determining module is further configured to determine a second operating frequency of the processor in the current period according to the first duration and the second accumulated value; the processing module is used for acquiring a third working frequency corresponding to the processor in the previous period and judging whether the timer is in a normal working state or not based on the second working frequency and the third working frequency; the acquisition module is used for acquiring a first count value of the timer and a second count value of the processor; The processing module is used for running a delay program, acquiring a third count value of the timer and a fourth count value of the processor after the delay program is detected to finish running, determining a difference value between the third count value and the first count value as the first accumulated value, and determining a difference value between the fourth count value and the second count value as the second accumulated value.
- 8. An electronic device, comprising: at least one processor, and At least one memory communicatively coupled to the processor, wherein: the memory stores program instructions that are called by the processor to perform the method of any one of claims 1 to 6.
- 9. A computer readable storage medium, characterized in that the computer readable storage medium comprises a stored program, wherein the program when executed by a processor implements the method according to any one of claims 1 to 6.
Description
Chip timer diagnostic method and device Technical Field The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for diagnosing a chip timer. Background At present, many timing tasks executed by a chip are required to be triggered at a preset moment, so that a chip timer is set inside the chip to ensure that each task processed by the chip can be normally executed. The accuracy of a chip timer has an important impact on the operation of the chip, which often requires a diagnosis of the accuracy of the chip timer. The current diagnostic method of the chip timer comprises the steps of introducing a calibration chip such as a standard timer or a programmable logic device as a reference to achieve the purpose of monitoring the chip timer, and the method increases the complexity of a hardware structure, is greatly influenced by the precision of the reference chip timer and is accompanied by complex calculation and processing procedures. Disclosure of Invention The embodiment of the invention provides a diagnosis method and a diagnosis device for a chip timer, which are used for calculating the working frequency of a processor in different time periods based on the corresponding relation between the working frequencies of the timer and the processor, and can accurately determine whether the timer runs stably or not so as to achieve the effect of real-time monitoring. In a first aspect, an embodiment of the present invention provides a method for diagnosing a chip timer, including: acquiring a first accumulated value of a timer in a current period and a second accumulated value of a processor in the current period; determining a first duration included in the current period according to the first accumulated value and a first working frequency of the timer; Determining a second operating frequency of the processor in the current period according to the first duration and the second accumulated value; and acquiring a third working frequency corresponding to the processor in a previous period, and judging whether the timer is in a normal working state or not based on the second working frequency and the third working frequency. In a real-time example, the acquiring a first accumulated value of the timer during a current period and a second accumulated value of the processor during the current period, comprising: Acquiring a first count value of the timer and a second count value of the processor; Running a delay program; after the delay program is detected to finish running, acquiring a third count value of the timer and a fourth count value of the processor; The difference between the third count value and the first count value is determined as the first accumulated value, and the difference between the fourth count value and the second count value is determined as the second accumulated value. In a real-time example, the acquiring a first accumulated value of a timer during a current period and a second accumulated value of a processor during the current period, the method further comprising: circularly running a delay program and acquiring the running total time length of the delay program in real time; And stopping running the delay program when the running total time is detected to be longer than a first threshold value, and executing the steps of acquiring a first accumulated value of the timer in a current period and a second accumulated value of the processor in the current period. In a real-time example, the determining whether the timer is in a normal operating state based on the second operating frequency and the third operating frequency includes: determining a frequency difference between the second operating frequency and the third operating frequency; And if the frequency difference value is smaller than a frequency threshold value and the second working frequency is larger than a preset lowest frequency, determining that the timer is in a normal working state. In a real-time example, the determining whether the timer is in a normal operating state based on the second operating frequency and the third operating frequency includes: and if the second working frequency is equal to the third working frequency and the second working frequency is larger than a preset lowest frequency, determining that the timer is in a normal working state. In a real-time example, the method further comprises: And if the second working frequency is not equal to the third working frequency, executing the steps of acquiring the first accumulated value of the timer in the current period and the second accumulated value of the processor in the current period again in the next period and the subsequent diagnosis flow. In a real-time example, the method further comprises: setting a counter, wherein the initial value of the counter is zero; And after each diagnosis process is executed, adding one to the counter, if the value of the counter exceeds a second threshold value