RTC clock time synchronization method and device on real-time operating system
By acquiring and analyzing the crystal oscillator and temperature data of the RTC clock, the synchronization interval is accurately determined, which solves the problems of time drift and functional life in RTC clock time synchronization, and improves synchronization and life.
Patent Information
- Application Number
- CN202510534059.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2045-04-27
AI Technical Summary
The prior art is difficult to accurately adapt to RTC accuracy changes in RTC clock time synchronization, resulting in time drift, and frequent writing to RTC can easily affect its functional life.
By obtaining the crystal oscillator-related data and temperature data of the RTC clock, the crystal oscillator and temperature key points are determined. Based on these data and system time information, the synchronization interval is accurately determined, and the RTC clock time synchronization is performed according to the interval.
Improves synchronization between RTC clock time and system time, and reduces the impact on RTC function life.
Smart Images

Figure CN120045385A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technologies, and in particular, to a method and apparatus for RTC clock time synchronization on a real-time operating system. Background Art
[0002] When a device restarts, the operating system reads the RTC (Real-Time Clock) time from the RTC and sets it as the system time. This is because during a power outage 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, to prevent time drift caused by RTC accuracy issues, 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 in turn causes the RTC accuracy to change. 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 apparatus for RTC clock time synchronization on a real-time operating system, which can 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.
[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: Obtaining 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 oscillator-related data; Based on the correlation and the oscillator-related data, determining oscillator key point data in the oscillator-related data; Determine 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, determine the synchronization interval; Synchronize the RTC clock according to the system time information at the synchronization interval.
[0006] Optionally, the determining the correlation between data points in the crystal oscillator related data includes: Determine the first crystal oscillator data point in the crystal oscillator related data that matches the information of the electronic device; 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.
[0007] 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: Perform a correlation analysis on the first crystal oscillator data point and the third crystal oscillator data point to obtain a first correlation; Perform a correlation analysis on the first crystal oscillator data point and the fourth crystal oscillator data point to obtain a second correlation; Perform a correlation analysis on the first crystal oscillator data point and the fifth crystal oscillator data point to obtain a third correlation; Determine the correlation based on at least the first correlation, the second correlation, and the third correlation.
[0008] Optionally, the determining the correlation based on at least the first correlation, the second correlation, and the third correlation includes: Based on the information of the electronic device, determine the high frequency weight, the medium frequency weight, and the low frequency weight; Multiply the first correlation by the high frequency weight to obtain a fourth correlation; Multiply the second correlation by the medium frequency weight to obtain a fifth correlation; Multiply 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.
[0009] Optionally, determining the key oscillator data in the oscillator-related data based on the correlation and the oscillator-related data includes: Projecting the oscillator-related data into a target space based on the correlation to obtain target space data; Determining the key oscillator data in the oscillator-related data based on the correlation and the target space data.
[0010] Optionally, determining the key oscillator data in the oscillator-related data based on the correlation and the target space data includes: Performing clustering processing on the target space data based on the correlation to obtain at least one clustering cluster; Determining the key oscillator data from the oscillator-related data based on the at least one clustering cluster.
[0011] Optionally, 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: Determining a first error between the RTC time information and the system time information; 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; Determining the synchronization interval based at least on the third error.
[0012] Optionally, 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: Coarsely adjusting the first error based on the temperature data and the oscillator-related data to obtain a second error; Finely adjusting the second error based on the key oscillator data and the key temperature data to obtain the third error.
[0013] Optionally, the method further includes: Obtaining the oscillator aging information and the power supply voltage fluctuation information of the RTC clock; The determining the synchronization interval based at least on the third error includes: Correcting the third error based on the oscillator aging information and the power supply voltage fluctuation information to obtain a fourth error; Determining the synchronization interval according to the fourth error.
[0014] Second aspect, an embodiment of the present application provides an RTC clock time synchronization device on a real-time operating system, where the real-time operating system is used for an electronic device, the electronic device includes an RTC clock, and the device is applicable to the real-time operating system and includes: A data acquisition module, 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; 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 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 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.
[0015] In summary, the embodiment of the present application has at least the following beneficial effects: By adopting the embodiment of the present application, by acquiring crystal oscillator related data and RTC time information of the RTC clock, and acquiring 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; performing time synchronization on the RTC clock according to the system time information at the synchronization interval, it is possible 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
[0016] Figure 1 is a schematic flowchart of an RTC clock time synchronization method on a real-time operating system provided by an embodiment of the present application; Figure 2 is 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; Figure 3 It is a schematic diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0017] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying 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. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the protection scope of the present application.
[0018] In the description of the present 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 the present application, unless otherwise stated, the meaning of "a plurality" is two or more. In the description of the present application, the term "including" and its variants are open-ended inclusions, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "according to" is "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".
[0019] In the description of the present application, it should be noted that, unless otherwise clearly defined and limited, the terms "installed", "connected", and "coupled" should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection or an electrical connection; it may be directly connected, or indirectly connected through an intermediate medium, and it may be the communication inside two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific situations.
[0020] In the description of the present application, it should be noted that, unless otherwise defined, all the technical and scientific terms used in the present application have the same meanings as those commonly understood by those skilled in the technical field to which the present application belongs. The terms used in the specification of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific situations.
[0021] Next, some term concepts related to the embodiments of the present application will be explained: The RTC (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.
[0022] In a first aspect, referring to Figure 1 , a flowchart of a method for synchronizing RTC clock time on a real - time operating system provided by an embodiment of the present application 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: 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.
[0023] In an example, the above - mentioned RTC time information can be used to indicate the time value recorded by the RTC clock included in the above - mentioned electronic device, and this time value is usually the time value at the time of generating the RTC time information.
[0024] In an example, the above - mentioned 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.
[0025] S102, determine the correlation between each data point in the crystal - oscillator - related data.
[0026] In an example, assuming 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 a frequency value, the analyzed correlation is suitable for indicating the periodicity, trend, and / or outliers of the frequency.
[0027] In an example, the correlation in any one or more embodiments of the present application can be obtained by calculating similarity.
[0028] In an 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, excluding 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.
[0029] In one example, the above-mentioned 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-mentioned correlation) may include the similarity calculation result and / or the partial autocorrelation function calculation result.
[0030] S103. Based on the correlation and the crystal oscillator related data, determine the crystal oscillator key point data in the crystal oscillator related data.
[0031] 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 outliers of the frequency. Therefore, in this embodiment, the crystal oscillator key point data associated with the periodicity, trend, and / or outliers of the frequency can be determined from the crystal oscillator related data.
[0032] Continuing with the above example, taking periodicity as an example, at this time, the crystal oscillator key point data within one complete period can be determined from the crystal oscillator related data.
[0033] Continuing with the above example, taking trend as an example, at this time, time series analysis (such as time series decomposition) can be performed on the crystal oscillator related data according to the correlation to obtain the trend term in the crystal oscillator related data, and the crystal oscillator key point data corresponding to the trend term can be determined from the crystal oscillator related data. Among them, the crystal oscillator key point data corresponding to the trend term may include at least one of the following: the crystal oscillator key point data corresponding to the inflection point where the trend changes significantly (which can characterize the key point where the crystal oscillator performance changes), the crystal oscillator key point data corresponding to the highest point and / or the lowest point in the trend (which can characterize the important indicators of the crystal oscillator performance, such as the maximum and / or minimum frequency deviation). Among them, the trend term can reflect the change trend of the crystal oscillator performance parameter (such as frequency) on a long time scale.
[0034] S104. Determine the temperature key point data in the temperature data corresponding to the crystal oscillator key point data.
[0035] In one example, both the crystal oscillator related data and the temperature data may 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 crystal oscillator key point data. Here, since the used crystal oscillator key point data and temperature key point data 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.
[0036] S105. 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.
[0037] In one example, 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 may include: analyzing the 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, and then determining the synchronization interval according to the error analysis result.
[0038] S106. Synchronize the RTC clock according to the system time information at the synchronization interval.
[0039] In one example, the system time indicated by the system time information may be written into the RTC clock at the synchronization interval to complete the RTC clock time synchronization.
[0040] In an alternative embodiment, 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 the data point in the crystal oscillator related data other than the first crystal oscillator data point.
[0041] In one example, any of the above embodiments related to correlation may be used to perform the correlation analysis on the first crystal oscillator data point and the second crystal oscillator data point, which will not be elaborated here.
[0042] 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.
[0043] 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.
[0044] 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 supply 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.
[0045] Continuing with the above example, the usage 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 at what time the collected data can best reflect the actual working condition of the electronic device, thereby determining at least some of the first crystal oscillator data points.
[0046] In an alternative embodiment, the second crystal oscillator data points include a third crystal oscillator data point corresponding to a high frequency, a fourth crystal oscillator data point corresponding to an intermediate frequency, and a fifth crystal oscillator data point corresponding to a low frequency. The performing a correlation analysis on the first crystal oscillator data points and the second crystal oscillator data points to obtain the correlation includes: Performing a correlation analysis on the first crystal oscillator data points and the third crystal oscillator data points to obtain a first correlation; Performing a correlation analysis on the first crystal oscillator data points and the fourth crystal oscillator data points to obtain a second correlation; Performing a correlation analysis on the first crystal oscillator data points and the fifth crystal oscillator data points to obtain a third correlation; Determining the correlation based at least on the first correlation, the second correlation, and the third correlation.
[0047] In an 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.
[0048] In an 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.
[0049] In one example, the correlation analysis corresponding to each of the above-mentioned 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, second correlation, and 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 the two data points significantly decreases, 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. 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.
[0050] 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. In this way, by comparing the similarity between the first crystal oscillator data point and the third crystal oscillator data point operating under high-frequency conditions, when it is found that the similarity between the two data points significantly decreases, it means that there are problems (such as frequency drift, increased phase noise, etc., which should be understood to occur more frequently during high-frequency operation) when the crystal oscillator operates at high frequency. Thus, the first correlation can be used to characterize the problems existing when the crystal oscillator operates at high frequency. 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 lag effects and / or delay phenomena when the crystal oscillator operates at low frequency (it should be understood that lag effects and / or delay phenomena are more likely to exist during low-frequency operation). Thus, precise timing can be completed based on the identified lag effects and / or delay phenomena.
[0051] In an alternative implementation manner, determining the correlation based on at least the first correlation, the second correlation, and the third correlation includes: Determining a high-frequency weight, a medium-frequency weight, and a low-frequency weight based on the information of the electronic device; 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; Multiply 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.
[0052] In one example, assume 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.
[0053] 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 higher. 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), 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, the low-frequency weight will be correspondingly increased.
[0054] In addition, if the abnormal information indicates that the electronic device has more abnormalities in the corresponding frequency band, the weight of the corresponding frequency band should be appropriately increased to pay more attention to the performance of this frequency band.
[0055] In one example, the correlation can be obtained by adding the fourth correlation, the fifth correlation, and the sixth correlation.
[0056] In an alternative implementation, the determining 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.
[0057] 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 the data points in the crystal oscillator related data into the target space according to the distances to obtain target space data.
[0058] In one example, the target space can be a frequency domain space (in which case the projection can be achieved through Fourier transform), so that the obtained target space data can more intuitively observe the performance of the data at different frequencies. Therefore, the correlation analyzed at this time combined with the target space data 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.
[0059] 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 the two-dimensional plane, or the correlation is used as the third dimension in the three-dimensional space to form the target space data. In this way, the crystal oscillator related data can be converted into the target space data that is more convenient for intuitive display.
[0060] 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: Performing clustering processing on the target space data based on the correlation to obtain at least one clustering cluster; Determining the crystal oscillator key point data from the crystal oscillator related data based on the at least one clustering cluster.
[0061] In one example, the above clustering processing may include DBSCAN (Density-Based Spatial Clustering of Applications with Noise, density-based clustering algorithm).
[0062] In one example, the crystal oscillator key point data can be the data points in the crystal oscillator related data corresponding to the respective clustering centers of at least one clustering cluster. For example, it can be the data points whose distance from the clustering center is less than a preset distance threshold and / or the similarity is higher than a preset similarity threshold, and / or the data points with the smallest distance and / or the highest similarity.
[0063] 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: Determining a first error between the RTC time information and the system time information; 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; Determine the synchronization interval based at least on the third error.
[0064] In one example, the above synchronization interval can be determined only based 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.
[0065] 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: Coarsely adjusting the first error based on the temperature data and the crystal oscillator related data to obtain a second error; Finely adjusting the second error based on the crystal oscillator key point data and the temperature key point data to obtain the third error.
[0066] 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 coarse adjustment) to obtain the third error.
[0067] In an alternative embodiment, the method further includes: Obtain the crystal oscillator aging information and the power supply voltage fluctuation information of the RTC clock; The determining 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.
[0068] 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.
[0069] It should be noted that power supply fluctuations refer to the instability 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 frequency output by the crystal oscillator, called 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.
[0070] 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.
[0071] 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 the real-time operating system provided by the above embodiment.
[0072] 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: 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; A correlation determination module 202, configured to determine the correlation between each data point in the crystal oscillator-related data; 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; 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; 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; A synchronization module 206, configured to perform time synchronization on the RTC clock according to the system time information at the synchronization interval.
[0073] In an alternative embodiment, 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.
[0074] In an alternative embodiment, 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 an intermediate 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: 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 on at least the first correlation, the second correlation, and the third correlation.
[0075] In an alternative embodiment, determining the correlation based on at least the first correlation, the second correlation, and the third correlation includes: Determining a high frequency weight, an intermediate frequency weight, and a low frequency weight based on the information of the electronic device; Multiplying the first correlation by the high frequency weight to obtain a fourth correlation; Multiplying the second correlation by the intermediate frequency weight to obtain a fifth correlation; Multiplying the third correlation by the low frequency weight to obtain a sixth correlation; Determining the correlation based on the fourth correlation, the fifth correlation, and the sixth correlation.
[0076] In an alternative embodiment, determining the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the crystal oscillator related data includes: Projecting the crystal oscillator related data into a target space based on the correlation to obtain target space data; Determining the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the target space data.
[0077] 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: Performing clustering processing on the target space data based on the correlation to obtain at least one clustering cluster; Determining the crystal oscillator key point data from the crystal oscillator related data based on the at least one clustering cluster.
[0078] 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: Determining a first error between the RTC time information and the system time information; 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; Determining the synchronization interval based at least on the third error.
[0079] In an alternative embodiment, 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: Performing a rough adjustment on the first error based on the temperature data and the crystal oscillator related data to obtain a second error; Performing a fine adjustment on the second error based on the crystal oscillator key point data and the temperature key point data to obtain the third error.
[0080] In an alternative embodiment, the apparatus further includes: An information acquisition module, configured to acquire the crystal oscillator aging information and the power supply voltage fluctuation information of the RTC clock; The determining the synchronization interval based at least on the third error includes: Correcting 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.
[0081] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. 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.
[0082] In a fourth aspect, an embodiment of the present application provides a computer program product, including computer instructions. 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.
[0083] 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.
[0084] 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 executable 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 each of the above embodiments of the RTC clock time synchronization method on the real-time operating system are implemented, such as Figure 1 the steps S101-S106 shown.
[0085] Exemplarily, the computer program may be divided into one or more modules / units. The one or more modules / units are stored in the memory 302 and executed by the processor 301 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used to describe the execution process of the computer program in the computer device.
[0086] 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, or combine certain components, or different components. For example, the computer device may further include input / output devices, network access devices, a bus, etc.
[0087] 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 lines.
[0088] The memory 302 can be used to store the computer programs and / or modules. The processor 301 realizes various functions of the computer device by running or executing the computer programs and / or modules stored in the memory 302, and by calling the data stored in the memory 302. The memory 302 may mainly include 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, memory, plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, at least one magnetic disk storage device, flash device, or other volatile solid-state storage devices.
[0089] 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 this understanding, to implement all or part of the processes in the above-described embodiment methods of this application, it can also be completed by instructing related 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-described 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, executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc.
[0090] In summary, the embodiments of this application have at least the following beneficial effects: By adopting the embodiments of this 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, it is possible 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.
[0091] Through the description of the above embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus a necessary hardware platform. Of course, it can also be implemented entirely through hardware. Based on such an understanding, all or part of the technical solution of this application that contributes to the background art can be embodied in the form of a software product. This 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, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0092] The above is the preferred embodiment of this application. It should be noted that for those of ordinary skill in the art of this technology, without departing from the principle of this application, several improvements and refinements can still be made, and these improvements and refinements are also regarded as the protection scope of this application.
Claims
1. A method for synchronizing RTC clock time 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 method is executed by the real-time operating system and includes: 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; 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; Determine temperature key point data corresponding to the crystal oscillator key point data in the temperature data; 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; According to the synchronization interval, the RTC clock is synchronized according to the system time information.
2. The method according to claim 1, characterized in that Determining the correlation between the 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; A correlation analysis is performed on the first crystal oscillator data point and the second crystal oscillator data point to obtain the correlation, wherein the second crystal oscillator data point is a data point in the crystal oscillator-related data except the first crystal oscillator data point.
3. The method according to claim 2, characterized in that 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 an intermediate frequency, and a fifth crystal oscillator data point corresponding to a low frequency, and the correlation analysis of 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; The correlation is determined based on at least the first correlation, the second correlation, and the third correlation.
4. The method according to claim 3, characterized in that The determining the correlation based at least on the first correlation, the second correlation, and the third correlation comprises: Determining a high frequency weight, a medium frequency weight, and a low frequency weight based on the information of the electronic device; multiplying the first correlation by the high frequency weight to obtain a fourth correlation; multiplying the second correlation by the intermediate frequency weight to obtain a fifth correlation; multiplying the third correlation by the low frequency weight to obtain a sixth correlation; The correlation is determined based on the fourth correlation, the fifth correlation, and the sixth correlation.
5. The method according to claim 1, characterized in that The step of determining the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the crystal oscillator related data includes: Based on the correlation, projecting the crystal oscillator related data into a target space to obtain target space data; Based on the correlation and the target space data, crystal oscillator key point data in the crystal oscillator related data is determined.
6. The method according to claim 5, characterized in that The step of determining the crystal oscillator key point data in the crystal oscillator related data based on the correlation and the target space data includes: Based on the correlation, clustering is performed on the target spatial data to obtain at least one cluster; Based on the at least one cluster, the crystal oscillator key point data is determined from the crystal oscillator related data.
7. The method according to claim 1, characterized in that The step of 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 comprises: 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, adjusting the first error to obtain a third error; Based at least on the third error, the synchronization interval is determined.
8. The method according to claim 7, characterized in that 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: Based on the temperature data and the crystal oscillator related data, the first error is roughly adjusted to obtain a second error; Based on the crystal oscillator key point data and the temperature key point data, the second error is fine-tuned to obtain the third error.
9. The method according to any one of claims 7-8, characterized in that: The method further comprises: Obtaining crystal oscillator aging information and power supply fluctuation information of the RTC clock; The step of determining the synchronization interval based at least on the third error comprises: Based on the crystal oscillator aging information and the power supply fluctuation information, the third error is corrected to obtain a fourth error; The synchronization interval is determined according to the fourth error.
10. An 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 device is applicable to the real-time operating system and includes: A data acquisition module, used to acquire the crystal oscillator-related data and RTC time information of the RTC clock, and to acquire the temperature data of the electronic device and the system time information of the real-time operating system; A correlation determination module, used to determine the correlation between each data point in the crystal oscillator related data; A crystal oscillator key point determination module, used 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, used 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 is used to synchronize the RTC clock according to the synchronization interval and the system time information.
Citation Information
Patent Citations
Local clock synchronization keeping method and device
CN112821976A
Clock synchronization method and device, electronic equipment and storage medium
CN113972893A
RTC equipment timing method and system
CN116719220A
Synchronous clock precision optimization method and device and electronic equipment
CN119847286A
Time synchronization method and device and storage medium
WO2023141817A1