A Method and Device for RTC Clock Time Synchronization on a Real-Time Operating System

By obtaining the crystal oscillator and temperature data of the RTC clock, determining the key point data, and accurately setting the synchronization interval, the time drift problem caused by improper setting of the RTC clock time synchronization period is solved, which improves synchronization and reduces the impact on the life of the RTC.

CN120045385BActive Publication Date: 2025-07-22GUANGZHOU JINQILI INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510534059.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-27
Publication Date
2025-07-22
Estimated Expiration
2045-04-27

AI Technical Summary

Technical Problem

In the prior art, the period setting of RTC clock time synchronization is difficult to adapt to changes in RTC accuracy, resulting in time drift problems, and frequent writing to RTC affects its functional life.

Method used

By obtaining the crystal oscillator-related data and temperature data of the RTC clock, determining the crystal oscillator and temperature key points, combining the system time information, accurately determining the synchronization interval, and achieving accurate synchronization between the RTC clock time and the system time.

Benefits of technology

Improves the synchronization between RTC clock time and system time, and reduces the impact on RTC function life.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045385B_ABST
    Figure CN120045385B_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for RTC clock time synchronization on a real-time operating system. The method includes: obtaining crystal oscillator-related data of the RTC clock and RTC time information, obtaining temperature data of the electronic device and system time information of the real-time operating system; determining the correlation between data points in the crystal oscillator-related data; determining crystal oscillator key point data in the crystal oscillator-related data based on the correlation and the crystal oscillator-related data; determining temperature key point data corresponding to the crystal oscillator key point data in the temperature data; determining a synchronization interval based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator-related data, and the system time information; and performing time synchronization on the RTC clock according to the system time information at the synchronization interval, so as to accurately determine a suitable synchronization interval, improve the synchronization between the RTC clock time and the system time, and reduce the impact on the functional life of the RTC.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to a method and device for RTC clock time synchronization on a real-time operating system. Background Art

[0002] When the device restarts, the operating system reads the RTC (Real_Time Clock) clock time from the RTC and sets it as the system time. This is because during the power-off period of the device, the operating system does not maintain operation, while the independently powered RTC continues to operate and keep the time updated. After the device is running normally and connected to the network, the operating system usually obtains accurate time via the network as the latest system time.

[0003] In related technologies, in order to prevent time drift caused by RTC accuracy problems, the operating system usually writes the latest system time back to the RTC at a set period to complete RTC clock time synchronization, so as to ensure that the RTC clock time is as close as possible to the real time and reduce the impact of time drift. However, the RTC accuracy changes over time. For example, the environment where the RTC is located changes at different times, which leads to changes in RTC accuracy. Thus, if the set period is too long, it is difficult to adapt to the changes in RTC accuracy, resulting in inaccurate RTC clock time in some periods. But if the period is too short, frequently writing information into the RTC easily affects the functional life of the RTC. For example, the non-volatile memory used by the RTC has a fixed write count limit. Summary of the Invention

[0004] To solve the above technical problems, embodiments of this application propose a method and device for RTC clock time synchronization on a real-time operating system, which can accurately determine an appropriate synchronization interval, improve the synchronization between the RTC clock time and the system time, and reduce the impact on the functional life of the RTC.

[0005] In a first aspect, embodiments of this application provide a method for RTC clock time synchronization on a real-time operating system. The real-time operating system is used for an electronic device, and the electronic device includes an RTC clock. The method is executed by the real-time operating system and includes:

[0006] Obtain crystal oscillator-related data and RTC time information of the RTC clock, and obtain temperature data of the electronic device and system time information of the real-time operating system;

[0007] Determine the correlation between data points in the crystal oscillator-related data;

[0008] Determine the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the crystal oscillator related data;

[0009] Determine the temperature key point data corresponding to the crystal oscillator key point data in the temperature data;

[0010] Based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator related data, and the system time information, determine the synchronization interval;

[0011] Synchronize the RTC clock according to the system time information at the synchronization interval.

[0012] Optionally, the determination of the correlation between each data point in the crystal oscillator related data includes:

[0013] Determine the first crystal oscillator data point in the crystal oscillator related data that matches the information of the electronic device;

[0014] Perform a correlation analysis on the first crystal oscillator data point and the second crystal oscillator data point to obtain the correlation, where the second crystal oscillator data point is the data point in the crystal oscillator related data other than the first crystal oscillator data point.

[0015] Optionally, the second crystal oscillator data point includes a third crystal oscillator data point corresponding to high frequency, a fourth crystal oscillator data point corresponding to medium frequency, and a fifth crystal oscillator data point corresponding to low frequency. The performing a correlation analysis on the first crystal oscillator data point and the second crystal oscillator data point to obtain the correlation includes:

[0016] Perform a correlation analysis on the first crystal oscillator data point and the third crystal oscillator data point to obtain a first correlation;

[0017] Perform a correlation analysis on the first crystal oscillator data point and the fourth crystal oscillator data point to obtain a second correlation;

[0018] Perform a correlation analysis on the first crystal oscillator data point and the fifth crystal oscillator data point to obtain a third correlation;

[0019] Determine the correlation based on at least the first correlation, the second correlation, and the third correlation.

[0020] Optionally, the determining the correlation based on at least the first correlation, the second correlation, and the third correlation includes:

[0021] Based on the information of the electronic device, determine the high-frequency weight, the medium-frequency weight, and the low-frequency weight;

[0022] Multiply the first correlation by the high-frequency weight to obtain a fourth correlation;

[0023] Multiply the second correlation by the medium-frequency weight to obtain a fifth correlation;

[0024] Multiply the third correlation by the low-frequency weight to obtain a sixth correlation;

[0025] Determine the correlation based on the fourth correlation, the fifth correlation, and the sixth correlation.

[0026] Optionally, the determining the key oscillator data in the oscillator-related data based on the correlation and the oscillator-related data includes:

[0027] Project the oscillator-related data into a target space based on the correlation to obtain target space data;

[0028] Determine the key oscillator data in the oscillator-related data based on the correlation and the target space data.

[0029] Optionally, the determining the key oscillator data in the oscillator-related data based on the correlation and the target space data includes:

[0030] Perform clustering on the target space data based on the correlation to obtain at least one clustering cluster;

[0031] Determine the key oscillator data from the oscillator-related data based on the at least one clustering cluster.

[0032] Optionally, the determining the synchronization interval based on the RTC time information, the key oscillator data, the key temperature data, the temperature data, the oscillator-related data, and the system time information includes:

[0033] Determine a first error between the RTC time information and the system time information;

[0034] Adjust the first error based on the key oscillator data, the key temperature data, the temperature data, and the oscillator-related data to obtain a third error;

[0035] Determine the synchronization interval based at least on the third error.

[0036] Optionally, the adjusting the first error based on the key oscillator data, the key temperature data, the temperature data, and the oscillator-related data to obtain a third error includes:

[0037] Based on the temperature data and the crystal oscillator related data, perform a rough adjustment on the first error to obtain a second error;

[0038] Based on the crystal oscillator key point data and the temperature key point data, perform a fine adjustment on the second error to obtain the third error.

[0039] Optionally, the method further includes:

[0040] Obtain the crystal oscillator aging information and the power supply voltage fluctuation information of the RTC clock;

[0041] The at least determining the synchronization interval based on the third error includes:

[0042] Based on the crystal oscillator aging information and the power supply voltage fluctuation information, correct the third error to obtain a fourth error;

[0043] Determine the synchronization interval according to the fourth error.

[0044] In a second aspect, an embodiment of the present application provides an RTC clock time synchronization device on a real-time operating system. The real-time operating system is used for an electronic device, and the electronic device includes an RTC clock. The device is applicable to the real-time operating system and includes:

[0045] A data acquisition module, configured to acquire the crystal oscillator related data and RTC time information of the RTC clock, and acquire the temperature data of the electronic device and the system time information of the real-time operating system;

[0046] A correlation determination module, configured to determine the correlation between data points in the crystal oscillator related data;

[0047] A crystal oscillator key point determination module, configured to determine the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the crystal oscillator related data;

[0048] A temperature key point determination module, configured to determine the temperature key point data corresponding to the crystal oscillator key point data in the temperature data;

[0049] A synchronization interval determination module, configured to determine a synchronization interval based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator related data, and the system time information;

[0050] A synchronization module, configured to perform time synchronization on the RTC clock according to the system time information at the synchronization interval.

[0051] In summary, the embodiments of the present application at least have the following beneficial effects:

[0052] By adopting the embodiment of the present application, by obtaining the crystal oscillator related data and RTC time information of the RTC clock, and obtaining the temperature data of the electronic device and the system time information of the real-time operating system; determining the correlation between data points in the crystal oscillator related data; based on the correlation and the crystal oscillator related data, determining the crystal oscillator key point data in the crystal oscillator related data; determining the temperature key point data corresponding to the crystal oscillator key point data in the temperature data; based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator related data and the system time information, determining the synchronization interval; and synchronizing the RTC clock according to the system time information at the synchronization interval, so as to accurately determine a suitable synchronization interval, improve the synchronization between the RTC clock time and the system time, and reduce the impact on the functional life of the RTC. Description of the Drawings

[0053] Figure 1 is a schematic flowchart of a method for synchronizing RTC clock time on a real-time operating system provided by an embodiment of the present application;

[0054] Figure 2 is a schematic structural diagram of a device for synchronizing RTC clock time on a real-time operating system provided by an embodiment of the present application;

[0055] Figure 3 is a schematic diagram of a computer device provided by an embodiment of the present application. Detailed Embodiments

[0056] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0057] In the description of this application, the terms "first", "second", "third", etc. are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first", "second", "third", etc. may explicitly or implicitly include one or more of such features. In the description of this application, unless otherwise specified, the meaning of "a plurality" is two or more. In the description of this application, the term "comprising" and its variants are open-ended, i.e., "including but not limited to". The term "based on" means "at least partially based on". The term "according to" means "at least partially according to". The term "an embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments".

[0058] In the description of this application, it should be noted that unless otherwise clearly defined and limited, the terms "installed", "connected", "coupled" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the communication inside two components. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific situations.

[0059] In the description of this application, it should be noted that unless otherwise defined, all technical and scientific terms used in this application have the same meaning as commonly understood by those skilled in the technical field to which this application belongs. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific situations.

[0060] The following explains some term concepts related to the embodiments of this application:

[0061] RTC (Real_Time Clock, real-time clock) usually includes a crystal oscillator, generally called a crystal resonator / crystal oscillator. The crystal oscillator is one of the core components of the RTC, which determines the accuracy of the clock. Under different working conditions (such as temperature changes), the frequency of the crystal oscillator may change, thus affecting the accuracy of the RTC.

[0062] In a first aspect, referring to Figure 1 , a schematic flowchart of a method for synchronizing RTC clock time on a real-time operating system is shown. The real-time operating system is used for an electronic device, and the electronic device includes an RTC clock. The method is executed by the real-time operating system and includes steps S101 - S106, specifically as follows:

[0063] S101, obtain the crystal oscillator related data and RTC time information of the RTC clock, and obtain the temperature data of the electronic device and the system time information of the real-time operating system.

[0064] In one example, the above RTC time information can be used to indicate the time value recorded by the RTC clock included in the above electronic device, and this time value can generally be the time value when the RTC time information is generated.

[0065] In one example, the above crystal oscillator related data may include data related to the crystal oscillator in the RTC clock. For example, it may include at least one of the following: excitation power data, frequency data, nominal frequency, frequency tolerance, temperature stability, load capacitance data.

[0066] S102, determine the correlation between each data point in the crystal oscillator related data.

[0067] In one example, assume that each data point in the crystal oscillator related data is arranged in time sequence and each data point in the crystal oscillator related data is suitable for characterizing the frequency value. At this time, the analyzed correlation is suitable for indicating the periodicity, trend and / or outlier of the frequency.

[0068] In one example, the correlation in any one or more embodiments of the present application can be obtained by calculating the similarity.

[0069] In one example, the correlation in any one or more embodiments of the present application can be obtained by calculating the partial autocorrelation function. The correlation obtained by calculating the partial autocorrelation function can directly characterize the direct correlation between two data points and exclude the influence of other points. Here, the data for which the correlation needs to be calculated can be first converted into a corresponding data point sequence, and then the partial autocorrelation function is used to calculate the correlation between any two data points in the data point sequence.

[0070] In one example, the above correlation analysis may include similarity calculation and / or partial autocorrelation function. In other words, the analysis result of the correlation analysis (i.e., the above correlation) may include the similarity calculation result and / or the partial autocorrelation function calculation result.

[0071] S103, based on the correlation and the crystal oscillator related data, determine the crystal oscillator key point data in the crystal oscillator related data.

[0072] In one example, assume that each data point in the crystal oscillator related data is suitable for characterizing the frequency value. At this time, the analyzed correlation is suitable for indicating the periodicity, trend and / or outlier of the frequency. Therefore, in this embodiment, the crystal oscillator key point data associated with the periodicity, trend and / or outlier of the frequency can be determined from the crystal oscillator related data.

[0073] Continuing with the above example, taking periodicity as an example, at this time, the key oscillator data within one complete period can be determined from the oscillator-related data.

[0074] Continuing with the above example, taking trend as an example, at this time, the time series analysis (such as time series decomposition) of the oscillator-related data can be performed according to the correlation to obtain the trend term in the oscillator-related data, and the key oscillator data corresponding to the trend term can be determined from the oscillator-related data. Among them, the key oscillator data corresponding to the trend term can include at least one of the following: the key oscillator data corresponding to the inflection point where the trend changes significantly (the key point that can characterize the change in oscillator performance), the key oscillator data corresponding to the highest point and / or the lowest point in the trend (the important indicators that can characterize the oscillator performance, such as the maximum and / or minimum frequency deviation). Among them, the trend term can reflect the change trend of the oscillator performance parameter (such as frequency) on a long time scale.

[0075] S104. Determine the temperature key point data corresponding to the key oscillator data in the temperature data.

[0076] In one example, both the oscillator-related data and the temperature data can carry information such as timestamps. Therefore, the temperature key point data corresponding to the timestamp can be directly determined from the temperature data according to the timestamps corresponding to each data point in the key oscillator data. Here, since the key oscillator data and the temperature key point data used are data within one or more periods of time, the data only needs to reflect the situation within this time range, and it is not necessarily required to be very accurate for each time endpoint.

[0077] S105. Determine the synchronization interval based on the RTC time information, the key oscillator data, the temperature key point data, the temperature data, the oscillator-related data, and the system time information.

[0078] In one example, determining the synchronization interval based on the RTC time information, the key oscillator data, the temperature key point data, the temperature data, the oscillator-related data, and the system time information can include: analyzing the error between the RTC time information and the system time information based on the key oscillator data, the temperature key point data, the temperature data, and the oscillator-related data, and thus determining the synchronization interval according to the error analysis result.

[0079] S106. Synchronize the RTC clock according to the system time information at the synchronization interval.

[0080] In one example, the system time indicated by the system time information can be written into the RTC clock at a synchronization interval to complete the RTC clock time synchronization.

[0081] In an alternative embodiment, determining the correlation between data points in the crystal oscillator related data includes:

[0082] Determining a first crystal oscillator data point in the crystal oscillator related data that matches the information of the electronic device;

[0083] Performing a correlation analysis on the first crystal oscillator data point and a second crystal oscillator data point to obtain the correlation, where the second crystal oscillator data point is a data point in the crystal oscillator related data other than the first crystal oscillator data point.

[0084] In one example, any of the above embodiments related to correlation can be used to perform a correlation analysis on the first crystal oscillator data point and the second crystal oscillator data point, which will not be elaborated here.

[0085] In one example, the information of the electronic device includes the abnormal information, usage information, configuration information, and / or type information of the electronic device.

[0086] Continuing with the above example, the type of electronic device indicated by the type information can be used to reflect how the electronic device usually interacts with the crystal oscillator (for example, for high-precision timing or frequency synthesis), which can help understand which types of crystal oscillator data are the most critical and determine at least some of the first crystal oscillator data points.

[0087] Continuing with the above example, the abnormal situation of the electronic device indicated by the abnormal information can be used to reflect the abnormal situation existing in the electronic device, such as power fluctuations, etc. Since this abnormality may cause changes in the crystal oscillator performance, by identifying the abnormal time point and the type of abnormality indicated by the abnormal information, it can help determine at least some of the first crystal oscillator data points.

[0088] Continuing with the above example, the usage situation of the electronic device indicated by the usage information can be used to reflect the usage pattern of the electronic device (such as whether it is in a high-load state or an idle state), so as to facilitate determining in what situation (usage pattern) and / or time the collected data can best reflect the actual working condition of the electronic device, and thus determine at least some of the first crystal oscillator data points.

[0089] In an alternative embodiment, the second crystal oscillator data point includes a third crystal oscillator data point corresponding to high frequency, a fourth crystal oscillator data point corresponding to medium frequency, and a fifth crystal oscillator data point corresponding to low frequency. Performing a correlation analysis on the first crystal oscillator data point and the second crystal oscillator data point to obtain the correlation includes:

[0090] Perform a correlation analysis on the first crystal oscillator data point and the third crystal oscillator data point to obtain a first correlation;

[0091] Perform a correlation analysis on the first crystal oscillator data point and the fourth crystal oscillator data point to obtain a second correlation;

[0092] Perform a correlation analysis on the first crystal oscillator data point and the fifth crystal oscillator data point to obtain a third correlation;

[0093] Determine the correlation based at least on the first correlation, the second correlation, and the third correlation.

[0094] In one example, determining the correlation based at least on the first correlation, the second correlation, and the third correlation may include: directly adding the first correlation, the second correlation, and the third correlation to obtain the correlation.

[0095] In one example, the correlation analysis performed in this embodiment can be completed using any of the above embodiments related to correlation, which will not be elaborated here.

[0096] In one example, the correlation analysis corresponding to each of the above first correlation, second correlation, and third correlation may include similarity calculation and / or partial autocorrelation function. In other words, the analysis results of the correlation analysis (i.e., the first correlation, the second correlation, and the third correlation) may include similarity calculation results and / or partial autocorrelation function calculation results. Here, by comparing the similarity between two data points, when it is found that the similarity between two data points drops significantly, it means that there are problems (such as frequency drift, increased phase noise, etc.) when the crystal oscillator operates at the corresponding frequency (high, medium, low frequency). Thus, the similarity calculation result can be used to characterize the problems existing when the crystal oscillator operates at the corresponding frequency (high, medium, low frequency), and the magnitude of the value of the similarity calculation result represents the magnitude of the possibility of the corresponding problem and / or the severity of the existing problem. And by calculating the correlation between two data points through the partial autocorrelation function, it helps to identify whether there are specific lag effects and / or delay phenomena when the crystal oscillator operates at the corresponding frequency (high, medium, low frequency). Thus, precise timing can be completed for the operation at the corresponding frequency (high, medium, low frequency) based on the identified lag effects and / or delay phenomena.

[0097] In one example, a correlation analysis based on similarity calculation can be performed on the first crystal oscillator data point and the third crystal oscillator data point, and a correlation analysis based on the partial autocorrelation function can be performed on the first crystal oscillator data point and the fifth crystal oscillator data point. Thus, by comparing the similarity between the first crystal oscillator data point and the third crystal oscillator data point operating under high-frequency conditions, when a significant decrease in the similarity between the two data points is found, it means that there are problems with the crystal oscillator during high-frequency operation (such as frequency drift, increased phase noise, etc., which should be understood to occur more frequently during high-frequency operation). Therefore, the first correlation can be used to characterize the problems existing in the crystal oscillator during high-frequency operation. And by calculating the third correlation between the first crystal oscillator data point and the fifth crystal oscillator data point through the partial autocorrelation function, it helps to identify whether there are specific hysteresis effects and / or delay phenomena in the crystal oscillator during low-frequency operation (it should be understood that hysteresis effects and / or delay phenomena are more likely to exist during low-frequency operation), so that precise timing can be completed based on the identified hysteresis effects and / or delay phenomena.

[0098] In an alternative embodiment, determining the correlation based on at least the first correlation, the second correlation, and the third correlation includes:

[0099] Determine a high-frequency weight, an intermediate-frequency weight, and a low-frequency weight based on the information of the electronic device;

[0100] Multiply the first correlation by the high-frequency weight to obtain a fourth correlation;

[0101] Multiply the second correlation by the intermediate-frequency weight to obtain a fifth correlation;

[0102] Multiply the third correlation by the low-frequency weight to obtain a sixth correlation;

[0103] Determine the correlation based on the fourth correlation, the fifth correlation, and the sixth correlation.

[0104] In one example, it is assumed that the information of the electronic device includes the abnormal information and / or usage information of the electronic device. At this time, the above information provided by the electronic device can be considered to determine the weights of different frequency bands.

[0105] For example, in the high-frequency weight, if the usage information indicates that the electronic device is mainly used for high-frequency applications (such as high-speed data transmission), then the high-frequency weight may be relatively high. In the medium-frequency weight, if the usage information indicates that the electronic device is commonly used in applications that require both stable frequency and adaptation to certain changes (for example, certain types of communication devices have specific requirements for medium-frequency stability), then the medium-frequency weight can be appropriately increased. In the low-frequency weight, if the usage information indicates that the electronic device focuses on characteristics such as low power consumption or long battery life, then the low-frequency weight will be correspondingly increased.

[0106] In addition, if the abnormal information indicates that the electronic device has more abnormalities in the corresponding frequency band, then the weight of the corresponding frequency band should be appropriately increased to pay more attention to the performance of that frequency band.

[0107] In one example, the correlation can be obtained by adding the fourth correlation, the fifth correlation, and the sixth correlation.

[0108] In an alternative implementation, determining the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the crystal oscillator related data includes:

[0109] Projecting the crystal oscillator related data into a target space based on the correlation to obtain target space data;

[0110] Determining the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the target space data.

[0111] In one example, projecting the crystal oscillator related data into a target space based on the correlation to obtain target space data may include: determining the distances between the data points in the crystal oscillator related data based on the correlation, and projecting each data point in the crystal oscillator related data into the target space according to the distance to obtain target space data.

[0112] In one example, the target space can be a frequency domain space (in this case, the projection can be achieved through Fourier transform), so that the performance of the data at different frequencies can be more intuitively observed in the obtained target space data. Therefore, combining the analyzed correlation with the target space data at this time can more accurately obtain the periodicity, trend, and / or outliers of the frequency. Further, the crystal oscillator key point data can be determined from the crystal oscillator related data according to the more accurate periodicity, trend, and / or outliers of the frequency.

[0113] In one example, the target space can be a two-dimensional or three-dimensional space. At this time, time and frequency, or temperature and frequency, etc. can be selected as the two dimensions of the target space for representation. Then, the correlation is displayed as the third-dimensional information (such as color) on a two-dimensional plane, or the correlation is used as the third dimension in a three-dimensional space, thereby forming target space data. In this way, the crystal oscillator-related data can be converted into target space data that is more convenient for intuitive display.

[0114] In an alternative embodiment, determining the crystal oscillator key point data in the crystal oscillator-related data based on the correlation and the target space data includes:

[0115] Performing clustering processing on the target space data based on the correlation to obtain at least one clustering cluster;

[0116] Determining the crystal oscillator key point data from the crystal oscillator-related data based on the at least one clustering cluster.

[0117] In one example, the above clustering processing may include DBSCAN (Density-Based Spatial Clustering of Applications with Noise).

[0118] In one example, the crystal oscillator key point data may be data points corresponding to the clustering centers of at least one clustering cluster in the crystal oscillator-related data. For example, they may be data points with a distance less than a preset distance threshold and / or a similarity higher than a preset similarity threshold from the clustering center, and / or data points with the smallest distance and / or the highest similarity.

[0119] In an alternative embodiment, determining the synchronization interval based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator-related data, and the system time information includes:

[0120] Determining a first error between the RTC time information and the system time information;

[0121] Adjusting the first error based on the crystal oscillator key point data, the temperature key point data, the temperature data, and the crystal oscillator-related data to obtain a third error;

[0122] Determining the synchronization interval based at least on the third error.

[0123] In one example, the above synchronization interval can be determined based only on the third error, such that the synchronization interval can adapt to the obtained third error. That is, after obtaining the third error, since the interval since the last RTC clock time synchronization is clearly known, the error value within this interval can be known, and thus it is possible to know how large a synchronization interval needs to be set to adapt to the third error.

[0124] In an alternative embodiment, the adjusting the first error based on the crystal oscillator key point data, the temperature key point data, the temperature data, and the crystal oscillator related data to obtain a third error includes:

[0125] Coarsely adjusting the first error based on the temperature data and the crystal oscillator related data to obtain a second error;

[0126] Finely adjusting the second error based on the crystal oscillator key point data and the temperature key point data to obtain the third error.

[0127] In this embodiment, coarse adjustment can be first performed to reduce the first error and obtain a second error. Specifically, since the frequency of the crystal oscillator changes with temperature, by using the temperature data and querying the expected frequency at the current temperature using a pre-determined temperature-frequency relationship curve (usually determined by the model of the crystal oscillator), and then combining with the actual frequency indicated by the crystal oscillator related data, the frequency offset at the current temperature can be estimated, and then the first error can be preliminarily corrected according to this offset; then further fine adjustment is performed based on the key point data to minimize the error (the principle of adjustment can be similar to the above-mentioned coarse adjustment) to obtain the third error.

[0128] In an alternative embodiment, the method further includes:

[0129] Obtaining crystal oscillator aging information and power supply voltage fluctuation information of the RTC clock;

[0130] The determining the synchronization interval based at least on the third error includes:

[0131] Correcting the third error based on the crystal oscillator aging information and the power supply voltage fluctuation information to obtain a fourth error;

[0132] Determining the synchronization interval according to the fourth error.

[0133] It should be noted that the aging effect refers to the phenomenon that the frequency of a crystal oscillator changes slowly over time. This change is usually caused by changes in the internal structure of the crystal oscillator material, such as impurity diffusion in the crystal, changes in the electrode material, etc. Generally, as time increases, the frequency output by the crystal oscillator will gradually deviate from its initial value, resulting in frequency drift. This drift is usually unidirectional, that is, the frequency either continuously increases or continuously decreases. Therefore, it will lead to a decrease in the long-term stability of the crystal oscillator, making the crystal oscillator unable to maintain its original high-precision frequency output after long-term operation.

[0134] It should be noted that power supply fluctuations refer to the unstable phenomenon of the supply voltage or current, usually caused by poor power grid quality, sudden load changes, or other electrical interferences. For a crystal oscillator, power supply fluctuations can directly affect its working state and the quality of the output signal. For example, a slight change in the power supply voltage may cause short-term fluctuations in the output frequency of the crystal oscillator, known as frequency jitter (thus affecting applications that require extremely high frequency stability, such as communication systems), and / or, power supply fluctuations may also introduce additional phase noise, reducing the purity of the signal and affecting the reliability of data transmission.

[0135] In this embodiment, the influence of the crystal oscillator aging information and the power supply fluctuation information of the power supply can also be considered, so as to further correct the third error to obtain the fourth error, so that the determined synchronization interval is more accurate and more in line with the actual situation of the RTC.

[0136] In a second aspect, correspondingly, an RTC clock time synchronization device on a real-time operating system provided by an embodiment of the present application can implement all the processes of the RTC clock time synchronization method on a real-time operating system provided by the above embodiment.

[0137] See Figure 2 , which shows a schematic structural diagram of an RTC clock time synchronization device on a real-time operating system provided by an embodiment of the present application. The real-time operating system is used for an electronic device, and the electronic device includes an RTC clock. The device is applicable to the real-time operating system and includes:

[0138] A data acquisition module 201, configured to acquire crystal oscillator-related data and RTC time information of the RTC clock, and acquire temperature data of the electronic device and system time information of the real-time operating system;

[0139] A correlation determination module 202, configured to determine the correlation between each data point in the crystal oscillator-related data;

[0140] A crystal oscillator key point determination module 203, configured to determine crystal oscillator key point data in the crystal oscillator-related data based on the correlation and the crystal oscillator-related data;

[0141] A temperature key point determination module 204, configured to determine temperature key point data corresponding to the crystal oscillator key point data in the temperature data;

[0142] A synchronization interval determination module 205, configured to determine a synchronization interval based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator related data, and the system time information;

[0143] A synchronization module 206, configured to perform time synchronization on the RTC clock according to the system time information at the synchronization interval.

[0144] In an optional implementation manner, determining the correlation between data points in the crystal oscillator related data includes:

[0145] Determining a first crystal oscillator data point in the crystal oscillator related data that matches the information of the electronic device;

[0146] Performing a correlation analysis on the first crystal oscillator data point and a second crystal oscillator data point to obtain the correlation, where the second crystal oscillator data point is a data point in the crystal oscillator related data other than the first crystal oscillator data point.

[0147] In an optional implementation manner, the second crystal oscillator data point includes a third crystal oscillator data point corresponding to a high frequency, a fourth crystal oscillator data point corresponding to a medium frequency, and a fifth crystal oscillator data point corresponding to a low frequency. Performing a correlation analysis on the first crystal oscillator data point and the second crystal oscillator data point to obtain the correlation includes:

[0148] Performing a correlation analysis on the first crystal oscillator data point and the third crystal oscillator data point to obtain a first correlation;

[0149] Performing a correlation analysis on the first crystal oscillator data point and the fourth crystal oscillator data point to obtain a second correlation;

[0150] Performing a correlation analysis on the first crystal oscillator data point and the fifth crystal oscillator data point to obtain a third correlation;

[0151] Determining the correlation based on at least the first correlation, the second correlation, and the third correlation.

[0152] In an optional implementation manner, determining the correlation based on at least the first correlation, the second correlation, and the third correlation includes:

[0153] Based on the information of the electronic device, determining a high frequency weight, a medium frequency weight, and a low frequency weight;

[0154] Multiply the first correlation by the high-frequency weight to obtain a fourth correlation;

[0155] Multiply the second correlation by the medium-frequency weight to obtain a fifth correlation;

[0156] Multiply the third correlation by the low-frequency weight to obtain a sixth correlation;

[0157] Determine the correlation based on the fourth correlation, the fifth correlation, and the sixth correlation.

[0158] In an alternative embodiment, the determining the key oscillator data in the oscillator-related data based on the correlation and the oscillator-related data includes:

[0159] Project the oscillator-related data into a target space based on the correlation to obtain target space data;

[0160] Determine the key oscillator data in the oscillator-related data based on the correlation and the target space data.

[0161] In an alternative embodiment, the determining the key oscillator data in the oscillator-related data based on the correlation and the target space data includes:

[0162] Perform clustering processing on the target space data based on the correlation to obtain at least one clustering cluster;

[0163] Determine the key oscillator data from the oscillator-related data based on the at least one clustering cluster.

[0164] In an alternative embodiment, the determining the synchronization interval based on the RTC time information, the key oscillator data, the key temperature data, the temperature data, the oscillator-related data, and the system time information includes:

[0165] Determine a first error between the RTC time information and the system time information;

[0166] Adjust the first error based on the key oscillator data, the key temperature data, the temperature data, and the oscillator-related data to obtain a third error;

[0167] Determine the synchronization interval based at least on the third error.

[0168] In an alternative embodiment, the adjusting the first error based on the key oscillator data, the key temperature data, the temperature data, and the oscillator-related data to obtain a third error includes:

[0169] Based on the temperature data and the crystal oscillator related data, perform a rough adjustment on the first error to obtain a second error;

[0170] Based on the crystal oscillator key point data and the temperature key point data, perform a fine adjustment on the second error to obtain the third error.

[0171] In an alternative embodiment, the apparatus further includes:

[0172] An information acquisition module, configured to acquire the crystal oscillator aging information and the power supply fluctuation information of the RTC clock;

[0173] The determining the synchronization interval based at least on the third error includes:

[0174] Based on the crystal oscillator aging information and the power supply fluctuation information, correct the third error to obtain a fourth error;

[0175] Determine the synchronization interval according to the fourth error.

[0176] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the RTC clock time synchronization method on the real-time operating system described in any one of the above are implemented.

[0177] In a fourth aspect, an embodiment of the present application provides a computer program product, including computer instructions, and when the computer instructions are executed by a processor, the steps of the RTC clock time synchronization method on the real-time operating system described in any one of the above are implemented.

[0178] In a fifth aspect, an embodiment of the present application provides a computer device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, the steps of the RTC clock time synchronization method on the real-time operating system described in any one of the above are implemented.

[0179] See Figure 3 , the computer device of this embodiment includes: a processor 301, a memory 302, and a computer program stored in the memory 302 and operable on the processor 301, such as an RTC clock time synchronization program on a real-time operating system. When the processor 301 executes the computer program, the steps in the embodiments of the above-mentioned RTC clock time synchronization methods are implemented, such as Figure 1 the steps S101 - S106 shown.

[0180] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 302 and executed by the processor 301 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program in the computer device.

[0181] The computer device may be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The computer device may include, but is not limited to, a processor 301 and a memory 302. Those skilled in the art can understand that the schematic diagram is only an example of the computer device and does not constitute a limitation on the computer device. It may include more or fewer components than shown in the figure, or combine some components, or different components. For example, the computer device may also include input / output devices, network access devices, a bus, etc.

[0182] The processor 301 may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor 301 may also be any conventional processor, etc. The processor 301 is the control center of the computer device and connects various parts of the entire computer device through various interfaces and circuits.

[0183] The memory 302 can be used to store the computer programs and / or modules. By running or executing the computer programs and / or modules stored in the memory 302, and invoking the data stored in the memory 302, the processor 301 realizes various functions of the computer device. The memory 302 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the mobile phone (such as audio data, phone book, etc.). In addition, the memory 302 may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0184] Among them, if the modules / units integrated in the computer device are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above embodiment methods of this application, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor 301, the steps of the above various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, an executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disc, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.

[0185] In summary, the embodiments of this application at least have the following beneficial effects:

[0186] By adopting the embodiment of the present application, by obtaining the crystal oscillator related data and RTC time information of the RTC clock, and obtaining the temperature data of the electronic device and the system time information of the real-time operating system; determining the correlation between data points in the crystal oscillator related data; based on the correlation and the crystal oscillator related data, determining the crystal oscillator key point data in the crystal oscillator related data; determining the temperature key point data corresponding to the crystal oscillator key point data in the temperature data; based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator related data and the system time information, determining the synchronization interval; and synchronizing the RTC clock according to the system time information at the synchronization interval, so as to accurately determine a suitable synchronization interval, improve the synchronization between the RTC clock time and the system time, and reduce the impact on the functional life of the RTC.

[0187] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary hardware platform, and of course, it can also be implemented entirely by hardware. Based on such an understanding, all or part of the technical solution of the present application that contributes to the background technology can be embodied in the form of a software product. The computer software product can be stored in a storage medium, such as ROM (Read-Only Memory), RAM (Random Access Memory), magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments of the present application.

[0188] The above is the preferred embodiment of the present application. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present application, several improvements and retouches can be made, and these improvements and retouches are also regarded as the protection scope of the present application.

Claims

1. A method for RTC clock time synchronization on a real-time operating system, characterized in that, The real-time operating system is used for an electronic device, and the electronic device includes an RTC clock. The method is executed by the real-time operating system and includes: Obtaining crystal oscillator related data and RTC time information of the RTC clock, and obtaining temperature data of the electronic device and system time information of the real-time operating system; Determining the correlation between data points in the crystal oscillator related data; Based on the correlation and the crystal oscillator related data, determining crystal oscillator key point data in the crystal oscillator related data; Determining temperature key point data corresponding to the crystal oscillator key point data in the temperature data; Based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator related data, and the system time information, determining a synchronization interval; According to the synchronization interval, performing time synchronization on the RTC clock according to the system time information; The determining the synchronization interval based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator related data, and the system time information includes: Determining a first error between the RTC time information and the system time information; Based on the crystal oscillator key point data, the temperature key point data, the temperature data, and the crystal oscillator related data, adjusting the first error to obtain a third error; Determining the synchronization interval based at least on the third error.

2. The method according to claim 1, characterized in that, The determining the correlation between data points in the crystal oscillator related data includes: Determining a first crystal oscillator data point in the crystal oscillator related data that matches the information of the electronic device; Performing a correlation analysis on the first crystal oscillator data point and a second crystal oscillator data point to obtain the correlation, where the second crystal oscillator data point is a data point in the crystal oscillator related data other than the first crystal oscillator data point.

3. The method according to claim 2, wherein The second crystal oscillator data point includes a third crystal oscillator data point corresponding to a high frequency, a fourth crystal oscillator data point corresponding to a medium frequency, and a fifth crystal oscillator data point corresponding to a low frequency. The performing a correlation analysis on the first crystal oscillator data point and the second crystal oscillator data point to obtain the correlation includes: Performing a correlation analysis on the first crystal oscillator data point and the third crystal oscillator data point to obtain a first correlation; Performing a correlation analysis on the first crystal oscillator data point and the fourth crystal oscillator data point to obtain a second correlation; Performing a correlation analysis on the first crystal oscillator data point and the fifth crystal oscillator data point to obtain a third correlation; Determining the correlation based at least on the first correlation, the second correlation, and the third correlation.

4. The method according to claim 3, wherein The determining the correlation based at least on the first correlation, the second correlation, and the third correlation includes: Based on the information of the electronic device, determining a high frequency weight, a medium frequency weight, and a low frequency weight; Multiplying the first correlation by the high frequency weight to obtain a fourth correlation; Multiplying the second correlation by the medium frequency weight to obtain a fifth correlation; Multiplying the third correlation by the low frequency weight to obtain a sixth correlation; Determine the correlation based on the fourth correlation, the fifth correlation, and the sixth correlation.

5. The method according to claim 1, characterized in that The determining of the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the crystal oscillator related data includes: Project the crystal oscillator related data into a target space based on the correlation to obtain target space data; Determine the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the target space data.

6. The method according to claim 5, wherein The determining of the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the target space data includes: Perform clustering processing on the target space data based on the correlation to obtain at least one clustering cluster; Determine the crystal oscillator key point data from the crystal oscillator related data based on the at least one clustering cluster.

7. The method according to claim 1, characterized in that, The adjusting of the first error based on the crystal oscillator key point data, the temperature key point data, the temperature data, and the crystal oscillator related data to obtain a third error includes: Coarsely adjust the first error based on the temperature data and the crystal oscillator related data to obtain a second error; Finely adjust the second error based on the crystal oscillator key point data and the temperature key point data to obtain the third error.

8. The method according to any one of claims 1 to 7, characterized in that The method further includes: Obtain the crystal oscillator aging information and the power supply voltage fluctuation information of the RTC clock; The determining of the synchronization interval based at least on the third error includes: Correct the third error based on the crystal oscillator aging information and the power supply voltage fluctuation information to obtain a fourth error; Determine the synchronization interval according to the fourth error.

9. A RTC clock time synchronization device on a real-time operating system, characterized in that, The real-time operating system is used for an electronic device, the electronic device includes an RTC clock, and the apparatus is applicable to the real-time operating system and includes: A data acquisition module, configured to acquire the crystal oscillator related data and the RTC time information of the RTC clock, and acquire the temperature data of the electronic device and the system time information of the real-time operating system; A correlation determination module, configured to determine the correlation between data points in the crystal oscillator related data; A crystal oscillator key point determination module, configured to determine the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the crystal oscillator related data; A temperature key point determination module, configured to determine the temperature key point data corresponding to the crystal oscillator key point data in the temperature data; A synchronization interval determination module, configured to determine a synchronization interval based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator related data, and the system time information; A synchronization module, configured to perform time synchronization on the RTC clock according to the system time information at the synchronization interval; The determining of the synchronization interval based on the RTC time information, the crystal oscillator key point data, the temperature key point data, the temperature data, the crystal oscillator related data, and the system time information includes: Determine a first error between the RTC time information and the system time information; Based on the crystal oscillator key point data, the temperature key point data, the temperature data, and the crystal oscillator related data, adjust the first error to obtain a third error; Determine the synchronization interval based at least on the third error.

Citation Information

Patent Citations

  • Local clock synchronization keeping method and device

    CN112821976A