Timing methods, devices, equipment, and media based on unit timers

CN114721797BActive Publication Date: 2026-08-14CHINA FAW CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-31
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0003]本发明实施例提供了一种基于单位定时器的定时方法、装置、设备及介质,以解决现有技术中计时不准确以及系统资源占用过高的技术问题

Benefits of technology

[0036]通过获取用户定时器、用于为用户定时器计算单位时长的单位定时器,以及用于计算针对单位定时器的校准时长的校准定时器,在用户定时器采用单位定时器进行定时的过程中,校准定时器基于校准定时器的校准定时周期触发,如果校准定时器检测到单位定时器在校准定时周期内的当前触发次数等于预设触发次数,则触发对单位定时器的重启,以使单位定时器被提前触发,减少单位定时器在校准定时周期内的累计误差,从而提高了单位定时器的精度,进一步的,降低了用户定时器的累计误差,提高了用户定时器的精度,解决了传统定时器计时不准确的技术问题,并且,该方法仅通过校准定时器即可提高用户定时器的精度,所占用的系统资源低。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114721797B_ABST
    Figure CN114721797B_ABST
Patent Text Reader

Abstract

This invention discloses a timing method, apparatus, device, and medium based on a unit timer. The method acquires a user timer, a unit timer for calculating unit durations for the user timer, and a calibration timer for calculating calibration durations for the unit timer. During the user timer's timing process using the unit timer, the calibration timer is triggered based on its calibration timing period. If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period equals a preset trigger count, it triggers a restart of the unit timer. This causes the unit timer to be triggered earlier, reducing the error of the unit timer within the calibration timing period and improving its accuracy. Furthermore, this reduces the cumulative error of the user timer, improving its accuracy. Moreover, this method improves the accuracy of the user timer solely through the calibration timer, requiring minimal system resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of timer technology, and in particular to a timing method, apparatus, device and medium based on a unit timer. Background Technology

[0002] Timers are a common technique in computer software. They can be used to repeatedly process tasks that require looping, or to handle tasks that need to wait for a set amount of time before execution. However, traditional timers suffer from technical problems such as inaccurate timing or high system resource consumption due to complex design. Summary of the Invention

[0003] This invention provides a timing method, apparatus, device, and medium based on a unit timer to solve the technical problems of inaccurate timing and excessive system resource consumption in the prior art.

[0004] In a first aspect, embodiments of the present invention provide a timing method based on a unit timer, the method comprising:

[0005] Acquire a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer;

[0006] During the timing process of the user timer using the unit timer, the calibration timer is triggered based on the calibration timing period of the calibration timer;

[0007] If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, then the unit timer is restarted so that the unit timer is triggered earlier.

[0008] Optionally, the method further includes:

[0009] If the calibration timer detects that the actual total number of triggers of the unit timer within the calibration timing period is not equal to the preset number of triggers, then the unit timing period of the unit timer and / or the calibration timing period are adjusted based on the actual total number of triggers and the preset number of triggers.

[0010] Optionally, the method further includes:

[0011] Determine the average error duration generated by the unit timer running once;

[0012] Obtain the maximum cumulative error generated by the pre-set unit timer during one run of the calibration timer;

[0013] Based on the average error duration and the maximum cumulative error, the unit timing period of the unit timer and the calibration timing period of the calibration timer are determined.

[0014] Optionally, the method further includes:

[0015] Determine the proportional relationship between the unit timing period of the unit timer and the calibration timing period;

[0016] The preset number of triggers of the unit timer within the calibration timing period is determined based on the aforementioned proportional relationship.

[0017] Optionally, the method further includes:

[0018] During the timing process of the user timer using the unit timer, the cumulative timing length corresponding to the unit timer is determined based on the user timer;

[0019] If the accumulated timing length reaches the reference timing length corresponding to the user timer, the processing function corresponding to the user timer is triggered.

[0020] Optionally, the method further includes:

[0021] Obtain the timer list of the user timer, wherein the timer list includes at least one timer length to be executed;

[0022] The reference timing length corresponding to the user timer is determined based on the timer linked list.

[0023] Optionally, the method further includes:

[0024] The display interface shows the unit timing period of the unit timer, the calibration timing period, the actual total number of triggers, and the preset number of triggers.

[0025] Obtain the user's adjustment operation information on the display interface, and update the unit timing period and / or the calibration timing period based on the adjustment operation information.

[0026] Secondly, embodiments of the present invention also provide a timing device based on a unit timer, the device comprising:

[0027] The acquisition module is used to acquire a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer;

[0028] A timing module is used to trigger the calibration timer based on the calibration timing period of the calibration timer during the process of the user timer using the unit timer for timing.

[0029] The calibration module is configured to, if the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, trigger a restart of the unit timer so that the unit timer is triggered earlier.

[0030] Thirdly, embodiments of the present invention also provide an electronic device, the electronic device comprising:

[0031] One or more processors;

[0032] Storage device for storing one or more programs.

[0033] When the one or more programs are executed by the one or more processors, the one or more processors implement a timing method based on a unit timer as provided in any embodiment of the present invention.

[0034] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the timing method based on a unit timer as provided in any embodiment of the present invention.

[0035] The embodiments of the above invention have the following advantages or beneficial effects:

[0036] By acquiring a user timer, a unit timer for calculating the unit duration of the user timer, and a calibration timer for calculating the calibration duration of the unit timer, during the user timer's timing process using the unit timer, the calibration timer is triggered based on the calibration timing period of the calibration timer. If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period equals the preset trigger count, it triggers a restart of the unit timer to ensure that the unit timer is triggered earlier, reducing the cumulative error of the unit timer within the calibration timing period, thereby improving the accuracy of the unit timer. Furthermore, this reduces the cumulative error of the user timer, improving its accuracy and solving the technical problem of inaccurate timing by traditional timers. Moreover, this method improves the accuracy of the user timer simply by calibrating the timer, with low system resource consumption. Attached Figure Description

[0037] To more clearly illustrate the technical solutions of exemplary embodiments of the present invention, the accompanying drawings used in describing the embodiments are briefly introduced below. Obviously, the accompanying drawings described are only a portion of the drawings of the embodiments to be described in this invention, and not all of the drawings. For those skilled in the art, other drawings can be obtained from these drawings without any creative effort.

[0038] Figure 1AThis is a flowchart illustrating a timing method based on a unit timer provided in Embodiment 1 of the present invention;

[0039] Figure 1B This is a schematic diagram of the timing period of each timer provided in Embodiment 1 of the present invention;

[0040] Figure 1C This is a timing process for a user timer provided in Embodiment 1 of the present invention;

[0041] Figure 2A This is a flowchart illustrating a timing method based on a unit timer provided in Embodiment 2 of the present invention;

[0042] Figure 2B This is a schematic diagram of a periodic adjustment process provided in Embodiment 2 of the present invention;

[0043] Figure 3A This is a flowchart illustrating a timing method based on a unit timer provided in Embodiment 3 of the present invention;

[0044] Figure 3B This is a schematic diagram of the initialization process of the unit timer and calibration timer provided in Embodiment 3 of the present invention;

[0045] Figure 4 This is a schematic diagram of a timing device based on a unit timer provided in Embodiment 4 of the present invention;

[0046] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Detailed Implementation

[0047] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0048] Example 1

[0049] Figure 1A This is a flowchart illustrating a timing method based on a unit timer according to Embodiment 1 of the present invention. This embodiment is applicable to situations where a user timer is timed using a unit timer. The method can be executed by a timing device based on a unit timer, which can be implemented in hardware and / or software. The method specifically includes the following steps:

[0050] S110, Obtain a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer.

[0051] User timers can be used to time tasks that are about to be processed in a program. Specifically, a computer program can set corresponding user timers for each task to be processed according to actual task requirements, or set corresponding user timers for tasks that need to be executed cyclically for a set duration.

[0052] A unit timer can be a timer that cycles through time in units of a minimum timing interval. In this embodiment, the unit timer can be used as a timing unit of a user timer. The unit duration in the user timer is the duration calculated by the unit timer running once, i.e., the unit timing period of the unit timer. For example, the unit timing period of the unit timer can be 1ms.

[0053] The calibration timer can be a timer used to calibrate the unit timer; specifically, the calibration timer can be used to restart the unit timer. In this embodiment, the calibration period of the calibration timer can be set to a value much larger than the unit timer's unit timer period, and the calibration period of the calibration timer can be an integer multiple of the unit timer period. For example, the calibration period of the calibration timer can be 10ms.

[0054] like Figure 1B The diagram illustrates the timing periods of various timers, where the calibration timer has a calibration timing period of m milliseconds, the unit timer has a unit timing period of n milliseconds, and the user timer has a user timing period of X*n milliseconds.

[0055] S120. During the process of the user timer using the unit timer for timing, the calibration timer is triggered based on the calibration timing period of the calibration timer.

[0056] Specifically, during the timing process using a unit timer, when the unit timer is triggered, the user timer accumulates all the unit durations counted by the unit timer. For example, if the unit timer's unit timing period is 1ms, each time the unit timer triggers, the duration calculated by the user timer is increased by 1ms. In this embodiment, the duration to be calculated by the user timer can be much larger than the unit timer's unit timing period; for example, the duration to be calculated by the user timer may be 80ms.

[0057] In this embodiment, during the user timer's timing process using a unit timer, the unit timer is triggered cyclically to increase the cumulative count of the user timer by repeatedly calculating the unit duration. Simultaneously, the calibration timer can run cyclically according to its calibration timing cycle. Continuing with the previous example, the calibration timer can run once every 10ms, meaning each run calculates a duration of 10ms.

[0058] S130. If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, then the unit timer is restarted so that the unit timer is triggered in advance.

[0059] Specifically, after the calibration timer is triggered, it can monitor the number of times the unit timer is triggered within the current calibration timing period. If the current number of triggers of the unit timer within the current calibration timing period is equal to the preset number of triggers, the calibration timer can immediately trigger the restart of the unit timer so that the unit timer is triggered in advance, that is, the unit timer is triggered again before the unit timing period has elapsed after being triggered.

[0060] In other words, after a unit timer is triggered, it calculates the duration of one unit timing period and triggers again after the duration calculation is complete. A calibration timer, however, can restart the unit timer immediately without waiting for it to calculate the duration of one unit timing period when the current trigger count is the preset trigger count, causing the unit timer to be triggered again. Since user timers calculate their cumulative duration based on the number of triggers of the unit timer, when the calibration timer restarts the unit timer, the user timer immediately adds one unit timing period to the accumulated duration.

[0061] For example, the calibration timing period is 10ms, and the unit timing period of the unit timer is 1ms. After the calibration timer is triggered, when the calibration timer detects that the unit timer has been triggered 9 times, that is, when the user timer determines that the cumulative calculation duration of the unit timer during the operation of the calibration timer is 9ms, the calibration timer immediately restarts the unit timer so that the number of triggers of the unit timer reaches 10 times. At this time, the cumulative duration calculated by the user timer is 10ms.

[0062] It should be noted that the purpose of using a calibration timer to trigger the restart of the unit timer in this embodiment is as follows: The time consumed by the unit timer's processing function may introduce errors into the calculated duration of a single run of the unit timer. For example, if the actual duration required for one run of the unit timer is 1.2ms, while its calculated duration is 1ms, the error per run is 0.2ms. Without calibration of the unit timer, the accumulated error of the user timer may become significant. Therefore, this embodiment uses a calibration timer to trigger the restart of the unit timer within a calibration period. This ensures that the unit timer is immediately restarted after a single trigger, and is triggered again after a single trigger, eliminating the need to calculate a full unit timer period. This reduces the accumulated error of the unit timer within a calibration period, thereby improving the accuracy of the unit timer.

[0063] In this embodiment, the preset trigger count can be a pre-set number of times to trigger a restart of the unit timer; the preset trigger count can be any value, but of course, it cannot exceed the ratio between the calibration timing period and the unit timing period. For example, the preset trigger count can be obtained by: determining the proportional relationship between the unit timing period of the unit timer and the calibration timing period; and determining the preset trigger count of the unit timer within the calibration timing period based on the proportional relationship.

[0064] The proportional relationship can be the ratio of the calibration timing period to the unit timing period, i.e., the multiple relationship between the standard timing period and the unit timing period. For example, the standard trigger count can be set based on the proportional relationship; for instance, the preset trigger count can be equal to the proportional relationship value minus 1. For example, if the calibration timing period is m milliseconds and the unit timing period is n milliseconds, then the preset trigger count can be... Where m is an integer multiple of n. That is, the preset trigger count can be the second to last trigger that the unit timer should trigger within one calibration timing period, without considering the running error of the unit timer.

[0065] Of course, the preset number of triggers can also be any one of the triggers of the unit timer within a calibration timing period. The calibration timer can trigger a restart of the unit timer once within a calibration timing period.

[0066] Specifically, during the user timer's timing process, the calibration timer can be triggered cyclically. In each calibration timing cycle, the unit timer is restarted once to reduce the cumulative error in each calibration timing cycle, thereby reducing the cumulative error during the user timer's timing period.

[0067] In this embodiment, the method may further include: during the process of the user timer using the unit timer for timing, determining the cumulative timing length corresponding to the unit timer based on the user timer; if the cumulative timing length reaches the reference timing length corresponding to the user timer, then triggering the processing function corresponding to the user timer.

[0068] The user timer can determine the cumulative timing length corresponding to the unit timer based on the number of times the unit timer is triggered. Specifically, each time the unit timer is triggered, the user timer can add the unit timer's unit timing period to the existing timing length. Each time the user timer accumulates a unit timing period, it can check whether the accumulated timing length has reached a reference timing length. The reference timing length can be a preset length that the user timer needs to keep track of. If it has, the corresponding processing function of the user timer is triggered. The processing function includes, but is not limited to, data processing tasks and application control tasks, such as refreshing the usage status of an application or restarting an application.

[0069] It should be noted that the reference timing length can be obtained from a preset user timer linked list. That is, optionally, the method further includes: obtaining the timer linked list of the user timer, wherein the timer linked list includes at least one timing length to be executed; and determining the reference timing length corresponding to the user timer based on the timer linked list.

[0070] The timer list can be a linked list used to store the durations of each pending execution time; these durations can be stored in the timer list in chronological order of execution time. Specifically, the duration closest to the execution time can be read from the timer list and used as the reference duration for the user timer.

[0071] For example, such as Figure 1C The diagram illustrates the timing process of a user timer. Specifically, after initializing the user timer's linked list, a unit timer can be triggered to start timing. The user timer increments the timing length of the unit timer. Furthermore, it checks whether the incremented timing length exceeds the reference timing length. If so, the user timer processing function is triggered.

[0072] The technical solution of this embodiment obtains a user timer, a unit timer for calculating the unit duration of the user timer, and a calibration timer for calculating the calibration duration of the unit timer. During the timing process of the user timer using the unit timer, the calibration timer is triggered based on the calibration timing period of the calibration timer. If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, it triggers a restart of the unit timer to make the unit timer be triggered in advance, reducing the cumulative error of the unit timer within the calibration timing period, thereby improving the accuracy of the unit timer. Furthermore, it reduces the cumulative error of the user timer and improves the accuracy of the user timer, solving the technical problem of inaccurate timing of traditional timers. Moreover, this method can improve the accuracy of the user timer by calibrating the timer alone, and the system resources occupied are low.

[0073] Example 2

[0074] Figure 2A This is a flowchart illustrating a timing method based on a unit timer according to Embodiment 2 of the present invention. Based on the above embodiments, this embodiment can further adjust the unit timing period and / or the calibration timing period based on the actual total number of triggers of the unit timer during the calibration timing period. Explanations of terms that are the same as or corresponding to those in the above embodiments are not repeated here. See also... Figure 2A The timing method based on a unit timer provided in this embodiment includes the following steps:

[0075] S210, Obtain a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer.

[0076] S220. During the process of the user timer using the unit timer for timing, the calibration timer is triggered based on the calibration timing period of the calibration timer.

[0077] S230. If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, then the unit timer is restarted so that the unit timer is triggered in advance.

[0078] S240. If the calibration timer detects that the actual total number of triggers of the unit timer within the calibration timing period is not equal to the preset number of triggers, then the unit timing period of the unit timer and / or the calibration timing period are adjusted based on the actual total number of triggers and the preset number of triggers.

[0079] In this embodiment, the preset trigger count is equal to the ratio between the calibration timing period and the unit timing period minus 1. Specifically, if the actual total trigger count is not equal to the preset trigger count, it indicates that the cumulative error of the unit timer within one calibration timing period is large, and the unit timer cannot complete the preset trigger count within one calibration timing period. Therefore, by adjusting the unit timing period and / or the calibration timing period, the number of times the unit timer should run within one calibration timing period can be reduced, thereby reducing the cumulative error of the unit timer within one calibration timing period, so that the total number of times the unit timer is triggered within one calibration timing period can reach the preset trigger count.

[0080] Specifically, if the unit timing period is increased, the ratio of the calibration timing period to the unit timing period decreases, and the number of times the unit timer should run within one calibration timing period decreases; if the calibration timing period is decreased, the ratio of the calibration timing period to the unit timing period decreases, and the number of times the unit timer should run within one calibration timing period decreases.

[0081] In this embodiment, the unit timing period and / or calibration timing period can be adjusted based on the difference between the actual total number of triggers and the preset number of triggers. Alternatively, a prompt message indicating that adjustment is needed can be displayed on the screen, and the unit timing period and / or calibration timing period can be updated based on the user's adjustment.

[0082] Optionally, the method further includes: displaying the unit timing period of the unit timer, the calibration timing period, the actual total number of triggers, and the preset number of triggers on a display interface; obtaining adjustment operation information of the user on the display interface, and updating the unit timing period and / or the calibration timing period based on the adjustment operation information.

[0083] Specifically, when it is determined that the actual number of triggers is not equal to the preset number of triggers, the timing of the current user timer can be paused or terminated, and a prompt message can be displayed on the display interface to obtain the user's adjustment operation information on the display interface. Furthermore, after updating the unit timing period and / or calibration timing period according to the operation adjustment information, the timing of the user timer can be re-executed according to the updated unit timing period and calibration timing period.

[0084] Of course, in this embodiment, the unit timing period and / or the timing period can be adjusted and / or calibrated after the user timer completes a timing cycle or before the user timer starts timing, so that when the user timer is timing based on the unit timer next time, the error accuracy of the user timer can be controlled within the allowable range.

[0085] For example, such as Figure 2BThe diagram illustrates a periodic adjustment process. After the calibration timer is triggered, the unit timer can be restarted, and its processing function is triggered. After the calibration timer completes one count, the actual number of times the unit timer has been triggered during this period is obtained. It is then determined whether the actual number of triggers equals the standard number of triggers. If not, both the unit timer period and the calibration timer period are adjusted; otherwise, the time synchronization is successful. Of course, while the user timer is using the unit timer for timing, the calibration timer can be continuously triggered to continuously calibrate the unit timer.

[0086] The technical solution of this embodiment determines whether the actual total number of triggers of the unit timer within the calibration timing period is equal to the preset number of triggers. If not, the unit timing period and / or calibration timing period are adjusted according to the actual total number of triggers and the preset number of triggers to reduce the cumulative error of the unit timer within the calibration timing period. This ensures that the actual total number of triggers of the unit timer within the calibration timing period can reach the preset number of triggers, thus solving the technical problem of inaccurate timing of traditional timers.

[0087] Example 3

[0088] Figure 3A This is a flowchart illustrating a timing method based on a unit timer according to Embodiment 3 of the present invention. This embodiment, based on the above embodiments, provides an exemplary description of the process for determining the unit timing period and the calibration timing period. Explanations of terms that are the same as or corresponding to those in the above embodiments are not repeated here. See also... Figure 3A The timing method based on a unit timer provided in this embodiment includes the following steps:

[0089] S310, Obtain a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer.

[0090] S320. Determine the average error duration generated by the unit timer running once, and obtain the maximum cumulative error generated by the unit timer during the calibration timer running once (pre-set).

[0091] Specifically, the average error duration can be the delay caused by the processing time of the unit timer's function. Theoretically, the timing of one run of the unit timer should be the unit timing period. However, due to the existence of the average error duration, the time required for one run of the unit timer may be equal to the sum of the unit timing period and the average error duration. For example, if the unit timing period is 1ms and the average error duration is 0.1ms, then the time required for one run of the unit timer is 1.1ms. For instance, the actual duration of multiple runs of the unit timer can be obtained, and then the average error duration can be calculated based on each actual duration and the unit timing period.

[0092] In this embodiment, the maximum cumulative error generated by the pre-set unit timer during one run of the calibration timer can be the maximum error generated by the unit timer within one calibration timing period.

[0093] S330. Based on the average error duration and the maximum cumulative error, determine the unit timing period of the unit timer and the calibration timing period of the calibration timer.

[0094] Specifically, based on the unit timer's unit timing period, calibration timing period, and average error duration, the simulated cumulative error of the unit timer within the calibration timing period can be calculated. The unit timing period and calibration timing period are set with the condition that the simulated cumulative error cannot exceed the maximum cumulative error.

[0095] For example, the unit timing period of the unit timer and the calibration timing period of the calibration timer can be determined by the following formulas:

[0096]

[0097] in, The cumulative simulation error is represented by ΔT, the average error duration is represented by m, the calibration timing period is n, and the unit timing period is m. This represents the expected number of times the unit timer will run within the calibration timing period, and y is the preset maximum cumulative error. Using the above formula, the unit timing period and calibration timing period can be set to satisfy the above conditions.

[0098] For example, such as Figure 3B The diagram illustrates the initialization process for the unit timer and calibration timer. Specifically, the unit timer and calibration timer can be initialized, and the unit timing period and calibration timing period can be set through the steps described above. The processing function for the calibration timer can then be configured, and the unit timer and calibration timer can be started.

[0099] S340. During the process of the user timer using the unit timer for timing, the calibration timer is triggered based on the calibration timing period of the calibration timer.

[0100] S350. If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, then the unit timer is restarted so that the unit timer is triggered in advance.

[0101] The technical solution of this embodiment determines the average error duration of the unit timer and the maximum cumulative error that the unit timer can generate within a calibration timing period. By setting the unit timing period and the calibration timing period, the error generated by the unit timing period within a calibration timing period is controlled within an allowable range, thereby improving the positioning accuracy of the user timer.

[0102] Example 4

[0103] Figure 4 This is a schematic diagram of a timing device based on a unit timer provided in Embodiment 4 of the present invention. This embodiment is applicable to the situation where a user timer is timed by a unit timer. The device specifically includes: an acquisition module 410, a timing module 420, and a calibration module 430.

[0104] The acquisition module 410 is used to acquire a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer;

[0105] The timing module 420 is used to trigger the calibration timer based on the calibration timing period of the calibration timer during the process of the user timer using the unit timer for timing.

[0106] The calibration module 430 is used to trigger a restart of the unit timer if the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, so that the unit timer is triggered in advance.

[0107] Optionally, the device further includes an adjustment module, which is used to adjust the unit timing period of the unit timer and / or the calibration timing period based on the actual total number of triggers and the preset number of triggers if the calibration timer detects that the actual total number of triggers of the unit timer within the calibration timing period is not equal to the preset number of triggers.

[0108] Optionally, the device further includes a period setting module, which is used to determine the average error duration generated by the unit timer running once; obtain the maximum cumulative error generated by the unit timer during the calibration timer running once (pre-set); and determine the unit timing period of the unit timer and the calibration timing period of the calibration timer based on the average error duration and the maximum cumulative error.

[0109] Optionally, the calibration module 430 is further configured to determine the proportional relationship between the unit timing period of the unit timer and the calibration timing period; and to determine the preset number of times the unit timer is triggered within the calibration timing period based on the proportional relationship.

[0110] Optionally, the timing module 420 is further configured to determine the cumulative timing length corresponding to the unit timer based on the user timer during the process of the user timer using the unit timer for timing; if the cumulative timing length reaches the reference timing length corresponding to the user timer, then trigger the processing function corresponding to the user timer.

[0111] Optionally, the timing module 420 is further configured to obtain a timer list of the user timer, wherein the timer list includes at least one timing length to be executed; and determine a reference timing length corresponding to the user timer based on the timer list.

[0112] Optionally, the adjustment module is further configured to display the unit timing period, the calibration timing period, the actual total number of triggers, and the preset number of triggers of the unit timer on the display interface; obtain the user's adjustment operation information on the display interface, and update the unit timing period and / or the calibration timing period based on the adjustment operation information.

[0113] In this embodiment, by acquiring a user timer, a unit timer for calculating the unit duration of the user timer, and a calibration timer for calculating the calibration duration of the unit timer, during the user timer's timing process using the unit timer, the calibration timer is triggered based on the calibration timing period of the calibration timer. If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, it triggers a restart of the unit timer to make it be triggered earlier, reducing the cumulative error of the unit timer within the calibration timing period, thereby improving the accuracy of the unit timer. Furthermore, this reduces the cumulative error of the user timer, improving its accuracy and solving the technical problem of inaccurate timing by traditional timers. Moreover, this method can improve the accuracy of the user timer simply by calibrating the timer, and it consumes low system resources.

[0114] The timing device based on a unit timer provided in the embodiments of the present invention can execute the timing method based on a unit timer provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0115] It is worth noting that the various units and modules included in the above system are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of the present invention.

[0116] Example 5

[0117] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Figure 5 A block diagram is shown of an exemplary electronic device 12 suitable for implementing embodiments of the present invention. Figure 5 The illustrated electronic device 12 is merely an example and should not be construed as limiting the functionality or scope of the embodiments of the present invention. Device 12 is typically an electronic device that performs timing functions based on a unit timer.

[0118] like Figure 5 As shown, the electronic device 12 is represented in the form of a general-purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, memory 28, and bus 18 connecting different components (including memory 28 and processing unit 16).

[0119] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MCA) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0120] Electronic device 12 typically includes a variety of computer-readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0121] Memory 28 may include computer device readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer storage media. By way of example only, storage device 34 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 5 Not shown; usually referred to as a "hard drive"). Although Figure 5 Not shown, disk drives for reading and writing to removable non-volatile disks (e.g., "floppy disks") and optical disc drives for reading and writing to removable non-volatile optical discs (e.g., Compact Disc-Read Only Memory (CD-ROM), Digital Video Disc-Read Only Memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product 40 having a set of program modules 42 configured to perform the functions of the embodiments of the present invention. Program product 40 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.

[0122] Electronic device 12 can also communicate with one or more external devices 14 (e.g., keyboard, mouse, camera, etc., and monitor), and with one or more devices that enable a user to interact with electronic device 12, and / or with any device that enables electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, electronic device 12 can also communicate with one or more networks (e.g., Local Area Network (LAN), Wide Area Network (WAN) and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of electronic device 12 via bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) devices, tape drives, and data backup storage devices.

[0123] Processor 16 executes various functional applications and data processing by running programs stored in memory 28, such as implementing the timing method based on a unit timer provided in the above embodiments of the present invention, including:

[0124] Acquire a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer;

[0125] During the timing process of the user timer using the unit timer, the calibration timer is triggered based on the calibration timing period of the calibration timer;

[0126] If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, then the unit timer is restarted so that the unit timer is triggered earlier.

[0127] Of course, those skilled in the art will understand that the processor can also implement the timing method based on a unit timer provided in any embodiment of the present invention.

[0128] Example 6

[0129] Embodiment 6 of the present invention also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the program implements the timing method steps based on a unit timer as provided in any embodiment of the present invention. The method includes:

[0130] Acquire a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer;

[0131] During the timing process of the user timer using the unit timer, the calibration timer is triggered based on the calibration timing period of the calibration timer;

[0132] If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, then the unit timer is restarted so that the unit timer is triggered earlier.

[0133] The computer storage medium of this invention can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0134] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0135] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0136] Computer program code for performing the operations of embodiments of the present invention can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0137] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A timing method based on a unit timer, characterized in that, The method includes: Acquire a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer; During the timing process of the user timer using the unit timer, the calibration timer is triggered based on the calibration timing period of the calibration timer; If the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, then the unit timer is restarted so that the unit timer is triggered earlier. The method further includes: Determine the average error duration generated by the unit timer running once; Obtain the maximum cumulative error generated by the pre-set unit timer during one run of the calibration timer; Based on the average error duration and the maximum cumulative error, the unit timing period of the unit timer and the calibration timing period of the calibration timer are determined.

2. The method according to claim 1, characterized in that, The method further includes: If the calibration timer detects that the actual total number of triggers of the unit timer within the calibration timing period is not equal to the preset number of triggers, then the unit timing period of the unit timer and / or the calibration timing period are adjusted based on the actual total number of triggers and the preset number of triggers.

3. The method according to claim 1, characterized in that, The method further includes: Determine the proportional relationship between the unit timing period of the unit timer and the calibration timing period; The preset number of triggers of the unit timer within the calibration timing period is determined based on the aforementioned proportional relationship.

4. The method according to claim 1, characterized in that, The method further includes: During the timing process of the user timer using the unit timer, the cumulative timing length corresponding to the unit timer is determined based on the user timer; If the accumulated timing length reaches the reference timing length corresponding to the user timer, the processing function corresponding to the user timer is triggered.

5. The method according to claim 4, characterized in that, The method further includes: Obtain the timer list of the user timer, wherein the timer list includes at least one timer length to be executed; The reference timing length corresponding to the user timer is determined based on the timer linked list.

6. The method according to claim 2, characterized in that, The method further includes: The display interface shows the unit timing period of the unit timer, the calibration timing period, the actual total number of triggers, and the preset number of triggers. Obtain the user's adjustment operation information on the display interface, and update the unit timing period and / or the calibration timing period based on the adjustment operation information.

7. A timing device based on a unit timer, characterized in that, The device includes: The acquisition module is used to acquire a user timer, a unit timer for calculating a unit duration for the user timer, and a calibration timer for calculating a calibration duration for the unit timer; A timing module is used to trigger the calibration timer based on the calibration timing period of the calibration timer during the process of the user timer using the unit timer for timing. The calibration module is configured to, if the calibration timer detects that the current trigger count of the unit timer within the calibration timing period is equal to the preset trigger count, trigger a restart of the unit timer so that the unit timer is triggered earlier. The device further includes a period setting module, which is used to determine the average error duration generated by the unit timer running once; obtain the maximum cumulative error generated by the unit timer during the calibration timer running once (pre-set); and determine the unit timing period of the unit timer and the calibration timing period of the calibration timer based on the average error duration and the maximum cumulative error.

8. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the timing method based on a unit timer as described in any one of claims 1-6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements the timing method based on a unit timer as described in any one of claims 1-6.

Citation Information

Patent Citations

  • MCU internal clock calibration system and method and PCB

    CN103853081A

  • Fast frequency offset calibration method and device for radio frequency module, equipment and medium

    CN110401499A