On-chip crystal oscillator calibration circuit and calibration method

By using a successive approximation algorithm in the on-chip crystal oscillator calibration circuit, comparing the clock to be calibrated and the reference clock, generating a step-length control signal, and adjusting the crystal oscillator frequency, the problem of long calibration time in the prior art is solved, and efficient and accurate on-chip crystal oscillator calibration is achieved.

CN113489486BActive Publication Date: 2025-07-01QINGXIN SEMICON TECH (SHANGHAI) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110586248.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-27
Publication Date
2025-07-01
Estimated Expiration
2041-05-27

AI Technical Summary

Technical Problem

The existing on-chip crystal oscillator calibration method has a long calibration time, and the frequency and accuracy of the IO port output are limited by the IO port.

Method used

A on-chip crystal oscillator calibration circuit based on successive approximation algorithm is designed, including a clock comparison module, a state control module and a step size control module. By comparing the results of the clock to be calibrated and the reference clock, the successive approximation algorithm generates a step size control signal, adjusts the clock frequency of the crystal oscillator to be calibrated, and achieves accurate calibration.

Benefits of technology

This method significantly shortens calibration time, improves calibration efficiency and accuracy, and avoids calibration failures caused by clock deviation in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113489486B_ABST
    Figure CN113489486B_ABST
Patent Text Reader

Abstract

The present invention provides an on-chip crystal oscillator calibration circuit and a calibration method, including: a clock comparison module configured to compare a clock to be calibrated and a reference clock to obtain a comparison result and provide the comparison result to a state control module; a state control module configured to generate a step control signal through a successive approximation algorithm according to the comparison result to provide the step control signal to a step control module; and a step control module configured to generate a calibration signal according to the step control signal to provide the calibration signal to a crystal oscillator to be calibrated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of integrated circuit technology, and particularly to an on-chip crystal oscillator calibration circuit and a calibration method based on a successive approximation algorithm. Background Art

[0002] For a chip actually manufactured and containing an on-chip crystal oscillator, due to process deviations, there are various deviations between the clock signal frequency generated by the crystal oscillator circuit in the chip and the expected clock frequency in design. For a chip that requires a precise clock, the internal crystal oscillator circuit needs to be calibrated.

[0003] The actual on-chip crystal oscillator circuit can adjust the capacitance of the on-chip circuit through a series of switches, change the clock frequency by changing the capacitance, and thus achieve the purpose of calibrating the clock frequency. These switches can be controlled by registers.

[0004] As Figure 1 shown, a common test method is that the central control console sends test instructions through the control interface, outputs the clock signal (output clock) of the on-chip crystal oscillator of the chip to be tested to the central control console. The central control console uses a reference precise clock signal to compare with the output crystal oscillator signal, and calibrates by gradually controlling and adjusting the on-chip crystal oscillator. This calibration method has a long calibration time, and the frequency and accuracy output by the IO port are limited by the IO port.

[0005] For example, Chinese Patent CN103116124B provides a chip calibration method. This method needs to find the optimal solution during the clock comparison process, and does not provide a solution for the valid values that meet within a certain range. Moreover, the step size is fixed during the calibration process, which is not conducive to improving the calibration efficiency and accuracy. Summary of the Invention

[0006] The purpose of the present invention is to provide an on-chip crystal oscillator calibration circuit and a calibration method to solve the problem of long calibration time of the existing on-chip crystal oscillator calibration method.

[0007] To solve the above technical problems, the present invention provides an on-chip crystal oscillator calibration circuit, including:

[0008] A clock comparison module configured to compare the clock to be calibrated and a reference clock to obtain a comparison result and provide the comparison result to the state control module;

[0009] A state control module configured to generate a step size control signal through a successive approximation algorithm according to the comparison result to provide the step size control signal to the step size control module; and

[0010] A step size control module configured to generate a calibration signal according to the step size control signal to provide the calibration signal to the crystal oscillator to be calibrated.

[0011] Optionally, in the on-chip crystal oscillator calibration circuit, the crystal oscillator to be calibrated provides a clock to be calibrated to the clock comparison module;

[0012] The step control module generates calibration signals with different step sizes according to the step control signal; and

[0013] The step control module provides calibration signals with different step sizes to the crystal oscillator to be calibrated to adjust the clock frequency of the crystal oscillator to be calibrated.

[0014] Optionally, in the on-chip crystal oscillator calibration circuit, it further includes a central control station, which is configured to perform the following actions:

[0015] Provide a reference clock to the clock comparison module through the IO interface, and

[0016] Provide a target calibration value and read the calibration result to the clock comparison module through the control interface.

[0017] Optionally, in the on-chip crystal oscillator calibration circuit, the on-chip crystal oscillator calibration circuit and the crystal oscillator to be calibrated are integrated in the chip under test;

[0018] The central control station is located outside the chip under test.

[0019] Optionally, in the on-chip crystal oscillator calibration circuit, the clock comparison module includes:

[0020] A reference counter, configured to be driven by the reference clock to count;

[0021] A counter to be calibrated, configured to be driven by the clock to be calibrated to count; and

[0022] A comparator, configured to compare the count value of the reference counter and the count value of the counter to be calibrated to obtain a comparison result.

[0023] Optionally, in the on-chip crystal oscillator calibration circuit, the state control module includes:

[0024] A control module, configured to convert the count value of the reference counter corresponding to the target calibration value according to the comparison value of the reference clock and the target calibration value, for the clock comparison module to compare the count value with the count value of the counter to be calibrated; and

[0025] A successive approximation algorithm implementation module, configured to generate a step control signal by detecting the result of comparing the count value with the count value of the counter to be calibrated by the clock comparison module;

[0026] The step control module adjusts the crystal oscillator to be calibrated according to the step control signal to gradually reduce the error between the clock to be calibrated and the target clock frequency and approach the target clock frequency.

[0027] Optionally, in the on-chip crystal oscillator calibration circuit, the successive approximation algorithm implementation module controls the states of each calibration and implements the state transition of the successive approximation algorithm. The implementation steps of the successive approximation algorithm are as follows:

[0028] Before the calibration starts, store the initial value to be calibrated in the control register of the crystal oscillator to be calibrated;

[0029] After the clock comparison module receives the calibration start instruction, start the first clock comparison;

[0030] If the count value corresponding to the initial value to be calibrated is greater than the count value of the reference counter corresponding to the target calibration value, the comparison result is that the clock to be calibrated is faster than the target calibration value. Then, the successive approximation algorithm implementation module generates the first step size N. The step size control module slows down the crystal oscillator to be calibrated by the first step size N based on the initial value to be calibrated; and

[0031] If the count value corresponding to the initial value to be calibrated is less than the count value of the reference counter corresponding to the target calibration value, the comparison result is that the clock to be calibrated is slower than the target calibration value. Then, the successive approximation algorithm implementation module generates the first step size N. The step size control module speeds up the crystal oscillator to be calibrated by the first step size N based on the initial value to be calibrated.

[0032] Optionally, in the on-chip crystal oscillator calibration circuit, the successive approximation algorithm further includes:

[0033] After adjusting the initial value to be calibrated by the first step size according to the comparison result of the first clock comparison, the clock comparison module performs multiple clock comparisons;

[0034] If the successive approximation algorithm implementation module determines that the comparison result of a certain time is the same as the comparison result of the previous time, continue to adjust in the same direction further. Otherwise, reduce the step size and then adjust in the opposite direction.

[0035] Optionally, in the on-chip crystal oscillator calibration circuit, the successive approximation algorithm further includes:

[0036] The reduction of the step size includes: halving according to the step size of the previous adjustment.

[0037] Optionally, in the on-chip crystal oscillator calibration circuit, the successive approximation algorithm further includes:

[0038] If the count value corresponding to the initial value to be calibrated is equal to the count value of the reference counter corresponding to the target calibration value, or the difference between the two falls within the error range, or the comparison results of two consecutive times are different from the comparison result of the previous time, calculate the average value after adding the initial values to be calibrated corresponding to the last two adjustments as the configuration value of the control register of the final crystal oscillator to be calibrated; and

[0039] During the execution of the successive approximation algorithm, if the value of the control register for the crystal oscillator to be calibrated overflows, the calibration is completed with a failure flag.

[0040] Optionally, in the on-chip crystal oscillator calibration circuit, the successive approximation algorithm further includes:

[0041] After adjusting the initial value to be calibrated by the first step size N according to the comparison result of the first clock comparison, the clock comparison module performs the i-th clock comparison, where i is a positive integer greater than 1;

[0042] If the successive approximation algorithm implementation module determines that the comparison result of the i-th time is the same as the comparison result of the (i - 1)-th time, the step size control module is controlled to generate the first step size N, so that the step size control module continues to adjust the initial value to be calibrated with the first step size N and in the same adjustment direction as the (i - 1)-th time until the comparison result of the j-th time is different from the comparison result of the (j - 1)-th time, where j is a positive integer not less than i;

[0043] If the successive approximation algorithm implementation module determines that the comparison result of the j-th time is different from the comparison result of the (j - 1)-th time, the step size control module is controlled to generate the second step size N / 2, so that the step size control module continues to adjust the initial value to be calibrated with the second step size N / 2 and in the opposite adjustment direction to the (j - 1)-th time until the comparison result of the k-th time is different from the comparison result of the (k - 1)-th time, where k is a positive integer not less than j;

[0044] If the successive approximation algorithm implementation module determines that the comparison result of the k-th time is different from the comparison result of the (k - 1)-th time, the step size control module is controlled to generate the third step size N / 4, so that the step size control module continues to adjust the initial value to be calibrated with the third step size N / 4 and in the opposite adjustment direction to the (k - 1)-th time until the comparison result of the m-th time is different from the comparison result of the (m - 1)-th time, and the initial value to be calibrated stored in the control register of the crystal oscillator to be calibrated at this time is saved as a, where m is a positive integer not less than k; and

[0045] If the successive approximation algorithm implementation module determines that the comparison result of the m-th time is different from the comparison result of the (m - 1)-th time, the step size control module is controlled to generate the fourth step size N / 8, so that the step size control module continues to adjust the initial value to be calibrated with the fourth step size N / 8 and in the opposite adjustment direction to the (m - 1)-th time until the comparison result of the h-th time is different from the comparison result of the (h - 1)-th time, and the initial value to be calibrated stored in the control register of the crystal oscillator to be calibrated at this time is saved as b, where h is a positive integer not less than m.

[0046] The configured value of the control register of the finally calibrated crystal oscillator is the integer value obtained by taking the integer part of (a + b) / 2.

[0047] The present invention also provides an on-chip crystal oscillator calibration method, including:

[0048] Enable the clock comparison module to compare the clock to be calibrated and the reference clock to obtain a comparison result and provide the comparison result to the state control module;

[0049] Enable the state control module to generate a step control signal through the successive approximation algorithm according to the comparison result to provide the step control signal to the step control module; and

[0050] Enable the step control module to generate a calibration signal according to the step control signal to provide the calibration signal to the crystal oscillator to be calibrated.

[0051] In the on-chip crystal oscillator calibration circuit and calibration method provided by the present invention, a comparison result is obtained by comparing the clock to be calibrated and the reference clock, and a step control signal is generated through the successive approximation algorithm, and a calibration signal is generated according to the step control signal to provide the calibration signal to the crystal oscillator to be calibrated, realizing calibration with different step sizes and higher calibration efficiency.

[0052] The present invention adopts the successive approximation algorithm, and the working principle of this algorithm is as follows: there is a certain relationship between the reference clock and the clock after expected calibration (target calibration value), so that when the reference clock count reaches a certain value, the target calibration value of the clock to be calibrated can be calculated, and this target calibration value can be given from the external control interface, so as to adapt to the adjustment of various processes. The count value of the clock to be calibrated is compared with the target calibration value to generate comparison results of greater than and less than.

[0053] The present invention can realize the automatic calibration of the on-chip crystal oscillator. After successive approximation, valid values that meet the requirements within a certain range can be found. By calculating the average value of the initial calibration values a and b stored in the control register of the crystal oscillator to be calibrated as the configuration value of the control register of the finally calibrated crystal oscillator, the present invention avoids the situation in the traditional method where calibration cannot be completed due to clock deviation and the count value and the target calibration value may never be equal during the clock comparison process.

[0054] The present invention can trade off increasing or decreasing the number of approximation times according to the requirements of accuracy and speed. For example, when the accuracy requirement is high or the speed requirement is not high, the minimum step size can be adjusted to the fifth step size N / 16. On the contrary, when the accuracy requirement is not high or the speed requirement is high, the minimum step size can be adjusted to the third step size N / 4. The final configuration value is obtained by taking the average value of the initial calibration values corresponding to the final 2 to 3 step sizes. Those skilled in the art can adjust according to the process requirements. The above solutions are all within the protection scope of the present invention. Through the above flexible optional solutions, the present invention has strong adaptability to various process deviations.

[0055] The clock comparison module of the present invention can achieve calibration only through a small number of comparators, and only some adders and subtractors are required in the step control module. In the state control module, the state machine jump can be maintained only through the clock comparison result. The implementation of the on-chip crystal oscillator calibration is relatively simple. Moreover, in the successive approximation adjustment, even if the clock is accidentally disturbed and the comparison result is incorrect in a certain step, it can be corrected in the next step, thus having a certain fault tolerance ability. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 is a schematic diagram of an existing on-chip crystal oscillator calibration circuit;

[0057] Figure 2 is a schematic diagram of an on-chip crystal oscillator calibration circuit according to an embodiment of the present invention;

[0058] Figure 3 is a schematic diagram of an on-chip crystal oscillator calibration method according to another embodiment of the present invention;

[0059] As shown in the figure: 10 - clock comparison module; 20 - step control module; 30 - state control module; 40 - crystal oscillator to be calibrated; 100 - chip to be tested; 200 - central control console. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0060] The present invention will be further described below with reference to the accompanying drawings in conjunction with specific embodiments.

[0061] It should be noted that the components in the drawings may be exaggerated for illustration purposes and may not necessarily be to scale. In the drawings, the same or functionally identical components are provided with the same reference numerals.

[0062] In the present invention, unless otherwise specified, "arranged on", "arranged above", and "arranged on top of" do not exclude the presence of intermediate objects between the two. In addition, "arranged on or above" only represents the relative positional relationship between two components, and in certain cases, such as when the product direction is reversed, it can also be converted to "arranged under or below", and vice versa.

[0063] In the present invention, each embodiment is only intended to illustrate the solution of the present invention and should not be construed as restrictive.

[0064] In the present invention, unless otherwise specified, the quantifiers "a" and "one" do not exclude the scenario of multiple elements.

[0065] It should also be noted here that, in the embodiments of the present invention, for the sake of clarity and simplicity, only a part of the components or assemblies may be shown. However, those of ordinary skill in the art can understand that, under the teachings of the present invention, the required components or assemblies can be added according to the specific scenario requirements. In addition, unless otherwise specified, the features in different embodiments of the present invention can be combined with each other. For example, a certain feature in the second embodiment can be used to replace the corresponding or functionally identical or similar feature in the first embodiment, and the resulting embodiment also falls within the scope of disclosure or the scope of recordation of this application.

[0066] It should also be noted here that within the scope of the present invention, terms such as "identical", "equal", "equal to", etc. do not mean that the two values are absolutely equal, but allow for a certain reasonable error. That is to say, these terms also cover "substantially identical", "substantially equal", "substantially equal to". By analogy, in the present invention, terms indicating directions such as "perpendicular to", "parallel to", etc. also cover the meanings of "substantially perpendicular to", "substantially parallel to".

[0067] In addition, the numbering of the steps of the various methods of the present invention does not limit the execution order of the method steps. Unless otherwise specified, the method steps can be executed in different orders.

[0068] The following further elaborates on the on-chip crystal oscillator calibration circuit and calibration method proposed by the present invention in conjunction with the accompanying drawings and specific embodiments. According to the following description and the claims, the advantages and features of the present invention will be clearer. It should be noted that the accompanying drawings are all in a very simplified form and use non-precise scales, only for the purpose of conveniently and clearly assisting in explaining the purpose of the embodiments of the present invention.

[0069] In addition, unless otherwise specified, the features in different embodiments of the present invention can be combined with each other. For example, a certain feature in the second embodiment can be used to replace the corresponding or functionally identical or similar feature in the first embodiment, and the resulting embodiment also falls within the scope of disclosure or the scope of recordation of this application.

[0070] The purpose of the present invention is to provide an on-chip crystal oscillator calibration circuit and calibration method to solve the problem of long calibration time in the existing on-chip crystal oscillator calibration methods.

[0071] To achieve the above purpose, the present invention provides an on-chip crystal oscillator calibration circuit and calibration method, including: enabling a clock comparison module to compare a clock to be calibrated and a reference clock to obtain a comparison result and provide the comparison result to a state control module; enabling the state control module to generate a step control signal through a successive approximation algorithm according to the comparison result to provide the step control signal to a step control module; and enabling the step control module to generate a calibration signal according to the step control signal to provide the calibration signal to the crystal oscillator to be calibrated.

[0072] An embodiment of the present invention provides an on-chip crystal oscillator calibration circuit, configured as Figure 2 shown, including: a clock comparison module 10, configured to compare a clock to be calibrated and a reference clock to obtain a comparison result and provide the comparison result to a state control module 30; a state control module 30, configured to generate a step control signal through a successive approximation algorithm according to the comparison result to provide the step control signal to a step control module 20; and a step control module 20, configured to generate a calibration signal according to the step control signal to provide the calibration signal to a crystal oscillator 40 to be calibrated.

[0073] In an embodiment of the present invention, in the on-chip crystal oscillator calibration circuit, the crystal oscillator 40 to be calibrated provides the clock to be calibrated to the clock comparison module 10; the step control module 20 generates calibration signals with different step lengths according to the step control signal; and the step control module 20 provides the calibration signals with different step lengths to the crystal oscillator 40 to be calibrated to adjust the clock frequency of the crystal oscillator 40 to be calibrated.

[0074] In an embodiment of the present invention, in the on-chip crystal oscillator calibration circuit, it further includes a central control station 200, and the central control station 200 is configured to perform the following actions: provide a reference clock to the clock comparison module 10 through an IO interface, and provide a target calibration value and read a calibration result to the clock comparison module 10 through a control interface.

[0075] In an embodiment of the present invention, in the on-chip crystal oscillator calibration circuit, the on-chip crystal oscillator calibration circuit and the crystal oscillator 40 to be calibrated are integrally integrated in a chip 100 to be tested; the central control station 200 is located outside the chip 100 to be tested.

[0076] In an embodiment of the present invention, in the on-chip crystal oscillator calibration circuit, the clock comparison module 10 includes: a reference counter, configured to be driven by the reference clock to count; a counter to be calibrated, configured to be driven by the clock to be calibrated to count; and a comparator, configured to compare the count value of the reference counter and the count value of the counter to be calibrated to obtain a comparison result.

[0077] In an embodiment of the present invention, in the on-chip crystal oscillator calibration circuit, the state control module 30 includes: a control module, configured to convert the count value of the reference counter corresponding to the target calibration value according to the comparison value of the reference clock and the target calibration value for the clock comparison module 10 to compare the count value with the count value of the counter to be calibrated; and a successive approximation algorithm implementation module, configured to generate a step control signal by detecting the result of the clock comparison module 10 comparing the count value with the count value of the counter to be calibrated; the step control module adjusts the crystal oscillator to be calibrated according to the step control signal to gradually reduce the error between the clock to be calibrated and the target clock frequency and approach the target clock frequency.

[0078] In an embodiment of the present invention, in the on-chip crystal oscillator calibration circuit, the successive approximation algorithm implementation module controls the states of each calibration and implements the state transition of the successive approximation algorithm. The implementation steps of the successive approximation algorithm are as Figure 3 shown, including: before calibration starts, storing an initial value to be calibrated in the control register of the crystal oscillator 40 to be calibrated; after the clock comparison module 10 receives a calibration start instruction, starting the first clock comparison; if the count value corresponding to the initial value to be calibrated is greater than the count value of the reference counter corresponding to the target calibration value, the comparison result is that the clock to be calibrated is faster than the target calibration value, then the successive approximation algorithm implementation module generates a first step size N, and the step size control module 20 slows down the crystal oscillator 40 to be calibrated by the first step size N on the basis of the initial value to be calibrated; and if the count value corresponding to the initial value to be calibrated is less than the count value of the reference counter corresponding to the target calibration value, the comparison result is that the clock to be calibrated is slower than the target calibration value, then the successive approximation algorithm implementation module generates a first step size N, and the step size control module 20 speeds up the crystal oscillator 40 to be calibrated by the first step size N on the basis of the initial value to be calibrated.

[0079] In an embodiment of the present invention, as Figure 3 shown, in the on-chip crystal oscillator calibration circuit, the successive approximation algorithm further includes: after adjusting the initial value to be calibrated by the first step size N according to the comparison result of the first clock comparison, the clock comparison module 10 performs the i-th clock comparison, where i is a positive integer greater than 1; if the successive approximation algorithm implementation module determines that the comparison result of a certain time is the same as the comparison result of the previous time, continue to adjust in the same direction further, otherwise reduce the step size and perform an adjustment in the opposite direction. The reduction of the step size includes: halving according to the step size of the previous adjustment.

[0080] In an embodiment of the present invention, if the count value corresponding to the initial value to be calibrated is equal to the count value of the reference counter corresponding to the target calibration value, or the difference between the two falls within the error range, or the comparison results of two consecutive times are different from the comparison result of the previous time, calculate the average value after adding the initial values to be calibrated corresponding to the last two adjustments as the configuration value of the control register of the final crystal oscillator to be calibrated; and during the execution of the successive approximation algorithm, if the value of the control register of the crystal oscillator to be calibrated overflows, complete the calibration with a failure flag.

[0081] In an embodiment of the present invention, according to the comparison result of the first clock comparison, after adjusting the initial value to be calibrated with the first step size N, the clock comparison module performs the i-th clock comparison, where i is a positive integer greater than 1; if the successive approximation algorithm implementation module determines that the comparison result of the i-th time is the same as the comparison result of the (i - 1)-th time, then it controls the step size control module 20 to generate the first step size N, so that the step size control module 20 continues to adjust the initial value to be calibrated with the first step size N and in the same adjustment direction as the (i - 1)-th time until the comparison result of the j-th time is different from the comparison result of the (j - 1)-th time, where j is a positive integer not less than i; if the successive approximation algorithm implementation module determines that the comparison result of the j-th time is different from the comparison result of the (j - 1)-th time, then it controls the step size control module 20 to generate the second step size N / 2, so that the step size control module 20 continues to adjust the initial value to be calibrated with the first step size N / 2 and in the opposite adjustment direction to the (j - 1)-th time until the comparison result of the k-th time is different from the comparison result of the (k - 1)-th time, where k is a positive integer not less than j; if the successive approximation algorithm implementation module determines that the comparison result of the k-th time is different from the comparison result of the (k - 1)-th time, then it controls the step size control module 20 to generate the second step size N / 4, so that the step size control module 20 continues to adjust the initial value to be calibrated with the first step size N / 4 and in the opposite adjustment direction to the (k - 1)-th time until the comparison result of the m-th time is different from the comparison result of the (m - 1)-th time, and the initial value to be calibrated stored in the control register of the oscillator 40 to be calibrated at this time is recorded as a, where m is a positive integer not less than k; and if the successive approximation algorithm implementation module determines that the comparison result of the m-th time is different from the comparison result of the (m - 1)-th time, then it controls the step size control module 20 to generate the second step size N / 8, so that the step size control module 20 continues to adjust the initial value to be calibrated with the first step size N / 8 and in the opposite adjustment direction to the (m - 1)-th time until the comparison result of the h-th time is different from the comparison result of the (h - 1)-th time, and the initial value to be calibrated stored in the control register of the oscillator 40 to be calibrated at this time is recorded as b, where h is a positive integer not less than m.

[0082] In an embodiment of the present invention, in the on-chip oscillator calibration circuit, the successive approximation algorithm further includes: calculating the average value of the initial values a and b to be calibrated stored in the control register of the oscillator 40 to be calibrated as the configuration value of the control register of the final oscillator 40 to be calibrated; and during the execution of the successive approximation algorithm, if the value of the control register of the oscillator 40 to be calibrated overflows, then the calibration is completed with a failure flag.

[0083] The present invention also provides an on-chip crystal oscillator calibration method, including: enabling the clock comparison module 10 to compare the clock to be calibrated and the reference clock to obtain a comparison result and provide the comparison result to the state control module 30; enabling the state control module 30 to generate a step control signal through the successive approximation algorithm according to the comparison result to provide the step control signal to the step control module 20; and enabling the step control module 20 to generate a calibration signal according to the step control signal to provide the calibration signal to the crystal oscillator 40 to be calibrated.

[0084] In the on-chip crystal oscillator calibration circuit and calibration method provided by the present invention, a comparison result is obtained by comparing the clock to be calibrated and the reference clock, a step control signal is generated through the successive approximation algorithm, and a calibration signal is generated according to the step control signal to provide the calibration signal to the crystal oscillator 40 to be calibrated, achieving calibration with different step sizes and higher calibration efficiency.

[0085] The present invention adopts the successive approximation algorithm, and the working principle of this algorithm is: there is a certain relationship between the reference clock and the clock after expected calibration (target calibration value), so that when the reference clock count reaches a certain value, the target calibration value of the clock to be calibrated can be calculated, and this target calibration value can be given from the external control interface, so as to adapt to the adjustment of various processes. The count value of the clock to be calibrated is compared with the target calibration value to generate comparison results of greater than and less than.

[0086] The present invention can realize the automatic calibration of the on-chip crystal oscillator. After successive approximation, a valid value that meets the requirements within a certain range can be found. By calculating the average value of the initial calibration values a and b stored in the control register of the crystal oscillator 40 to be calibrated as the configuration value of the control register of the finally calibrated crystal oscillator 40, that is, the configuration value of the control register of the finally calibrated crystal oscillator is the integer value after taking the integer of (a + b) / 2. The present invention avoids the situation in the traditional method where calibration cannot be completed because the count value and the target calibration value may never be equal during the clock comparison process due to clock deviation.

[0087] In some embodiments of the present invention, the number of approximation times can be weighed and increased or decreased according to the requirements of accuracy and speed. For example, when the accuracy requirement is high or the speed requirement is not high, the minimum step size can be adjusted to the fifth step size N / 16, …, or the Lth step size N / 2 L-1 , on the contrary, when the accuracy requirement is not high or the speed requirement is high, the minimum step size can be adjusted to the third step size N / 4, and the final configuration value is obtained by taking the average value of the initial calibration values corresponding to the final 2 to 3 step sizes. In the embodiments of the present invention, the relationship between two adjacent step sizes may not be halved, and it only needs to satisfy that the latter step size is less than the former step size to fall within the protection scope of the present invention. Those skilled in the art can adjust according to the process requirements, and the above solutions are all within the protection scope of the present invention. Through the above flexible optional solutions, the present invention has strong adaptability to various process deviations.

[0088] The clock comparison module 10 of the present invention can achieve calibration only through a small number of comparators, and only some adders and subtractors are required in the step control module 20. In the state control module 30, the state machine jump can be achieved only by maintaining the state according to the clock comparison result. The implementation of the on-chip crystal oscillator calibration is relatively simple. Moreover, in the successive approximation adjustment, even if the clock is accidentally disturbed and the comparison result is incorrect during a certain time, it can be corrected in the next step, thus having a certain fault tolerance ability.

[0089] Specifically, in the clock comparison module 10 of the present invention, counters and comparators driven by a reference clock and a clock to be calibrated are defined. The state control module 30 includes an implementation module for control and successive approximation algorithm, and generates a step control signal by detecting the result of the clock comparison module 10. The step control module 20 adjusts the step according to the control of the state control module 30 and outputs it to the crystal oscillator 40 to be calibrated to adjust the frequency of the crystal oscillator. The state control module 30 controls the states of each calibration and realizes the state transition of the successive approximation algorithm as Figure 3 shown. The implementation steps of this algorithm are as follows:

[0090] At the beginning of calibration, there is an initial value in the control register of the crystal oscillator 40 to be calibrated. After receiving the calibration start instruction, a clock comparison is started. If the count value is greater than the target value, it means that the clock to be calibrated is too fast, and then it is adjusted downward with a large step N based on the initial value of the control register of the crystal oscillator 40 to be calibrated. If the count value is less than the target value, it means that the clock to be calibrated is too slow, and then it is adjusted upward with a large step N. The following steps continue to illustrate the subsequent process with the count value being greater than the target value as an example. The process with the count value being less than the target value is the opposite.

[0091] After adjusting downward with the step N, a clock comparison is performed again. If the count value is still greater than the target value, the crystal oscillator frequency is continuously adjusted downward with the step N until the count value is less than the target value, and then step 3 is entered. If the adjusted register value overflows during this process, the calibration is completed with a failure flag.

[0092] After the adjustment in step 2, the crystal oscillator frequency is adjusted upward with the step N / 2, and a clock comparison is performed again. If the count value is still less than the target value, the crystal oscillator frequency is continuously adjusted upward with the step N / 2 until the count value is greater than the target value, and then step 4 is entered. If the adjusted register value overflows during this process, the calibration is completed with a failure flag.

[0093] After the adjustment in step 3, the crystal oscillator frequency is adjusted downward with the step N / 4, and a clock comparison is performed again. If the count value is still greater than the target value, the crystal oscillator frequency is continuously adjusted downward with the step N / 4 until the count value is less than the target value and step 5 is entered. If the adjusted register value overflows during this process, the calibration is completed with a failure flag.

[0094] After the adjustment in Step 4, save the register calibration value of Step 4, adjust the crystal oscillator frequency upward by a step size of N / 8, and perform the clock comparison again. If the count value is still less than the target value, continue to adjust the crystal oscillator frequency upward by a step size of N / 8 until the count value is greater than the target value. Then save the register value and enter Step 6. If the register value adjustment overflows during this process, the calibration is completed with a failure flag.

[0095] In Step 6, take the average of the saved register value of Step 4 and the saved register value of Step 5 as the average value, which is used as the configuration value of the final calibration register.

[0096] The present invention can achieve the automatic calibration of the on-chip crystal oscillator. After successive approximation, it can find valid values that meet the requirements within a certain range. The present invention avoids the situation in the traditional method where the calibration cannot be completed because the count value and the target value in the clock comparison process may never be equal due to clock deviation. The present invention can trade off increasing or decreasing the number of approximation times according to the requirements of precision and speed, and has strong adaptability to various process deviations. In the implementation of the present invention, the clock comparison module 10 only requires a small number of comparators, only partial adders and subtractors are needed in the step generation module, and in the state control, the state machine jump is maintained through the clock comparison result, so the entire module is relatively simple to implement. Moreover, in the successive approximation adjustment, even if the clock is accidentally disturbed and the comparison result is incorrect in a certain step, it can be corrected in the next step, thus having a certain fault tolerance. The above solution can increase or decrease the number of step adjustments, such as adding adjustments with step sizes of N / 16 and N / 32 to achieve higher precision, or reducing the number of step adjustments to improve the calibration speed.

[0097] The present invention provides an automatic calibration method for an on-chip crystal oscillator based on the successive approximation algorithm. First, adjust based on a larger step size to accelerate the speed of approaching the valid value, and then gradually adjust based on a smaller step size to increase the adjustment precision. After several adjustments, a value near the target value can be obtained. The present invention has a very simple requirement for the clock comparison module 10, only needing to know the greater than or less than relationship, thus reducing the complexity of hardware implementation. The step size of the present invention can be increased or decreased correspondingly in different states, reducing the complexity of hardware implementation.

[0098] In summary, the above embodiments have described in detail different configurations of the on-chip crystal oscillator calibration circuit and calibration method. Of course, the present invention includes but is not limited to the configurations listed in the above embodiments. Any content transformed based on the configurations provided in the above embodiments belongs to the scope protected by the present invention. Those skilled in the art can draw inferences from the content of the above embodiments.

[0099] In the present specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts among the various embodiments can be referred to each other. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the description in the method section.

[0100] The above description is only a description of the preferred embodiments of the present invention and does not limit the scope of the present invention in any way. Any changes and modifications made by those of ordinary skill in the art of the present invention based on the above disclosure fall within the protection scope of the claims.

Claims

1. An on-chip crystal oscillator calibration circuit, characterized in that Including: A clock comparison module, configured to compare a clock to be calibrated and a reference clock to obtain a comparison result and provide the comparison result to a status control module; A status control module, configured to generate a step control signal through a successive approximation algorithm according to the comparison result to provide the step control signal to a step control module; And A step control module, configured to generate a calibration signal according to the step control signal to provide the calibration signal to the crystal oscillator to be calibrated, The clock comparison module includes a reference counter, configured to be driven by the reference clock to count; A counter to be calibrated, configured to be driven by the clock to be calibrated to count; And A comparator, configured to compare the count value of the reference counter and the count value of the counter to be calibrated to obtain a comparison result, The status control module includes: a control module, configured to convert the count value of the reference counter corresponding to the target calibration value according to the comparison value of the reference clock and the target calibration value for the clock comparison module to compare the count value with the count value of the counter to be calibrated; and a successive approximation algorithm implementation module, configured to generate a step control signal and implement state conversion by detecting the comparison result of the clock comparison module comparing the count value with the count value of the counter to be calibrated; the step control module adjusts the crystal oscillator to be calibrated according to the step control signal to gradually reduce the error between the clock to be calibrated and the target clock frequency and approach the target clock frequency, Wherein the successive approximation algorithm implementation module controls the states of each calibration and implements the state conversion of the successive approximation algorithm. The implementation steps of the successive approximation algorithm are as follows: Before calibration starts, store the initial value to be calibrated in the control register of the crystal oscillator to be calibrated; After the clock comparison module receives the calibration start instruction, start the first clock comparison; If the count value corresponding to the initial value to be calibrated is greater than the count value of the reference counter corresponding to the target calibration value, the comparison result is that the clock to be calibrated is faster than the target calibration value, then the successive approximation algorithm implementation module generates a first step, and the step control module slows down the crystal oscillator to be calibrated by the first step based on the initial value to be calibrated; and If the count value corresponding to the initial value to be calibrated is less than the count value of the reference counter corresponding to the target calibration value, the comparison result is that the clock to be calibrated is slower than the target calibration value, then the successive approximation algorithm implementation module generates a first step, and the step control module speeds up the crystal oscillator to be calibrated by the first step based on the initial value to be calibrated; After adjusting the initial value to be calibrated by the first step according to the comparison result of the first clock comparison, the clock comparison module performs multiple clock comparisons; If the successive approximation algorithm implementation module determines that the comparison result of a certain time is the same as the comparison result of the previous time, continue to adjust in the same direction further, otherwise convert the state, reduce the step and perform adjustment in the opposite direction.

2. The on-chip crystal oscillator calibration circuit according to claim 1, characterized in that, The crystal oscillator to be calibrated provides the clock to be calibrated to the clock comparison module; The step control module generates calibration signals with different steps according to the step control signal; The step control module provides calibration signals with different steps to the crystal oscillator to be calibrated to adjust the clock frequency of the crystal oscillator to be calibrated.

3. The on-chip crystal oscillator calibration circuit according to claim 2, wherein, It further includes a central control console, which is configured to perform the following actions: Provide the reference clock to the clock comparison module through the IO interface, and Provide the target calibration value and read the calibration result to the clock comparison module through the control interface.

4. The on-chip crystal oscillator calibration circuit according to claim 3, characterized in that, The on-chip crystal oscillator calibration circuit and the crystal oscillator to be calibrated are integrated in the chip under test; The central control station is located outside the chip under test.

5. The on-chip crystal oscillator calibration circuit according to claim 1, characterized in that The successive approximation algorithm further includes: The reduction of the step size includes: halving the step size according to the previously adjusted step size.

6. The on-chip crystal oscillator calibration circuit according to claim 5, wherein The successive approximation algorithm further includes: If the count value corresponding to the initial value to be calibrated is equal to the count value of the reference counter corresponding to the target calibration value, or the difference between the two falls within the error range, or the comparison results of two consecutive times are different from the previous comparison result, calculate the average value after adding the initial values to be calibrated corresponding to the last two adjustments, and use it as the configuration value of the control register of the crystal oscillator to be calibrated finally; and During the execution of the successive approximation algorithm, if the value of the control register for adjusting the crystal oscillator to be calibrated overflows, the calibration is completed with a failure flag.

7. The on-chip crystal oscillator calibration circuit according to claim 1, wherein The successive approximation algorithm further includes: According to the comparison result of the first clock comparison, after adjusting the initial value to be calibrated with the first step size N, the clock comparison module performs the i-th clock comparison, where i is a positive integer greater than 1; If the successive approximation algorithm implementation module determines that the comparison result of the i-th time is the same as the comparison result of the (i - 1)-th time, control the step size control module to generate the first step size N, so that the step size control module continues to adjust the initial value to be calibrated with the first step size N and the same adjustment direction as the (i - 1)-th time until the comparison result of the j-th time is different from the comparison result of the (j - 1)-th time, where j is a positive integer not less than i; If the successive approximation algorithm implementation module determines that the comparison result of the j-th time is different from the comparison result of the (j - 1)-th time, control the step size control module to generate the second step size N / 2, so that the step size control module continues to adjust the initial value to be calibrated with the second step size N / 2 and the opposite adjustment direction to the (j - 1)-th time until the comparison result of the k-th time is different from the comparison result of the (k - 1)-th time, where k is a positive integer not less than j; If the successive approximation algorithm implementation module determines that the comparison result of the k-th time is different from the comparison result of the (k - 1)-th time, control the step size control module to generate the third step size N / 4, so that the step size control module continues to adjust the initial value to be calibrated with the third step size N / 4 and the opposite adjustment direction to the (k - 1)-th time until the comparison result of the m-th time is different from the comparison result of the (m - 1)-th time, and save the initial value to be calibrated stored in the control register of the crystal oscillator to be calibrated at this time as a, where m is a positive integer not less than k; and If the successive approximation algorithm implementation module determines that the comparison result of the m-th time is different from the comparison result of the (m - 1)-th time, control the step size control module to generate the fourth step size N / 8, so that the step size control module continues to adjust the initial value to be calibrated with the fourth step size N / 8 and the opposite adjustment direction to the (m - 1)-th time until the comparison result of the h-th time is different from the comparison result of the (h - 1)-th time, and save the initial value to be calibrated stored in the control register of the crystal oscillator to be calibrated at this time as b, where h is a positive integer not less than m; The configuration value of the control register of the crystal oscillator to be calibrated finally is the integer value after taking the integer part of (a + b) / 2.

8. An on-chip crystal oscillator calibration method, characterized in that, Include: Cause the clock comparison module to compare the clock to be calibrated and the reference clock to obtain a comparison result and provide the comparison result to the state control module; Cause the state control module to generate a step control signal through the successive approximation algorithm according to the comparison result to provide the step control signal to the step control module; And Cause the step control module to generate a calibration signal according to the step control signal to provide the calibration signal to the crystal oscillator to be calibrated, where the implementation steps of the successive approximation algorithm are as follows: Before calibration starts, store the initial value to be calibrated in the control register of the crystal oscillator to be calibrated; After the clock comparison module receives the calibration start instruction, start the first clock comparison; If the count value corresponding to the initial value to be calibrated is greater than the count value of the reference counter corresponding to the target calibration value, the comparison result is that the clock to be calibrated is faster than the target calibration value, then the successive approximation algorithm implementation module generates the first step, and the step control module slows down the crystal oscillator to be calibrated by the first step based on the initial value to be calibrated; And If the count value corresponding to the initial value to be calibrated is less than the count value of the reference counter corresponding to the target calibration value, the comparison result is that the clock to be calibrated is slower than the target calibration value, then the successive approximation algorithm implementation module generates the first step, and the step control module speeds up the crystal oscillator to be calibrated by the first step based on the initial value to be calibrated; After adjusting the initial value to be calibrated by the first step according to the comparison result of the first clock comparison, the clock comparison module performs multiple clock comparisons; If the successive approximation algorithm implementation module determines that the comparison result of a certain time is the same as that of the previous time, continue to adjust in the same direction further, otherwise change the state, reduce the step and then adjust in the opposite direction.

Citation Information

Patent Citations

  • Chip capable of self-calibrating internal crystal oscillator, crystal oscillator calibration test system and calibration method

    CN103116124B

  • Chip capable of self-calibration of interior crystal oscillator, calibration system and calibration method

    CN103116124A

  • High -speed self -calibration chip encircles controller and testing arrangement of frequency of shaking

    CN205844782U