A real-time clock calibration method, apparatus, device and medium
By obtaining the frequencies of the RC and quartz crystal oscillators in the RTC clock system, generating compensated bits for physical compensation and error calibration, the problem of low accuracy of the RC oscillator in the low power state of the RTC is solved, and accurate clock output and system stability are achieved.
Patent Information
- Application Number
- CN202211229462.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-08
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2042-10-08
AI Technical Summary
In existing technologies, when the RTC uses an RC oscillator clock as a reference source in a low-power state, the accuracy is not high, which leads to a decrease in the accuracy of the chip clock.
By acquiring the frequencies of the RC oscillator and the quartz crystal oscillator within a preset calibration time period, generating the number of compensation bits for the RC impedance control bit, performing physical compensation on the RC oscillator, obtaining the error compensation value, and adjusting the clock time of the RC oscillator, clock calibration is achieved.
It improves the stability and clock accuracy of the RTC clock system under low power consumption, ensuring accurate output of the RC oscillator clock.
Smart Images

Figure CN115480616B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of real-time clock calibration, and in particular to a real-time clock calibration method, apparatus, device, and medium. Background Technology
[0002] The Real-Time Clock (RTC) is the clock reference for a chip's operation; only an accurate clock can ensure the chip functions correctly and systematically. As portable devices increasingly demand low power consumption, the RTC, as the chip's internal clock system, also requires low power consumption. When the RTC operates at high performance, a quartz crystal oscillator is used throughout as the clock reference, achieving a clock accuracy of 2ppm, but this also results in relatively high power consumption. When the RTC operates at low power, the system uses a lower-power RC oscillator to generate the clock reference, achieving low-power operation.
[0003] Currently, when the RTC operates in a low-power state, it uses an RC oscillator clock as the reference source. However, the impedance of the resistors and capacitors inside the chip is easily affected by the process, voltage, and temperature, which makes the accuracy of the RC oscillator not high, thus reducing the clock accuracy of the chip under low power conditions.
[0004] In view of the above problems, designing a real-time clock calibration method to achieve accurate output of RC oscillator clock under low power consumption is an urgent problem to be solved by technicians in this field. Summary of the Invention
[0005] The purpose of this application is to provide a real-time clock calibration method, apparatus, device, and medium to achieve accurate output of an RC oscillator clock under low power consumption.
[0006] To address the aforementioned technical problems, this application provides a real-time clock calibration method applied to an RTC clock system; the method includes:
[0007] When the RTC clock system switches to low-power operation, the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock are obtained within a preset calibration time period.
[0008] The compensation bit number of the RC impedance control bit of the RC oscillator clock is generated according to the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock, so as to perform physical compensation of the RC oscillator clock according to the compensation bit number.
[0009] Obtain the error compensation value of the RC oscillator clock after physical compensation;
[0010] The timing of the RC oscillator clock is adjusted according to the error compensation value to achieve clock calibration of the RTC clock system.
[0011] Preferably, the compensation bit number for generating the RC impedance control bit of the RC oscillator clock based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock includes:
[0012] Obtain the sampling period;
[0013] The actual period count value of the quartz crystal oscillator clock within the sampling period is obtained based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock.
[0014] The theoretical period count value of the quartz crystal oscillator clock within the sampling period is obtained based on the sampling period, the frequency of the RC oscillator clock, and the frequency of the quartz crystal oscillator clock.
[0015] The error period count value is obtained based on the actual period count value and the theoretical period count value;
[0016] The compensation bit number of the RC impedance control bit is obtained according to the error cycle count value and the compensation bit number formula.
[0017] Preferably, the formula for the compensation bit depth is:
[0018] Te = 10A + B;
[0019] Where Te is the error cycle count value, A is the compensation bit number, and B is the calculation error value.
[0020] Preferably, the error compensation value of the RC oscillator clock after obtaining physical compensation includes:
[0021] Turn off the quartz crystal oscillator clock;
[0022] The single-cycle error compensation value is obtained based on the calculated error value, the sampling period, and the frequency of the quartz crystal oscillator clock.
[0023] The error compensation value is obtained based on the preset calibration time period, the single-cycle error compensation value, and the frequency of the RC oscillator clock.
[0024] Preferably, after adjusting the RC oscillator clock time according to the error compensation value, the method further includes:
[0025] Returning to the step of obtaining the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock within the preset calibration time period;
[0026] Specifically, the quartz crystal oscillator clock is restarted at a preset time before the end of the preset calibration time period.
[0027] Preferably, it further includes:
[0028] When an interrupt signal is received that switches the RTC clock system from low-power operation to high-performance operation, it is determined whether the RTC clock system is in the process of physically compensating the RC oscillator clock according to the compensation bit.
[0029] If so, then directly switch the running state;
[0030] If not, the operating state is switched according to the state of the quartz crystal oscillator clock.
[0031] Preferably, the step of switching the operating state according to the state of the quartz crystal oscillator clock includes:
[0032] Determine whether the quartz crystal oscillator clock is in the on state;
[0033] If so, the operating state will be switched after the preset calibration time period ends;
[0034] If not, wait for the quartz crystal oscillator clock to restart, and switch the operating state after the preset calibration time period ends.
[0035] To address the aforementioned technical problems, this application also provides a real-time clock calibration device for use in an RTC clock system; the device includes:
[0036] The first acquisition module is used to acquire the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock within a preset calibration time period when the RTC clock system switches to low power operation.
[0037] The generation module is used to generate the number of compensation bits for the RC impedance control bits of the RC oscillator clock according to the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock, so as to perform physical compensation on the RC oscillator clock according to the compensation bits.
[0038] The second acquisition module is used to acquire the error compensation value of the RC oscillator clock after physical compensation;
[0039] An adjustment module is used to adjust the time of the RC oscillator clock according to the error compensation value in order to achieve clock calibration of the RTC clock system.
[0040] To address the aforementioned technical problems, this application also provides a real-time clock calibration device, comprising:
[0041] Memory, used to store computer programs;
[0042] A processor is used to implement the steps of the real-time clock calibration method described above when executing the computer program.
[0043] To address the aforementioned technical problems, this application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the real-time clock calibration method described above.
[0044] The real-time clock calibration method provided in this application is applied to an RTC clock system. When the RTC clock system switches to low-power operation, the frequencies of the RC oscillator clock and the quartz crystal oscillator clock are acquired within a preset calibration time period. The compensation bits for the RC impedance control bits of the RC oscillator clock are generated based on these frequencies to facilitate physical compensation of the RC oscillator clock. The error compensation value of the physically compensated RC oscillator clock is obtained. The time of the RC oscillator clock is adjusted based on the error compensation value to achieve clock calibration of the RTC clock system. Therefore, when the RTC clock system switches to low-power operation, the above scheme generates the compensation bits for the RC impedance control bits of the RC oscillator clock using the frequencies of the two clocks in the system. By adjusting the RC impedance control bits through the compensation bits, physical compensation of the RC oscillator clock is achieved. Simultaneously, the error compensation value of the physically compensated RC oscillator clock is obtained, and the remaining error of the RC oscillator clock is calibrated. Ultimately, accurate output of the RC oscillator clock under low-power conditions is achieved, improving the stability of the RTC clock system.
[0045] In addition, this application also provides a real-time clock calibration device, equipment, and medium, with the same effect as above. Attached Figure Description
[0046] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0047] Figure 1 A flowchart illustrating a real-time clock calibration method provided in this application embodiment;
[0048] Figure 2 A schematic diagram of a real-time clock calibration device provided in an embodiment of this application;
[0049] Figure 3 This is a schematic diagram of a real-time clock calibration device provided in an embodiment of this application. Detailed Implementation
[0050] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0051] The core of this application is to provide a real-time clock calibration method, apparatus, device, and medium.
[0052] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0053] Figure 1 A flowchart illustrating a real-time clock calibration method provided in this application embodiment. The method is applied to an RTC clock system; as... Figure 1 As shown, the method includes:
[0054] S10: When the RTC clock system switches to low power operation, the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock are obtained within the preset calibration time period.
[0055] Understandably, an RTC clock system includes both a quartz crystal oscillator clock and an RC oscillator clock. When the system is in high-performance mode, it directly uses the quartz crystal oscillator clock as the clock reference; when the system switches to low-power mode, it uses the RC oscillator clock as the clock reference, and the quartz crystal oscillator clock is turned off. However, because the impedance of the resistors and capacitors in the RC oscillator clock is easily affected by process technology, voltage, and temperature (PVT), the accuracy of the RC oscillator is not high. Therefore, clock calibration of the RC oscillator clock is necessary during low-power operation.
[0056] Specifically, when the RTC clock system switches to low-power operation, the frequencies of the RC oscillator clock and the quartz crystal oscillator clock are acquired within a preset calibration time period. The preset calibration time period is the period for clock calibration of the RC oscillator clock. For example, if the preset calibration time period is 10 seconds, the RC oscillator clock is calibrated every 10 seconds. In this embodiment, the preset calibration time period is not limited and depends on the specific implementation.
[0057] S11: Generate the number of compensation bits for the RC impedance control bits of the RC oscillator clock based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock, so as to perform physical compensation for the RC oscillator clock according to the compensation bits.
[0058] Furthermore, since the RC oscillator clock frequency and the quartz crystal oscillator clock frequency are different in the RTC clock system, clock calibration of the RC oscillator clock can be performed by sampling the RC oscillator clock using a quartz crystal oscillator with a stable clock signal. The sampling accuracy calculation formula is as follows:
[0059]
[0060] Among them, F RC F is the frequency of the RC oscillator clock. OSC is the frequency of the quartz crystal oscillator clock, and N is the sampling period.
[0061] By sampling the RC oscillator clock, the frequency error between the RC oscillator clock and the quartz crystal oscillator clock can be determined. Based on this frequency error, the number of compensation bits for the RC impedance control bits of the RC oscillator clock can be obtained. It is understood that the RC impedance control bits are used to control the impedance change of the RC oscillator clock. Adjusting the RC impedance control bits by the compensation bits can achieve physical-level compensation calibration of the RC oscillator clock. In this embodiment, the specific process for generating the compensation bits for the RC impedance control bits of the RC oscillator clock is not limited and depends on the specific implementation.
[0062] S12: Obtain the error compensation value of the RC oscillator clock after physical compensation.
[0063] S13: Adjust the RC oscillator clock time according to the error compensation value to achieve clock calibration of the RTC clock system.
[0064] In practical implementation, since the RC oscillator clock still has a certain error after physical compensation, it is necessary to further obtain the error compensation value of the RC oscillator clock. The error compensation value enables data-level compensation and calibration of the RC oscillator clock, facilitating data compensation after physical compensation, ultimately achieving clock calibration of the RC oscillator clock. This embodiment does not limit the specific process of obtaining the error compensation value of the RC oscillator clock after physical compensation; it depends on the specific implementation situation.
[0065] In this embodiment, when the RTC clock system switches to low-power operation, the frequencies of the RC oscillator clock and the quartz crystal oscillator clock are acquired within a preset calibration time period. The compensation bit number of the RC impedance control bit of the RC oscillator clock is generated based on the frequencies of the RC oscillator clock and the quartz crystal oscillator clock, so as to perform physical compensation of the RC oscillator clock according to the compensation bit number. The error compensation value of the RC oscillator clock after physical compensation is obtained. The time of the RC oscillator clock is adjusted according to the error compensation value to achieve clock calibration of the RTC clock system. Therefore, the above scheme, when the RTC clock system switches to low-power operation, generates the compensation bit number of the RC impedance control bit of the RC oscillator clock through the frequencies of the two clocks in the system, and adjusts the RC impedance control bit by the compensation bit, thus achieving physical compensation of the RC oscillator clock. Simultaneously, the error compensation value of the RC oscillator clock after physical compensation is further obtained, and the remaining error of the RC oscillator clock is calibrated, ultimately achieving accurate output of the RC oscillator clock under low power conditions and improving the stability of the RTC clock system.
[0066] Based on the above embodiments:
[0067] As a preferred embodiment, the number of compensated bits for the RC impedance control bits of the RC oscillator clock, generated based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock, includes:
[0068] Obtain the sampling period;
[0069] The actual period count value of the quartz crystal oscillator clock within the sampling period is obtained based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock.
[0070] The theoretical period count value of the quartz crystal oscillator clock within the sampling period is obtained based on the sampling period, the frequency of the RC oscillator clock, and the frequency of the quartz crystal oscillator clock.
[0071] The error period count value is obtained based on the actual period count value and the theoretical period count value;
[0072] The number of compensation bits for the RC impedance control bits is obtained based on the error cycle count value and the compensation bit formula.
[0073] Taking a quartz crystal oscillator clock frequency of 24MHz and an RC oscillator clock frequency of 256kHz as an example, when the RTC clock system switches to low-power operation, clock calibration of the RC oscillator clock is performed. The frequency signal of the RC oscillator clock is sampled and detected using the frequency signal of the quartz crystal oscillator; that is, a 24MHz signal is used to detect a 256kHz signal. Theoretically, after 93.75 cycles of the 24MHz signal, the 256kHz signal will have completed one cycle, resulting in an error of one 24MHz signal cycle. Therefore, it can be understood that the longer the measurement period, the smaller the error. Thus, to obtain the number of compensation bits for the RC impedance control, a suitable sampling period must first be selected.
[0074] Specifically, as can be seen from the above embodiments, since sampling accuracy is related to the sampling period, a corresponding sampling period can be determined in specific implementations based on the requirements for sampling accuracy. For example, if the design requires a calibration accuracy of no more than 200 ppm, then a sampling period of 100 can be selected, at which point PPM = 106.66 ppm. Further, the theoretical period count value T2 of the quartz crystal oscillator clock within the sampling period is obtained based on the sampling period, the frequency of the RC oscillator clock, and the frequency of the quartz crystal oscillator clock.
[0075]
[0076] Further, based on the frequencies of the RC oscillator clock and the quartz crystal oscillator clock, the actual period count value T1 of the quartz crystal oscillator clock within the sampling period is obtained. After obtaining the actual period count value and the theoretical period count value, the error period count value Te is obtained based on the actual period count value and the theoretical period count value.
[0077] Te = T1 - T2
[0078] It is understandable that when Te is negative, it indicates that the period is smaller and the frequency of the RC oscillator clock is too high; when Te is positive, it indicates that the period is larger and the frequency of the RC oscillator clock is too low. The compensation bit number of the RC impedance control bit is further obtained based on the obtained error period count value and the compensation bit number formula. In this embodiment, the compensation bit number formula is not limited and depends on the specific implementation.
[0079] It should be noted that this embodiment does not impose a limit on the sampling period, which depends on the specific implementation.
[0080] In this embodiment, the sampling period is obtained; the actual period count value of the quartz crystal oscillator clock within the sampling period is obtained based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock; the theoretical period count value of the quartz crystal oscillator clock within the sampling period is obtained based on the sampling period, the frequency of the RC oscillator clock, and the frequency of the quartz crystal oscillator clock; the error period count value is obtained based on the actual period count value and the theoretical period count value; and the compensation bit number of the RC impedance control bit is obtained based on the error period count value and the compensation bit number formula. This achieves the acquisition of the compensation bit number, which facilitates physical compensation of the RC oscillator clock.
[0081] Based on the above embodiments:
[0082] As a preferred embodiment, the formula for the compensated bit depth is:
[0083] Te = 10A + B;
[0084] Where Te is the error cycle count value, A is the compensation bit value, and B is the calculation error value.
[0085] In the above embodiment, the error cycle count value was obtained. Combined with the compensation bit formula in this embodiment, the compensation bit number for the RC impedance control bit can be obtained.
[0086] It should be noted that in the compensation bit formula of this embodiment, A and B are both integers, with B being an integer less than 10. The RC impedance control bit is adjusted according to the compensation bit number, with the RC impedance control bit increasing or decreasing by bit A based on the sign of Te. During the physical compensation process, a waiting time can be set after physical compensation is completed. By setting the waiting time, the RC oscillator clock output signal is stabilized, and the process returns to the steps described above for obtaining the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock within the preset calibration time period, to perform physical compensation again until A is 0. In this embodiment, the waiting time is not limited and depends on the specific implementation.
[0087] It should be noted that in this embodiment, there is no restriction on the correspondence between the sign of the error cycle count value Te and the rise or fall of the RC impedance control bit. It can be set to adjust the RC impedance control bit to rise by A bits when the error cycle count value Te is positive, and to adjust the RC impedance control bit to fall by A bits when the error cycle count value Te is negative; it can also be set to adjust the RC impedance control bit to fall by A bits when the error cycle count value Te is positive, and to adjust the RC impedance control bit to rise by A bits when the error cycle count value Te is negative, depending on the specific implementation.
[0088] Based on the above embodiments:
[0089] As a preferred embodiment, obtaining the error compensation value of the RC oscillator clock after physical compensation includes:
[0090] Turn off the quartz crystal oscillator clock;
[0091] The single-cycle error compensation value is obtained based on the calculated error value, sampling period, and the frequency of the quartz crystal oscillator clock.
[0092] The error compensation value is obtained based on the preset calibration time period, the single-cycle error compensation value, and the frequency of the RC oscillator clock.
[0093] In the above embodiment, the RC impedance control bit is adjusted according to the number of compensation bits. When A is 0, the physical compensation process ends, and the data calibration process begins. At this time, the crystal oscillator is turned off, the timing clock of the RTC clock system is switched to the RC oscillator clock signal, the RC oscillator clock signal is counted, and the single-cycle error compensation value is obtained based on the calculated error value, sampling period, and the frequency of the quartz crystal oscillator clock.
[0094] Tet=B / (F OSC *N 采样周期 )
[0095] Further, the error compensation value is obtained based on the preset calibration time period, the single-cycle error compensation value, and the frequency of the RC oscillator clock:
[0096] Tea = Tc * Tet * F RC
[0097] Where Tea is the error compensation value within the preset calibration time period Tc; if the error period count value Te is positive, then the RTC clock system time is subtracted from Tea. If the error period count value Te is negative, then the RTC clock system time is added to Tea.
[0098] In this embodiment, the error compensation value is obtained by turning off the quartz crystal oscillator clock; obtaining the single-cycle error compensation value based on the calculated error value, sampling period, and frequency of the quartz crystal oscillator clock; and obtaining the error compensation value based on the preset calibration time period, single-cycle error compensation value, and frequency of the RC oscillator clock. This allows the error compensation value to be obtained so that the time of the RTC clock system can be adjusted according to the error compensation value.
[0099] Furthermore, as a preferred embodiment, after adjusting the RC oscillator clock time according to the error compensation value, the method further includes:
[0100] Return to the step of obtaining the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock within the preset calibration time period;
[0101] The quartz crystal oscillator clock is restarted at a preset time before the end of the preset calibration period.
[0102] Understandably, after adjusting the RC oscillator clock time according to the error compensation value, the clock calibration within this preset calibration period is completed. In order to continuously calibrate the RC oscillator clock, after completing the clock calibration within this preset calibration period, the process returns to the step of obtaining the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock within the preset calibration time period, in order to perform clock calibration for the next preset calibration time period.
[0103] It is important to note that in practice, the quartz crystal oscillator clock needs to be restarted at a preset time before the end of the preset calibration time period to facilitate clock calibration for the next preset calibration time period. Taking the above embodiment with a preset calibration time period of 10 seconds, an RC oscillator clock frequency of 256 kHz, a quartz crystal oscillator clock frequency of 24 MHz, and a sampling period N of 100 as an example, when calibrating the RC oscillator clock, the RC oscillator clock signal is counted, and error compensation is performed sequentially after each sampling period N. The error for each compensation is: Tea = B / 24 * 10. 6 .
[0104] Furthermore, as can be seen from the above embodiments, the number of compensations within the entire preset calibration time period is Tc*F. RC =10*256*10 3 =256000. If the preset time is set to 1ms, the crystal oscillator will be restarted when the preset calibration time period reaches 9999ms, at which point the data compensation count will be 2,569,744 times; after the crystal oscillator restart ends, compensation will continue for 256 times (1ms), and the preset calibration time period will end.
[0105] Furthermore, to ensure system stability and clock accuracy when the RTC clock system switches from low-power operation to high-performance operation, as a preferred embodiment, it also includes:
[0106] When an interrupt signal is received that switches the RTC clock system from low-power operation to high-performance operation, it is determined whether the RTC clock system is in the process of physically compensating the RC oscillator clock according to the compensation bit.
[0107] If so, then directly switch the running state;
[0108] If not, the operating state will be switched according to the state of the quartz crystal oscillator clock.
[0109] In practical implementation, when an interrupt signal is received that switches the RTC clock system from low-power operation to high-performance operation, the system first determines whether the RTC clock system is in the process of physically compensating the RC oscillator clock according to the compensation bit. This can be determined by a preset variable. That is, the preset variable is set to 1 when the system is in physical compensation and set to 0 when the system is in data calibration, thereby confirming the current calibration process of the system based on the preset variable.
[0110] Furthermore, when the system is confirmed to be in physical compensation mode, the RTC clock system uses the quartz crystal oscillator clock as the clock reference, and the physical calibration state can be directly interrupted. When the system is confirmed to be in data calibration mode, the operating state needs to be switched according to the state of the quartz crystal oscillator clock.
[0111] As a preferred embodiment, switching the operating state based on the state of the quartz crystal oscillator clock specifically includes:
[0112] Determine whether the quartz crystal oscillator clock is on;
[0113] If so, the running status will be switched after the preset calibration time period ends;
[0114] If not, wait for the quartz crystal oscillator clock to restart, and switch the operating state after the preset calibration time period ends.
[0115] Specifically, as described in the above embodiments, during the data calibration process within the preset calibration time period, there is a preset time to restart the quartz crystal oscillator. If the quartz crystal oscillator clock is on, it indicates that the quartz crystal oscillator has already restarted. After the current preset calibration time period ends, the RTC clock system switches to the quartz crystal oscillator clock, interrupting the system's low-power state and allowing the system to enter a high-performance state. Conversely, if the quartz crystal oscillator clock is off, it indicates that the quartz crystal oscillator has not yet restarted. It is waiting for the quartz crystal oscillator clock to restart, and after the preset calibration time period ends, the operating state switches, the RTC clock system switches to the quartz crystal oscillator clock, interrupting the system's low-power state and allowing the system to enter a high-performance state.
[0116] It is important to note that data calibration continues during the preset calibration time period before the system switches operating states. In this implementation, the switching of the RTC clock system from low-power operation to high-performance operation is achieved by controlling the on / off state of the quartz crystal oscillator clock.
[0117] In the above embodiments, the real-time clock calibration method has been described in detail. This application also provides embodiments corresponding to the real-time clock calibration device. It should be noted that this application describes the embodiments of the device from two perspectives: one is based on the functional modules, and the other is based on the hardware structure.
[0118] Figure 2 A schematic diagram of a real-time clock calibration device provided in an embodiment of this application. It is applied to an RTC clock system; such as... Figure 2 As shown, the device includes:
[0119] The first acquisition module 10 is used to acquire the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock within a preset calibration time period when the RTC clock system switches to low power operation.
[0120] The generation module 11 is used to generate the number of compensation bits for the RC impedance control bits of the RC oscillator clock according to the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock, so as to perform physical compensation on the RC oscillator clock according to the number of compensation bits.
[0121] The second acquisition module 12 is used to acquire the error compensation value of the RC oscillator clock after physical compensation;
[0122] The adjustment module 13 is used to adjust the time of the RC oscillator clock according to the error compensation value in order to achieve clock calibration of the RTC clock system.
[0123] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.
[0124] Figure 3 This is a schematic diagram of a real-time clock calibration device provided in an embodiment of this application. Figure 3 As shown, the real-time clock calibration device includes:
[0125] Memory 20 is used to store computer programs.
[0126] The processor 21 is used to implement the steps of the real-time clock calibration method mentioned in the above embodiments when executing a computer program.
[0127] The real-time clock calibration device provided in this embodiment may include, but is not limited to, smartphones, tablets, laptops, or desktop computers.
[0128] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an Artificial Intelligence (AI) processor, which handles computational operations related to machine learning.
[0129] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 20 is used to store at least the following computer program 201, which, after being loaded and executed by the processor 21, is capable of implementing the relevant steps of the real-time clock calibration method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, and the storage method may be temporary or permanent storage. The operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, the data involved in the real-time clock calibration method.
[0130] In some embodiments, the real-time clock calibration device may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.
[0131] Those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the real-time clock calibration device and may include more or fewer components than illustrated.
[0132] Finally, this application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps described in the above method embodiments.
[0133] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0134] The foregoing provides a detailed description of a real-time clock calibration method, apparatus, device, and medium provided in this application. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
[0135] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A real-time clock calibration method, characterized in that, Applied to RTC clock systems; the method includes: When the RTC clock system switches to low-power operation, the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock are obtained within a preset calibration time period. The compensation bit number of the RC impedance control bit of the RC oscillator clock is generated according to the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock, so as to perform physical compensation on the RC oscillator clock according to the compensation bit number; wherein, the RC impedance control bit is used to control the impedance change of the RC oscillator clock, and the compensation bit number is used to adjust the RC impedance control bit to achieve physical compensation and calibration of the RC oscillator clock. Obtain the error compensation value of the RC oscillator clock after physical compensation; The timing of the RC oscillator clock is adjusted according to the error compensation value to achieve clock calibration of the RTC clock system; The compensation bit number for generating the RC impedance control bit of the RC oscillator clock based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock includes: By sampling the RC oscillator clock, the frequency error between the RC oscillator clock and the quartz crystal oscillator clock is determined, and the number of compensation bits for the RC impedance control bits of the RC oscillator clock is obtained based on the frequency error.
2. The real-time clock calibration method according to claim 1, characterized in that, The compensation bit number for generating the RC impedance control bit of the RC oscillator clock based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock includes: Obtain the sampling period; The actual period count value of the quartz crystal oscillator clock within the sampling period is obtained based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock. The theoretical period count value of the quartz crystal oscillator clock within the sampling period is obtained based on the sampling period, the frequency of the RC oscillator clock, and the frequency of the quartz crystal oscillator clock. The error period count value is obtained based on the actual period count value and the theoretical period count value; The compensation bit number of the RC impedance control bit is obtained according to the error cycle count value and the compensation bit number formula.
3. The real-time clock calibration method according to claim 2, characterized in that, The formula for the compensation bit depth is: Te = 10A + B; Where Te is the error cycle count value, A is the compensation bit number, and B is the calculation error value.
4. The real-time clock calibration method according to claim 3, characterized in that, The error compensation value of the RC oscillator clock after obtaining physical compensation includes: Turn off the quartz crystal oscillator clock; The single-cycle error compensation value is obtained based on the calculated error value, the sampling period, and the frequency of the quartz crystal oscillator clock. The error compensation value is obtained based on the preset calibration time period, the single-cycle error compensation value, and the frequency of the RC oscillator clock.
5. The real-time clock calibration method according to claim 4, characterized in that, After adjusting the RC oscillator clock time according to the error compensation value, the method further includes: Returning to the step of obtaining the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock within the preset calibration time period; Specifically, the quartz crystal oscillator clock is restarted at a preset time before the end of the preset calibration time period.
6. The real-time clock calibration method according to claim 4 or 5, characterized in that, Also includes: When an interrupt signal is received that switches the RTC clock system from low-power operation to high-performance operation, it is determined whether the RTC clock system is in the process of physically compensating the RC oscillator clock according to the compensation bit. If so, then directly switch the running state; If not, the operating state is switched according to the state of the quartz crystal oscillator clock.
7. The real-time clock calibration method according to claim 6, characterized in that, The step of switching the operating state based on the state of the quartz crystal oscillator clock includes: Determine whether the quartz crystal oscillator clock is in the on state; If so, the operating state will be switched after the preset calibration time period ends; If not, wait for the quartz crystal oscillator clock to restart, and switch the operating state after the preset calibration time period ends.
8. A real-time clock calibration device, characterized in that, Applied to RTC clock systems; the device includes: The first acquisition module is used to acquire the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock within a preset calibration time period when the RTC clock system switches to low power operation. The generation module is used to generate a number of compensation bits for the RC impedance control bit of the RC oscillator clock based on the frequency of the RC oscillator clock and the frequency of the quartz crystal oscillator clock, so as to perform physical compensation on the RC oscillator clock according to the number of compensation bits; wherein, the RC impedance control bit is used to control the impedance change of the RC oscillator clock, and the compensation bit is used to adjust the RC impedance control bit to achieve physical compensation and calibration of the RC oscillator clock. The second acquisition module is used to acquire the error compensation value of the RC oscillator clock after physical compensation; An adjustment module is used to adjust the time of the RC oscillator clock according to the error compensation value in order to achieve clock calibration of the RTC clock system; Specifically, the generation module is used to determine the frequency error between the RC oscillator clock and the quartz crystal oscillator clock by sampling the RC oscillator clock, and to obtain the number of compensation bits for the RC impedance control bits of the RC oscillator clock based on the frequency error.
9. A real-time clock calibration device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the real-time clock calibration method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the real-time clock calibration method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Oscillator Correcting Circuit And Method And Integrated Circuit
CN103973266A
Process and temperature fluctuation resistant ultra-low power consumption timing circuit and timing method
CN108880509A