CN111781987B - Real-time clock calibration method and related device - Google Patents
Real-time clock calibration method and related device Download PDFInfo
- Publication number
- CN111781987B CN111781987B CN202010651828.9A CN202010651828A CN111781987B CN 111781987 B CN111781987 B CN 111781987B CN 202010651828 A CN202010651828 A CN 202010651828A CN 111781987 B CN111781987 B CN 111781987B
- Authority
- CN
- China
- Prior art keywords
- time
- calibration
- electronic equipment
- deviation
- offset
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/04—Generating or distributing clock signals or signals derived directly therefrom
- G06F1/14—Time supervision arrangements, e.g. real time clock
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Electric Clocks (AREA)
Abstract
The embodiment of the application discloses a real-time clock calibration method and a related device, which are applied to electronic equipment and comprise the following steps: carrying out first time synchronization on the system time of the electronic equipment, and recording corresponding first time information after synchronization; after the preset absolute time passes, acquiring current second time information of the electronic equipment, wherein the second time information is the current system time of the electronic equipment; and calculating the time deviation of the electronic equipment according to the first time information, the second time information and the preset absolute time, and determining whether to start RTC (real time clock) deviation calibration of a real time clock chip of the electronic equipment or not according to the time deviation. The embodiment of the application is favorable for avoiding frequently calibrating the RTC, and simultaneously improves the RTC calibration precision.
Description
Technical Field
The application relates to the technical field of mobile terminals, in particular to a real-time clock calibration method and a related device.
Background
In the prior art, a Real Time Clock (RTC) of a communication device system is usually calibrated by a frequency division Clock from an autonomous Clock, the frequency division Clock is modulated into a carrier signal of a radio frequency after frequency multiplication, the frequency deviation of the carrier signal is measured and counted when the device leaves a factory, so that a load capacitor of a crystal is modulated to reduce deviation caused by the Clock, the frequency multiplication and the periodic correction of the Clock are completed by real-time communication with a base station when the device is used, in addition, the RTC precision of a micro-processing system, such as an electronic watch, a bracelet and the like, is usually related to the frequency deviation of the crystal, because the system is relatively simple, the deviation of the crystal needs to be adjusted when the RTC leaves the factory, the basic timing precision is ensured, and meanwhile, the perception of a user on the time precision is reduced by synchronizing with the network time in a user use scene.
Disclosure of Invention
The embodiment of the application provides a real-time clock calibration method and a related device, which are beneficial to avoiding frequent calibration of an RTC (real time clock) and improving the RTC calibration precision.
In a first aspect, an embodiment of the present application provides a real-time clock calibration method, which is applied to an electronic device, and the method includes:
carrying out first time synchronization on the system time of the electronic equipment, and recording corresponding first time information after synchronization;
after the preset absolute time passes, acquiring current second time information of the electronic equipment, wherein the second time information is the current system time of the electronic equipment;
and calculating the time deviation of the electronic equipment according to the first time information, the second time information and the preset absolute time, and determining whether to start RTC (real time clock) deviation calibration of a real time clock chip of the electronic equipment or not according to the time deviation.
In a second aspect, an embodiment of the present application provides a real-time clock calibration apparatus, which is applied to an electronic device, where the electronic device includes an eye tracking component; the real-time clock calibration apparatus includes a processing unit and a communication unit, wherein,
the processing unit is used for carrying out first time synchronization on the system time of the electronic equipment through the communication unit and recording corresponding first time information after synchronization; the electronic equipment is used for acquiring current second time information of the electronic equipment after a preset absolute time passes, wherein the second time information is the current system time of the electronic equipment; and the real-time clock calibration module is used for calculating the time deviation of the electronic equipment according to the first time information, the second time information and the preset absolute time, and determining whether to start the RTC deviation calibration of the real-time clock chip of the electronic equipment or not according to the time deviation.
In a third aspect, an embodiment of the present application provides an electronic device, including a controller, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the controller, and the program includes instructions for executing steps in any method of the first aspect of the embodiment of the present application.
In a fourth aspect, the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program for electronic data exchange, where the computer program makes a computer perform part or all of the steps described in any one of the methods of the first aspect of the present application.
In a fifth aspect, the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform some or all of the steps as described in any one of the methods of the first aspect of the embodiments of the present application. The computer program product may be a software installation package.
It can be seen that, in the embodiment of the present application, an electronic device first performs time synchronization on system time of the electronic device for the first time, and records corresponding first time information after the synchronization, and then acquires current second time information of the electronic device after a preset absolute time elapses, where the second time information is the current system time of the electronic device, and finally, calculates a time offset of the electronic device according to the first time information, the second time information, and the preset absolute time, and determines whether to start RTC offset calibration of a real-time clock chip of the electronic device according to the time offset. The electronic equipment can calculate the time deviation and accumulate the time deviation after realizing network time synchronization through external communication, determine whether to start RTC calibration on the electronic equipment after judging the time deviation, and use the preset absolute time as a calibration period, wherein the period time is longer, so that frequent calibration on the RTC can be avoided, and meanwhile, the RTC calibration precision is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1A is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
fig. 1B is a schematic flowchart of RTC calibration according to an embodiment of the present disclosure;
fig. 1C is a schematic flowchart of a real-time clock calibration method according to an embodiment of the present disclosure;
FIG. 2 is a schematic flow chart illustrating another method for calibrating a real-time clock according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 4 is a block diagram illustrating functional units of a real-time clock calibration apparatus according to an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first," "second," and the like in the description and claims of the present application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The electronic device may include a terminal or a server, which is not limited in the embodiments of the present application. Terminals include a variety of handheld devices with wireless communication capabilities, in-vehicle devices, wearable devices (e.g., smartwatches, smartbands, pedometers, etc.), computing devices, or other processes connected to a wireless modem. User Equipment (UE), Mobile Station (MS), terminal Equipment (terminal device), and so on. For convenience of description, the above-mentioned devices are collectively referred to as electronic devices.
The following describes embodiments of the present application in detail.
The RTC is an integrated circuit, generally called a clock chip, and currently, a crystal oscillator with high precision is mostly used as a clock source for the RTC. The crystal oscillator is also called crystal oscillator, and is an electromechanical device, the crystal oscillator is a short for quartz oscillator, the core of any RTC is crystal oscillator, the crystal oscillator frequency is 32768 Hz, it provides accurate and low-power consumption real-base signal for frequency division counter, and is used for generating information of second, minute, time, day, etc., in order to ensure long-term accuracy of RTC, the crystal oscillator must normally work without interference. The time error of the RTC mainly originates from the frequency error of the crystal oscillator.
Aiming at the existing RTC calibration scheme, the calibration equipment and the calibration scheme are complex, in a communication system, the precision of RTC time highly depends on the clock precision of a base station system, if the electronic equipment is not accessed to a base station for a long time, the synchronization of frequency can not be completed, and the wireless access failure of the equipment can be caused by the aging of equipment crystal oscillator and the accumulation of frequency deviation, thereby influencing the use of the electronic equipment. In addition, for some electronic devices which are relatively simple, when the electronic devices do not have the capability of directly completing frequency and calibration, the RTC precision of the electronic devices comes from the time service precision of the network, once the electronic devices cannot be connected with the network, the time accumulated deviation of the electronic devices gradually increases, and as time is prolonged, the user perception becomes more obvious. For example, for bracelet products, the time deviation of 1 day is required to be no more than 1 second according to international standards, if a bracelet cannot be connected to a network for one week or one month, the time deviation of at least more than 30s occurs, and due to the fact that electronic equipment of this type cannot be calibrated during production, the time deviation of more than 1 minute often occurs in unsynchronized networks for more than one week, which results in misjudgment of the user and reduction of the user experience.
The application provides a real-time clock calibration method, which can further improve the precision of a system clock of electronic equipment, thereby realizing high-reliability work of the electronic equipment. The electronic device in this application has the ability with external communication, can be direct and external communication, for example electronic device such as smart mobile phone, flat board, also can be indirect and external communication, electronic device such as bracelet, wearable equipment, and electronic device has data processing's ability. As shown in fig. 1A, for a structural schematic diagram of an electronic device provided by the present application, the electronic device includes a time service module 101, a communication module 102, a processing module 103, a precision adjustment module 104 and an RTC module 105, the time service module 101 is used for acquiring system time of an RTC of the electronic device and synchronizing network time of the electronic device, the communication module 102 is used for implementing real-time communication between the electronic device and an external device, the processing module 103 is used for data processing, and the precision adjustment module 104 and the RTC module 105 are used for implementing calibration of the RTC by adjusting different crystal oscillator parameters.
The specific implementation manner of the real-time clock calibration method provided in the application is as shown in fig. 1B, the network time of the electronic device is synchronized first, and the time point and the synchronization time interval of two times of synchronization time acquired by the synchronization time point are recorded, so that the RTC offset of the electronic device is calculated, whether the RTC offset is greater than the calibration threshold is judged, and when the RTC offset is detected to be greater than the calibration threshold, the RTC offset calibration can be started. For example, the electronic device completes the first time synchronization at the time point a, and performs the first time synchronization on the electronic device after the absolute time B, where the system time of the electronic device is C, but the time D is the correct time when the synchronization is required, so that the time offset of the two times of synchronization of the electronic device is (C-D), the RTC offset of the electronic device is (C-D)/B, and when it is detected that (C-D)/B is greater than the calibration threshold, the RTC calibration may be started. Therefore, the real-time clock calibration method provided by the application is beneficial to improving the frequency of interaction between the electronic equipment and the network, so that the RTC deviation is invisible and cannot be perceived by a user, and further the user experience is improved.
Referring to fig. 1C, fig. 1C is a schematic flowchart of a real-time clock calibration method applied to an electronic device according to an embodiment of the present disclosure. As shown in the figure, the real-time clock calibration method includes:
s101, the electronic equipment carries out first time synchronization on the system time of the electronic equipment and records corresponding first time information after synchronization.
When the electronic equipment has the capability of communicating with the outside, the system time synchronization with other electronic equipment can be realized, after the network time synchronization is carried out on the electronic equipment for the first time, the corresponding first time information after the synchronization of the electronic equipment is recorded, and at the moment, the system time of the electronic equipment is the standard time after the synchronization with the network.
S102, after the preset absolute time passes, the electronic equipment acquires current second time information of the electronic equipment, wherein the second time information is the current system time of the electronic equipment.
The preset absolute time can be set by a user, the preset absolute time is a longer time, for example, one month or 2 months, and the preset absolute time is used as a calibration period, so that the RTC calibration of the electronic equipment can be performed without frequent use, and the reduction of the power consumption of the electronic equipment is facilitated. In addition, in the process of time synchronization between the electronic device and the network server directly or indirectly through external communication, a certain time error is generated due to network time delay, so that the time after synchronization is still a certain difference compared with the standard network time, but because the time delay generated by the network time is usually in the order of milliseconds, and the timing error generated by the RTC every day is in the order of seconds, the longer the preset time is, the larger the timing error generated by the RTC is, and because the preset absolute time is longer, the timing error is accumulated every day, the RTC error generated by the electronic device after a period of the preset absolute time is far greater than the network time delay error generated during the network time synchronization, even the network time delay error can be ignored, so the electronic device is insensitive to the network time delay generated during the time synchronization, and the method is not sensitive to the environment, thereby being beneficial to reducing errors and simplifying the algorithm.
The frequency deviation of the crystal oscillator of the RTC is relatively large, and the frequency deviation can be measured only by a high-precision instrument, for example, in a system with the precision of 10ppm, the equipment for measuring the deviation is relatively few, and the networking is complex, but once the time period is lengthened, for example, the deviation of 0.86 second can be detected when the interval time is one day, when the accumulated time is longer, the detectable deviation is larger, that is, the deviation is more obvious, and when the deviation is more obvious, the calibration precision of the RTC is higher, therefore, the preset absolute time is set to be a longer time, which is beneficial to improving the calibration precision of the RTC.
The preset absolute time may be determined by interacting the electronic device with a network, or by RTC timing of the electronic device itself, and the absolute time is determined according to the oscillation period of the crystal oscillator and the corresponding relationship between the preset oscillation period and the absolute time. After the preset absolute time passes, acquiring current second time information of the electronic device, where the second time information is a current system time of the electronic device, but is not necessarily a standard time, and due to an error generated by the RTC, the time indicated by the second time information is not the standard system time, for example, the second time information is earlier than the standard system time or later than the standard system time.
S103, the electronic equipment calculates the time deviation of the electronic equipment according to the first time information, the second time information and the preset absolute time, and determines whether to start RTC (real time clock) deviation calibration on the electronic equipment or not according to the time deviation.
The first time information is the time after the network time synchronization is carried out on the electronic equipment for the first time, after the absolute time is preset, the network time synchronization is carried out on the electronic equipment for the second time, the time after the synchronization is approximately equal to the first time information plus the preset absolute time, therefore, the standard system time of the electronic equipment at the moment is the first time information plus the preset absolute time, the current time deviation of the electronic equipment can be calculated at the moment according to the first time information, the second time information and the preset absolute time, and then whether RTC calibration needs to be started on the electronic equipment can be determined according to the time deviation.
It can be seen that, in the embodiment of the present application, an electronic device first performs time synchronization on system time of the electronic device for the first time, and records corresponding first time information after the synchronization, and then acquires current second time information of the electronic device after a preset absolute time elapses, where the second time information is the current system time of the electronic device, and finally, calculates a time offset of the electronic device according to the first time information, the second time information, and the preset absolute time, and determines whether to start RTC offset calibration of a real-time clock chip of the electronic device according to the time offset. The electronic equipment can calculate the time deviation and accumulate the time deviation after realizing network time synchronization through external communication, determine whether to start RTC calibration on the electronic equipment after judging the time deviation, and use the preset absolute time as a calibration period, wherein the period time is longer, so that frequent calibration on the RTC can be avoided, and meanwhile, the RTC calibration precision is improved.
In one possible example, the calculating the time offset of the electronic device according to the first time information, the second time information and the preset absolute time includes: determining third time information according to the first time information and the preset period, wherein the third time information is the current standard system time of the electronic equipment; calculating an absolute value of a time difference between the second time information and the third time information; and calculating the ratio of the absolute value of the time difference value to the preset period to obtain the time deviation.
The third time information of the electronic equipment can be determined according to the first time information and the preset period, the third time information is the current standard system time of the electronic equipment, but the current display time of the electronic equipment is the second time information, when the second time information is different from the third time information, the absolute value of the difference between the second time information and the third time information is calculated, when the difference is larger than zero, the RTC timing is indicated to be faster, when the difference is smaller than zero, the RTC timing is indicated to be slower, and the absolute value of the calculated difference is the ratio of the preset absolute time to obtain the time deviation.
As can be seen, in this example, after the electronic device is time-synchronized for the first time and after the absolute time is preset, time-synchronizing for the second time is performed on the electronic device to obtain third time information, where the third time information is the current standard system time of the electronic device, but the second time information is the current timing system time of the electronic device, and the time deviation of the electronic device can be obtained by comparing the second time information with the third time information, so as to determine whether the timing of the RTC is faster or slower, and further determine whether the RTC needs to be calibrated.
In one possible example, the determining whether to initiate a real time clock chip RTC offset calibration for the electronic device according to the time offset includes: starting RTC offset calibration on the electronic equipment when the time offset is detected to be larger than a calibration threshold value; when it is detected that the time deviation is less than the calibration threshold value, the time deviation is recorded and stored.
The electronic equipment calculates a time deviation once after the preset absolute time is over, starts RTC deviation calibration on the electronic equipment when detecting that the time deviation is greater than a calibration threshold value, records and stores the time deviation when detecting that the time deviation is less than the preset threshold value, calculates the time deviation once again after the next preset absolute time is over, accumulates the calculated time deviation to the previous time deviation, and can start RTC deviation calibration when the time deviation is greater than the calibration threshold value.
As can be seen, in this example, the time offset is calculated after the preset absolute time when the condition that the electronic device must be started is satisfied, and the RTC offset calibration is started only after the time offset is greater than the calibration threshold value, so that frequent starting of the RTC offset calibration can be avoided.
In one possible example, the calibration threshold value includes a first calibration threshold value and a second calibration threshold value, and the initiating RTC offset calibration for the electronic device upon detecting that the time offset is greater than the calibration threshold value includes: acquiring a power consumption state of the electronic equipment; when the electronic equipment is detected to be in a high power consumption state, acquiring the first calibration threshold value, and when the time deviation is detected to be larger than the first calibration threshold value, starting RTC deviation calibration on the electronic equipment; and when the electronic equipment is detected to be in a low power consumption state, acquiring the second calibration threshold value, and when the time deviation is detected to be larger than the second calibration threshold value, starting RTC deviation calibration on the electronic equipment, wherein the first calibration threshold value is larger than the second calibration threshold value.
The method includes the steps that preset absolute time is taken as a period, calibration of the RTC can be continuously conducted, but when RTC deviation calibration is started each time, processor resources of the electronic equipment can be temporarily used, power consumption is increased, and therefore frequent starting of RTC deviation calibration needs to be avoided.
The first calibration threshold value is greater than the second calibration threshold value, so that the condition for starting the RTC offset calibration in the high power consumption state is more strict than the condition for starting the RTC offset calibration in the low power consumption state, so that the RTC offset calibration can be delayed in the high power consumption state, and the use experience of a user on the electronic equipment is prevented from being influenced. The calibration threshold is ppm, and the calibration threshold may be set by a user, for example, the first calibration threshold is set to be 3ppm, the second calibration threshold is set to be 1ppm, when the time deviation is calculated to be 2ppm, if the current electronic device is in a high power consumption state, the RTC deviation calibration is not started, and if the current electronic device is in a low power consumption state, the RTC deviation calibration is started.
As can be seen, in this example, the electronic device corresponds to different calibration threshold values in the high power consumption state and the low power consumption state, and thus corresponds to different RTC trigger conditions, so that in the high power consumption state, occupation of processor resources of the electronic device can be avoided, and stable operation of the electronic device is ensured.
In one possible example, after initiating RTC offset calibration for the electronic device upon detecting that the time offset is greater than a calibration threshold value, the method further comprises: the time offset is set to zero.
Wherein, after starting RTC offset calibration, the time offset can be set to zero, and after the next preset absolute time, the time offset is recalculated.
It can be seen that, in this example, each time the RTC offset calibration is started, each parameter of the crystal oscillator is adjusted, so that the RTC accuracy is improved, at this time, the time offset is set to zero, and after the next preset absolute time, the time offset is calculated again, so that whether the RTC offset calibration is started or not is determined according to the time offset.
In one possible example, after initiating RTC offset calibration for the electronic device upon detecting that the time offset is greater than a calibration threshold value, the method further comprises: and updating the preset absolute time, wherein the updated preset absolute time is greater than the preset absolute time before updating.
After RTC calibration is started on the electronic equipment, the precision of the RTC can be improved, and after the next preset absolute time, the calculated time deviation can be smaller than the last calculated time deviation, so that the preset absolute time can be updated, the preset absolute time is prolonged, and whether RTC calibration needs to be started or not is determined. For example, the preset absolute time is 1 month, after one month, the calculated time offset is 2ppm, after the RTC offset calibration is started for the electronic device, the accuracy of the RTC is improved, and after another month, the calculated time offset may be much less than 2ppm, and the condition for starting the RTC offset calibration cannot be met, so that the period for calculating the time offset can be prolonged.
As can be seen, in this example, by updating the preset absolute time and extending the preset absolute time, the number of times of calculating the time offset can be reduced after the RTC accuracy is improved, thereby improving the accuracy of the calibration algorithm.
In one possible example, the calculating the time offset of the electronic device according to the first time information, the second time information and the preset absolute time includes: acquiring the time deviation currently recorded by the electronic equipment; and when the time deviation is detected to be not zero, updating the time deviation, wherein the updating is used for accumulating the calculated time deviation to the current time deviation.
When the electronic equipment does not calculate the time deviation for the first time, the electronic equipment stores the previously calculated time deviation, which may be zero or not, acquires the currently recorded time deviation of the electronic equipment, and when the time deviation is detected to be not zero, the time deviation obtained by the current calculation is accumulated to the previous time deviation, so that the time deviation is updated.
It can be seen that, in this example, after the time offset is calculated each time, whether RTC offset calibration is started or not can be determined according to the time offset, after the RTC offset calibration is started, the time offset is set to zero, if the RTC offset calibration is not started, the calculated time offset at this time is recorded and stored, and after the next preset absolute time, the recalculated time offset is accumulated to the calculated time offset at this time, which is beneficial to improving the accuracy of the calibration algorithm.
Referring to fig. 2, fig. 2 is a schematic flowchart of a real-time clock calibration method according to an embodiment of the present application, and the method is applied to an electronic device. As shown in the figure, the real-time clock calibration method includes:
s201, the electronic equipment carries out first time synchronization on the system time of the electronic equipment and records corresponding first time information after synchronization.
S202, after the preset absolute time passes, the electronic device acquires current second time information of the electronic device, wherein the second time information is current system time of the electronic device.
S203, the electronic equipment determines third time information according to the first time information and the preset absolute time, wherein the third time information is the current standard system time of the electronic equipment.
S204, the electronic equipment calculates the absolute value of the time difference between the second time information and the third time information.
And S205, the electronic equipment calculates the ratio of the absolute value of the time difference value to the preset absolute time to obtain the time deviation.
S206, the electronic equipment determines whether to start real-time clock chip RTC offset calibration on the electronic equipment according to the time offset.
It can be seen that, in the embodiment of the present application, an electronic device first performs time synchronization on system time of the electronic device for the first time, and records corresponding first time information after the synchronization, and then acquires current second time information of the electronic device after a preset absolute time elapses, where the second time information is the current system time of the electronic device, and finally, calculates a time offset of the electronic device according to the first time information, the second time information, and the preset absolute time, and determines whether to start RTC offset calibration of a real-time clock chip of the electronic device according to the time offset. The electronic equipment can calculate the time deviation and accumulate the time deviation after realizing network time synchronization through external communication, determine whether to start RTC calibration on the electronic equipment after judging the time deviation, and use the preset absolute time as a calibration period, wherein the period time is longer, so that frequent calibration on the RTC can be avoided, and meanwhile, the RTC calibration precision is improved.
In addition, after the electronic equipment is subjected to first time synchronization and absolute time is preset, second time synchronization is carried out on the electronic equipment to obtain third time information, the third time information is the current standard system time of the electronic equipment, but the second time information is the current timing system time of the electronic equipment, and the time deviation of the electronic equipment can be obtained by comparing the second time information with the third time information, so that whether the timing of the RTC is faster or slower is determined, and whether the RTC needs to be calibrated is determined.
Consistent with the embodiments shown in fig. 1C and fig. 2, please refer to fig. 3, fig. 3 is a schematic structural diagram of an electronic device 300 provided in the embodiments of the present application, where the electronic device 300 runs with one or more application programs and an operating system, as shown in the figure, the electronic device 300 includes a processor 310, a memory 320, a communication interface 330, and one or more programs 321, where the one or more programs 321 are stored in the memory 320 and configured to be executed by the processor 310, and the one or more programs 321 include instructions for performing the following steps;
carrying out first time synchronization on the system time of the electronic equipment, and recording corresponding first time information after synchronization;
after the preset absolute time passes, acquiring current second time information of the electronic equipment, wherein the second time information is the current system time of the electronic equipment;
and calculating the time deviation of the electronic equipment according to the first time information, the second time information and the preset absolute time, and determining whether to start RTC (real time clock) deviation calibration of a real time clock chip of the electronic equipment or not according to the time deviation.
It can be seen that, in the embodiment of the present application, an electronic device first performs time synchronization on system time of the electronic device for the first time, and records corresponding first time information after the synchronization, and then acquires current second time information of the electronic device after a preset absolute time elapses, where the second time information is the current system time of the electronic device, and finally, calculates a time offset of the electronic device according to the first time information, the second time information, and the preset absolute time, and determines whether to start RTC offset calibration of a real-time clock chip of the electronic device according to the time offset. The electronic equipment can calculate the time deviation and accumulate the time deviation after realizing network time synchronization through external communication, determine whether to start RTC calibration on the electronic equipment after judging the time deviation, and use the preset absolute time as a calibration period, wherein the period time is longer, so that frequent calibration on the RTC can be avoided, and meanwhile, the RTC calibration precision is improved.
In one possible example, in the calculating of the time offset of the electronic device according to the first time information, the second time information and the preset absolute time, the instructions in the program are specifically configured to: determining third time information according to the first time information and the preset absolute time, wherein the third time information is the current standard system time of the electronic equipment; calculating an absolute value of a time difference between the second time information and the third time information; and calculating the ratio of the absolute value of the time difference value to the preset absolute time to obtain the time deviation.
In one possible example, in the determining whether to initiate a real time clock chip RTC offset calibration on the electronic device according to the time offset, the instructions in the program are specifically configured to: starting RTC offset calibration on the electronic equipment when the time offset is detected to be larger than a calibration threshold value; when it is detected that the time deviation is less than the calibration threshold value, the time deviation is recorded and stored.
In one possible example, the calibration threshold value comprises a first calibration threshold value and a second calibration threshold value; in the aspect of starting RTC offset calibration for the electronic device when it is detected that the time offset is greater than a calibration threshold value, the instructions in the program are specifically configured to perform the following operations: acquiring a power consumption state of the electronic equipment; when the electronic equipment is detected to be in a high power consumption state, acquiring the first calibration threshold value, and when the time deviation is detected to be larger than the first calibration threshold value, starting RTC deviation calibration on the electronic equipment; and when the electronic equipment is detected to be in a low power consumption state, acquiring the second calibration threshold value, and when the time deviation is detected to be larger than the second calibration threshold value, starting RTC deviation calibration on the electronic equipment, wherein the first calibration threshold value is larger than the second calibration threshold value.
In one possible example, after the RTC offset calibration is started for the electronic device when the time offset is detected to be greater than a calibration threshold value, the instructions in the program are specifically configured to perform the following operations: the time offset is set to zero.
In one possible example, after the RTC offset calibration is started for the electronic device when the time offset is detected to be greater than a calibration threshold value, the instructions in the program are specifically configured to perform the following operations: and updating the preset absolute time, wherein the updated preset absolute time is greater than the preset absolute time before updating.
In one possible example, in the calculating of the time offset of the electronic device according to the first time information, the second time information and the preset absolute time, the instructions in the program are specifically configured to: acquiring the time deviation currently recorded by the electronic equipment; and when the time deviation is detected to be not zero, updating the time deviation, wherein the updating is used for accumulating the calculated time deviation to the current time deviation.
The above description has introduced the solution of the embodiment of the present application mainly from the perspective of the method-side implementation process. It is understood that the electronic device comprises corresponding hardware structures and/or software modules for performing the respective functions in order to realize the above-mentioned functions. Those of skill in the art would readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiment of the present application, the electronic device may be divided into the functional units according to the method example, for example, each functional unit may be divided corresponding to each function, or two or more functions may be integrated into one control unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit. It should be noted that the division of the unit in the embodiment of the present application is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
Fig. 4 is a block diagram of functional units of an apparatus 400 involved in the embodiments of the present application. The real-time clock calibration apparatus 400 is applied to an electronic device, and the real-time clock calibration apparatus 400 includes a processing unit 401 and a communication unit 402, wherein:
the processing unit 401 is configured to perform first time synchronization on the system time of the electronic device through the communication unit 402, and record corresponding first time information after the synchronization; the electronic equipment is used for acquiring current second time information of the electronic equipment after a preset absolute time passes, wherein the second time information is the current system time of the electronic equipment; and the real-time clock calibration module is used for calculating the time deviation of the electronic equipment according to the first time information, the second time information and the preset absolute time, and determining whether to start the RTC deviation calibration of the real-time clock chip of the electronic equipment or not according to the time deviation.
It can be seen that, in the embodiment of the present application, an electronic device first performs time synchronization on system time of the electronic device for the first time, and records corresponding first time information after the synchronization, and then acquires current second time information of the electronic device after a preset absolute time elapses, where the second time information is the current system time of the electronic device, and finally, calculates a time offset of the electronic device according to the first time information, the second time information, and the preset absolute time, and determines whether to start RTC offset calibration of a real-time clock chip of the electronic device according to the time offset. The electronic equipment can calculate the time deviation and accumulate the time deviation after realizing network time synchronization through external communication, determine whether to start RTC calibration on the electronic equipment after judging the time deviation, and use the preset absolute time as a calibration period, wherein the period time is longer, so that frequent calibration on the RTC can be avoided, and meanwhile, the RTC calibration precision is improved.
In a possible example, in the aspect of calculating the time offset of the electronic device according to the first time information, the second time information and the preset absolute time, the processing unit 401 is specifically configured to: determining third time information according to the first time information and the preset absolute time, wherein the third time information is the current standard system time of the electronic equipment; and for calculating an absolute value of a time difference between the second time information and the third time information; and the time deviation is obtained by calculating the ratio of the absolute value of the time difference value to the preset absolute time.
In one possible example, in the aspect of determining whether to start RTC offset calibration on the electronic device according to the time offset, the processing unit 401 is specifically configured to: starting RTC offset calibration on the electronic equipment when the time offset is detected to be larger than a calibration threshold value; or, when the time deviation is detected to be smaller than the calibration threshold value, recording and storing the time deviation.
In one possible example, the calibration threshold value comprises a first calibration threshold value and a second calibration threshold value; in the aspect of starting an RTC offset calibration on the electronic device when the time offset is detected to be greater than the calibration threshold value, the processing unit 401 is specifically configured to: acquiring a power consumption state of the electronic equipment; the RTC offset calibration method comprises the steps of acquiring a first calibration threshold value when the electronic equipment is detected to be in a high power consumption state, and starting RTC offset calibration on the electronic equipment when the time offset is detected to be larger than the first calibration threshold value; or, when it is detected that the electronic device is in a low power consumption state, acquiring the second calibration threshold value, and when it is detected that the time offset is greater than the second calibration threshold value, starting RTC offset calibration for the electronic device, where the first calibration threshold value is greater than the second calibration threshold value.
In a possible example, after the RTC offset calibration is started for the electronic device when the time offset is detected to be greater than the calibration threshold value, the processing unit 401 is specifically configured to: the time offset is set to zero.
In a possible example, after the RTC offset calibration is started for the electronic device when the time offset is detected to be greater than the calibration threshold value, the processing unit 401 is specifically configured to: and updating the preset absolute time, wherein the updated preset absolute time is greater than the preset absolute time before updating.
In a possible example, in the aspect of calculating the time offset of the electronic device according to the first time information, the second time information and the preset absolute time, the processing unit 401 is specifically configured to: acquiring the time deviation currently recorded by the electronic equipment; and updating the time offset when detecting that the time offset is not zero, wherein the updating is used for accumulating the calculated time offset to the current time offset.
The electronic device may further include a storage unit 403, the processing unit 401 and the communication unit 402 may be a controller or a processor, and the storage unit 403 may be a memory.
Embodiments of the present application also provide a computer storage medium, where the computer storage medium stores a computer program for electronic data exchange, and the computer program enables a computer to execute part or all of the steps of any one of the methods described in the above method embodiments, and the computer includes a mobile terminal.
Embodiments of the present application also provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the methods as described in the above method embodiments. The computer program product may be a software installation package, the computer comprising a mobile terminal.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units is only one type of division of logical functions, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated into one control unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit may be stored in a computer readable memory if it is implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a memory, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the above-mentioned method of the embodiments of the present application. And the aforementioned memory comprises: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable memory, which may include: flash Memory disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The foregoing detailed description of the embodiments of the present application has been presented to illustrate the principles and implementations of the present application, and the above description of the embodiments is only provided to help understand the method and the core concept of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.
Claims (9)
1. A method of clock calibration, comprising:
carrying out first time synchronization on the system time of the electronic equipment, and recording corresponding first time information after synchronization;
acquiring current second time information of the electronic equipment after a preset absolute time, wherein the second time information is the current system time of the electronic equipment, and the preset absolute time is determined according to the oscillation period of a crystal oscillator and the corresponding relation between the preset oscillation period and the absolute time;
calculating the time deviation of the electronic device according to the first time information, the second time information and the preset absolute time, including: acquiring the time deviation currently recorded by the electronic equipment, and updating the time deviation when the time deviation is detected to be not zero, wherein the updating is used for accumulating the calculated time deviation to the current time deviation;
and determining whether to start RTC (real time clock) offset calibration of the real time clock chip for the electronic equipment according to the time offset.
2. The method of claim 1, wherein calculating the time offset of the electronic device according to the first time information, the second time information and the preset absolute time comprises:
determining third time information according to the first time information and the preset absolute time, wherein the third time information is the current standard system time of the electronic equipment;
calculating an absolute value of a time difference between the second time information and the third time information;
and calculating the ratio of the absolute value of the time difference value to the preset absolute time to obtain the time deviation.
3. The method of claim 1 or 2, wherein the determining whether to initiate real time clock chip (RTC) offset calibration on the electronic device according to the time offset comprises:
starting RTC offset calibration on the electronic equipment when the time offset is detected to be larger than a calibration threshold value;
when it is detected that the time deviation is less than the calibration threshold value, the time deviation is recorded and stored.
4. The method of claim 3, wherein the calibration threshold value comprises a first calibration threshold value and a second calibration threshold value, and wherein initiating RTC offset calibration for the electronic device upon detecting that the time offset is greater than the calibration threshold value comprises:
acquiring a power consumption state of the electronic equipment;
when the electronic equipment is detected to be in a high power consumption state, acquiring the first calibration threshold value, and when the time deviation is detected to be larger than the first calibration threshold value, starting RTC deviation calibration on the electronic equipment;
and when the electronic equipment is detected to be in a low power consumption state, acquiring the second calibration threshold value, and when the time deviation is detected to be larger than the second calibration threshold value, starting RTC deviation calibration on the electronic equipment, wherein the first calibration threshold value is larger than the second calibration threshold value.
5. The method of claim 3, wherein after initiating RTC offset calibration for the electronic device upon detecting that the time offset is greater than a calibration threshold, the method further comprises:
the time offset is set to zero.
6. The method of claim 3, wherein after initiating RTC offset calibration for the electronic device upon detecting that the time offset is greater than a calibration threshold, the method further comprises:
and updating the preset absolute time, wherein the updated preset absolute time is greater than the preset absolute time before updating.
7. A real-time clock calibration apparatus, applied to an electronic device, comprising a processing unit and a communication unit, wherein,
the processing unit is used for carrying out first time synchronization on the system time of the electronic equipment through the communication unit and recording corresponding first time information after synchronization; the electronic equipment is used for acquiring current second time information of the electronic equipment after a preset absolute time passes, wherein the second time information is the current system time of the electronic equipment, and the preset absolute time is determined according to the oscillation period of the crystal oscillator and the corresponding relation between the preset oscillation period and the absolute time; and calculating a time offset of the electronic device according to the first time information, the second time information and the preset absolute time, including: acquiring the time deviation currently recorded by the electronic equipment, and updating the time deviation when the time deviation is detected to be not zero, wherein the updating is used for accumulating the calculated time deviation to the current time deviation; and determining whether to start RTC offset calibration of the real-time clock chip for the electronic equipment according to the time offset.
8. An electronic device comprising a processor, a memory, a communication interface, and one or more programs stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the steps in the method of any of claims 1-6.
9. A computer-readable storage medium, characterized in that a computer program for electronic data exchange is stored, wherein the computer program causes a computer to perform the method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010651828.9A CN111781987B (en) | 2020-07-08 | 2020-07-08 | Real-time clock calibration method and related device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010651828.9A CN111781987B (en) | 2020-07-08 | 2020-07-08 | Real-time clock calibration method and related device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111781987A CN111781987A (en) | 2020-10-16 |
CN111781987B true CN111781987B (en) | 2022-03-22 |
Family
ID=72758562
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010651828.9A Active CN111781987B (en) | 2020-07-08 | 2020-07-08 | Real-time clock calibration method and related device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111781987B (en) |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114553353B (en) * | 2020-11-25 | 2023-09-19 | 成都鼎桥通信技术有限公司 | Timing method and device and vehicle-mounted wireless communication box |
CN112506267B (en) * | 2020-12-01 | 2024-04-19 | 上海银基信息安全技术股份有限公司 | RTC calibration method, vehicle-mounted terminal, user and storage medium |
CN112462846A (en) * | 2020-12-14 | 2021-03-09 | 深圳市晨北科技有限公司 | Clock correction method, clock correction device, computer equipment and storage medium |
CN112637031B (en) * | 2021-01-06 | 2022-06-17 | 广东博智林机器人有限公司 | Calibration method, calibration device and drive control system for slave station control period |
CN113612717A (en) * | 2021-08-11 | 2021-11-05 | 深圳市欧瑞博科技股份有限公司 | Frequency offset calibration method and device, electronic equipment and storage medium |
CN114113977A (en) * | 2021-11-11 | 2022-03-01 | 广州朗国电子科技股份有限公司 | RTC circuit automatic detection method and system of circuit board |
CN114115445B (en) * | 2021-11-19 | 2023-10-17 | 上海移远通信技术股份有限公司 | Method and device for detecting precision of real-time clock RTC |
CN114553355A (en) * | 2022-01-18 | 2022-05-27 | 山东梅格彤天电气有限公司 | High-precision time synchronization method, device and system for low-voltage intelligent terminal |
CN114499732B (en) * | 2022-02-09 | 2023-11-17 | 中央广播电视总台 | Clock calibration method, clock calibration device, computer equipment and readable storage medium |
CN117979412B (en) * | 2024-03-29 | 2024-07-19 | 江铃汽车股份有限公司 | Internal time synchronization method and system for vehicle-mounted communication remote terminal |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107919934A (en) * | 2017-11-20 | 2018-04-17 | 广州谨华电子科技有限公司 | A kind of clock and clock correcting method |
CN108037656A (en) * | 2017-11-13 | 2018-05-15 | 深圳还是威健康科技有限公司 | Real-time timepiece chip calibration method, device and terminal device |
Family Cites Families (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102540868B (en) * | 2010-12-31 | 2016-05-04 | 重庆重邮信科通信技术有限公司 | A kind of slow clock crystal frequency compensation method of mobile communication terminal and device |
CN102497665B (en) * | 2011-12-28 | 2014-12-03 | 深圳市五巨科技有限公司 | Mobile terminal time correction method and apparatus thereof |
CN104297716B (en) * | 2014-09-29 | 2017-02-08 | 江阴长仪集团有限公司 | Intelligent electric meter RTC calibrating method |
US11487871B2 (en) * | 2015-01-31 | 2022-11-01 | San Diego Gas & Electric Company | Methods and systems for detecting and defending against invalid time signals |
CN109392074B (en) * | 2017-08-04 | 2022-02-18 | 华为技术有限公司 | Clock calibration method and device |
US10390305B1 (en) * | 2018-05-16 | 2019-08-20 | Qualcomm Incorporated | Timing calibration control in extended discontinuous reception |
CN109394193B (en) * | 2018-11-27 | 2021-04-23 | 西安交大辰方科技有限公司 | Method for calibrating real-time clock of dynamic blood pressure recorder |
CN110109643B (en) * | 2019-03-14 | 2022-09-23 | 恒玄科技(上海)股份有限公司 | Crystal-oscillator-free USB audio terminal on-chip system and synchronous clock calibration method |
CN110212863B (en) * | 2019-05-31 | 2024-02-13 | Oppo广东移动通信有限公司 | Method, apparatus, electronic device and storage medium for calibrating crystal oscillator |
CN111224733B (en) * | 2020-01-09 | 2020-12-29 | 珠海格力电器股份有限公司 | Time calibration method, device, computer equipment and storage medium |
-
2020
- 2020-07-08 CN CN202010651828.9A patent/CN111781987B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108037656A (en) * | 2017-11-13 | 2018-05-15 | 深圳还是威健康科技有限公司 | Real-time timepiece chip calibration method, device and terminal device |
CN107919934A (en) * | 2017-11-20 | 2018-04-17 | 广州谨华电子科技有限公司 | A kind of clock and clock correcting method |
Also Published As
Publication number | Publication date |
---|---|
CN111781987A (en) | 2020-10-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111781987B (en) | Real-time clock calibration method and related device | |
JP4164662B2 (en) | Portable terminal and GPS time keeping method | |
CN100456858C (en) | Time error compensation device and method for terminal | |
US20080244301A1 (en) | Real-time clock correction methods and apparatus | |
CN108663696B (en) | Method and device for updating temperature and frequency offset relationship, storage medium and mobile terminal | |
WO2001088635A2 (en) | Methods, systems, wireless terminals, and computer program products for calibrating an electronic clock using a base reference signal and a non-continuous calibration reference signal having greater accuracy than the base reference signal | |
JPH07182067A (en) | Detection device of frequency difference between local oscillator and reference signal | |
JP2007078405A (en) | Timing program of software timepiece | |
CN103309228A (en) | Time correcting method of car-mounted terminal system | |
JPH03218494A (en) | Clock with automatic correction of time accuracy | |
CN111817810B (en) | Clock synchronization method, wireless network device and readable storage medium | |
CA2149813A1 (en) | Time correction of an electronic clock | |
US11307537B2 (en) | Communication device, communication method, communication system, electronic watch, and program | |
CN110212863A (en) | Calibrate method, apparatus, electronic equipment and the storage medium of crystal oscillator | |
JPH11223686A (en) | Electronic equipment | |
CN113157047B (en) | Time adjustment method and device, computer equipment and storage medium | |
CN103024778A (en) | Method for improving real-time clock precision on wireless communication terminal | |
CN100565424C (en) | Bearing calibration and device | |
CN114499816B (en) | Clock synchronization method and device, terminal equipment and readable storage medium | |
JP3730914B2 (en) | Mobile communication terminal device | |
CN115061515A (en) | Temperature compensation method, circuit, chip and electronic equipment | |
CN112988179A (en) | Burning method and system for glucometer code card, electronic equipment and storage medium | |
CN111611186A (en) | Transmission control method and device in embedded chip | |
CN116886080B (en) | Control device for timing device and control method thereof | |
US9239588B2 (en) | Method and system for calculating a clock frequency of a clock signal for an IC card |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |