On-chip crystal oscillator calibration circuit and calibration method

文档序号:89491 发布日期:2021-10-08 浏览:45次 中文

阅读说明:本技术 片内晶振校准电路及校准方法 (On-chip crystal oscillator calibration circuit and calibration method ) 是由 孙向向 江国范 于 2021-05-27 设计创作,主要内容包括:本发明提供了一种片内晶振校准电路及校准方法,包括:时钟比较模块,被配置为比较待校准时钟和参考时钟,以得到比较结果并向状态控制模块提供比较结果;状态控制模块,被配置为根据比较结果通过逐次逼近算法生成步长控制信号,以向步长控制模块提供步长控制信号;步长控制模块,被配置为根据步长控制信号生成校准信号,以向待校准晶振提供校准信号。(The invention provides an on-chip crystal oscillator calibration circuit and a calibration method, which comprise the following steps: the clock comparison module is configured to compare the clock to be calibrated with the reference clock to obtain a comparison result and provide the comparison result to the state control module; the state control module is configured to generate a step control signal through a successive approximation algorithm according to the comparison result so as to provide the step control signal for the step control module; and the step size control module is configured to generate a calibration signal according to the step size control signal so as to provide the calibration signal for the crystal oscillator to be calibrated.)

1. An on-chip crystal oscillator calibration circuit, comprising:

the clock comparison module is configured to compare the clock to be calibrated with the reference clock to obtain a comparison result and provide the comparison result to the state control module;

the state control module is configured to generate a step control signal through a successive approximation algorithm according to the comparison result so as to provide the step control signal for the step control module; and

and the step size control module is configured to generate a calibration signal according to the step size control signal so as to provide the calibration signal for the crystal oscillator to be calibrated.

2. The on-chip crystal oscillator calibration circuit of claim 1, wherein the crystal oscillator to be calibrated provides a clock to be calibrated to the clock comparison module;

the step length control module generates calibration signals with different step lengths according to the step length control signals;

the step length control module provides the calibration signals with different step lengths to the crystal oscillator to be calibrated so as to adjust the clock frequency of the crystal oscillator to be calibrated.

3. The on-chip crystal oscillator calibration circuit of claim 2, further comprising a central control station configured to:

providing a reference clock to a clock comparison module via an IO interface, an

And providing the target calibration value and the reading calibration result to the clock comparison module through the control interface.

4. The on-chip crystal oscillator calibration circuit as claimed in claim 3, wherein the on-chip crystal oscillator calibration circuit and the crystal oscillator to be calibrated are integrated together in a chip to be tested;

and the center control machine station is positioned outside the chip to be tested.

5. The on-chip crystal oscillator calibration circuit of claim 3, wherein the clock comparison module comprises:

a reference counter configured to be driven by a reference clock to count;

a to-be-calibrated counter configured to be driven by a to-be-calibrated clock to count; and

and the comparator is configured to compare the count value of the reference counter with the count value of the counter to be calibrated to obtain a comparison result.

6. The on-chip crystal oscillator calibration circuit of claim 5, wherein the state control module comprises:

the control module is configured to convert a count value of a reference counter corresponding to the target calibration value according to a comparison value of the reference clock and the target calibration value, so that the clock comparison module can compare the count value with a count value of a counter to be calibrated; and

the successive approximation algorithm implementation module is configured to generate a step control signal according to a result of comparing the count value with the count value of the counter to be calibrated by the detection clock comparison module;

the step control module adjusts the crystal oscillator to be calibrated according to the step control signal so as to gradually reduce the error between the clock to be calibrated and the target clock frequency and approach the target clock frequency.

7. The on-chip crystal oscillator calibration circuit of claim 6, wherein the successive approximation algorithm implementation module controls each calibration state and implements state conversion of the successive approximation algorithm, the successive approximation algorithm implementation steps being as follows:

before the calibration is started, storing an initial value to be calibrated in a control register of a crystal oscillator to be calibrated;

after the clock comparison module receives the calibration starting instruction, starting first time clock comparison;

if the count value corresponding to the initial value to be calibrated is larger than the count value of the reference counter corresponding to the target calibration value, and the comparison result is that the clock to be calibrated is faster than the target calibration value, the successive approximation algorithm implementation module generates a first step length, and the step length control module adjusts and slows down the crystal oscillator to be calibrated by the first step length on the basis of the initial value to be calibrated; and

if the count value corresponding to the initial value to be calibrated is smaller than the count value of the reference counter corresponding to the target calibration value, and the comparison result is that the clock to be calibrated is slower than the target calibration value, the successive approximation algorithm implementation module generates a first step length, and the step length control module adjusts the crystal oscillator to be calibrated according to the first step length on the basis of the initial value to be calibrated.

8. The on-chip oscillator calibration circuit of claim 7, wherein the successive approximation algorithm further comprises:

according to the comparison result of the first time of clock comparison, after the initial value to be calibrated is adjusted by the first step length, the clock comparison module carries out clock comparison for multiple times;

if the successive approximation algorithm implementation module judges that the comparison result of a certain time is the same as the comparison result of the previous time, continuing to further adjust in the same direction, otherwise, reducing the step length and then adjusting in the opposite direction.

9. The on-chip oscillator calibration circuit of claim 8, wherein the successive approximation algorithm further comprises:

the step size reduction includes: and halving according to the step length adjusted at the previous time.

10. The on-chip oscillator calibration circuit of claim 9, wherein the successive approximation algorithm further comprises:

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 value of the two values falls within the error range, or the comparison result of two consecutive times is different from the comparison result of the previous time, calculating the average value obtained after adding the initial values to be calibrated corresponding to the last two times of adjustment, and taking the average value as the final configuration value of the control register of the crystal oscillator to be calibrated; and

and in the execution process of the successive approximation algorithm, if the value of the control register of the crystal oscillator to be calibrated is adjusted to overflow, the calibration is completed by using the failure identifier.

11. The on-chip oscillator calibration circuit of claim 7, wherein the successive approximation algorithm further comprises:

according to the comparison result of the first time of clock comparison, after the initial value to be calibrated is adjusted by a first step length N, the clock comparison module carries out the ith time of clock comparison, wherein i is a positive integer greater than 1;

if the successive approximation algorithm implementation module judges that the comparison result of the ith time is the same as the comparison result of the (i-1) th time, controlling the step length control module to generate a first step length N so that the step length control module continues to adjust the initial value to be calibrated in the first step length N and the adjustment direction which is the same as the adjustment direction of the (i-1) th time until the comparison result of the jth time is different from the comparison result of the (j-1) th time, wherein j is a positive integer not less than i;

if the successive approximation algorithm implementation module judges that the result of the comparison at the jth time is different from the result of the comparison at the jth-1 time, the step length control module is controlled to generate a second step length N/2, so that the step length control module continues to adjust the initial value to be calibrated in the second step length N/2 and the adjustment direction opposite to the jth-1 time until the result of the comparison at the kth time is different from the result of the comparison at the kth-1 time, wherein k is a positive integer not less than j;

if the successive approximation algorithm implementation module judges that the comparison result of the kth time is different from the comparison result of the kth-1 time, the control step length control module generates a third step length N/4, so that the step length control module continues to adjust the initial value to be calibrated in the third step length N/4 and the adjusting direction opposite to the kth-1 time until the comparison result of the mth time is different from the comparison result of the m-1 time, and stores the initial value to be calibrated in a control register of the crystal oscillator to be calibrated and records the initial value to be calibrated as a, wherein m is a positive integer not less than k; and

and if the successive approximation algorithm implementation module judges that the comparison result of the mth time is different from the comparison result of the (m-1) th time, the control step length control module generates a fourth step length N/8 so that the step length control module continues to adjust the initial value to be calibrated by the fourth step length N/8 and the adjustment direction opposite to the (m-1) th time until the comparison result of the h time is different from the comparison result of the h-1 th time, and stores the initial value to be calibrated in a control register of the crystal oscillator to be calibrated and records the initial value to be calibrated as b, wherein h is a positive integer not less than m.

And the final configuration value of the control register of the crystal oscillator to be calibrated is the value obtained by rounding (a + b)/2.

12. An on-chip crystal oscillator calibration method is characterized by comprising the following steps:

the clock comparison module compares the clock to be calibrated with the reference clock to obtain a comparison result and provides the comparison result to the state control module;

enabling the state control module to generate a step length control signal through a successive approximation algorithm according to the comparison result so as to provide the step length control signal for the step length control module; and

and enabling the step length control module to generate a calibration signal according to the step length control signal so as to provide the calibration signal for the crystal oscillator to be calibrated.

Technical Field

The invention relates to the technical field of integrated circuits, in particular to an on-chip crystal oscillator calibration circuit and method based on a successive approximation algorithm.

Background

In an actually manufactured chip including an on-chip crystal oscillator, due to process deviation, various deviations exist between the clock signal frequency generated by a crystal oscillator circuit in the chip and the clock frequency expected by design, and for a chip requiring a precise clock, the internal crystal oscillator circuit needs to be calibrated.

In an actual on-chip crystal oscillator circuit, the capacitance of the on-chip circuit can be adjusted through a series of switches, the clock frequency can be changed by changing the capacitance, and the purpose of calibrating the clock frequency is further achieved.

As shown in fig. 1, a commonly used test method is that a central control station sends a test instruction through a control interface, and outputs a clock signal (output clock) of an on-chip crystal oscillator of a chip to be tested to the central control station, the central control station compares the reference precision clock signal with the output crystal oscillator signal, and the on-chip crystal oscillator is adjusted through step-by-step control to realize calibration, and the calibration method has a long calibration time, and the frequency and precision output by an IO port are limited by the IO port.

For example, chinese patent CN103116124B provides a method for calibrating a chip, which needs to find an optimal solution in the process of comparing clocks, and provides no solution for an effective value that meets within a certain range, and the step length is fixed in the calibration process, which is not beneficial to improving the calibration efficiency and precision.

Disclosure of Invention

The invention aims to provide an on-chip crystal oscillator calibration circuit and a calibration method, which aim to solve the problem of long calibration time of the conventional on-chip crystal oscillator calibration method.

In order to solve the above technical problem, the present invention provides an on-chip crystal oscillator calibration circuit, including:

the clock comparison module is configured to compare the clock to be calibrated with the reference clock to obtain a comparison result and provide the comparison result to the state control module;

the state control module is configured to generate a step control signal through a successive approximation algorithm according to the comparison result so as to provide the step control signal for the step control module; and

and the step size control module is configured to generate a calibration signal according to the step size control signal so as to provide the calibration signal for the crystal oscillator to be calibrated.

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;

the step length control module generates calibration signals with different step lengths according to the step length control signals; and

the step length control module provides the calibration signals with different step lengths to the crystal oscillator to be calibrated so as to adjust the clock frequency of the crystal oscillator to be calibrated.

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

providing a reference clock to a clock comparison module via an IO interface, an

And providing the target calibration value and the reading calibration result to the clock comparison module through the control interface.

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 together in a chip to be tested;

and the center control machine station is positioned outside the chip to be tested.

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

a reference counter configured to be driven by a reference clock to count;

a to-be-calibrated counter configured to be driven by a to-be-calibrated clock to count; and

and the comparator is configured to compare the count value of the reference counter with the count value of the counter to be calibrated to obtain a comparison result.

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

the control module is configured to convert a count value of a reference counter corresponding to the target calibration value according to a comparison value of the reference clock and the target calibration value, so that the clock comparison module can compare the count value with a count value of a counter to be calibrated; and

the successive approximation algorithm implementation module is configured to generate a step control signal according to a result of comparing the count value with the count value of the counter to be calibrated by the detection clock comparison module;

the step control module adjusts the crystal oscillator to be calibrated according to the step control signal so as to gradually reduce the error between the clock to be calibrated and the target clock frequency and approach the target clock frequency.

Optionally, in the on-chip oscillator calibration circuit, the successive approximation algorithm implementation module controls each calibrated state and implements state conversion of the successive approximation algorithm, where the successive approximation algorithm implementation step is as follows:

before the calibration is started, storing an initial value to be calibrated in a control register of a crystal oscillator to be calibrated;

after the clock comparison module receives the calibration starting instruction, starting first time clock comparison;

if the count value corresponding to the initial value to be calibrated is larger than the count value of the reference counter corresponding to the target calibration value, and the comparison result is that the clock to be calibrated is faster than the target calibration value, the successive approximation algorithm implementation module generates a first step length N, and the step length control module adjusts the crystal oscillator to be calibrated by the first step length 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 smaller than the count value of the reference counter corresponding to the target calibration value, and the comparison result is that the clock to be calibrated is slower than the target calibration value, the successive approximation algorithm implementation module generates a first step length N, and the step length control module adjusts the crystal oscillator to be calibrated according to the first step length N on the basis of the initial value to be calibrated.

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

according to the comparison result of the first time of clock comparison, after the initial value to be calibrated is adjusted by the first step length, the clock comparison module carries out clock comparison for multiple times;

if the successive approximation algorithm implementation module judges that the comparison result of a certain time is the same as the comparison result of the previous time, continuing to further adjust in the same direction, otherwise, reducing the step length and then adjusting in the opposite direction.

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

the step size reduction includes: and halving according to the step length adjusted at the previous time.

Optionally, in the on-chip crystal oscillator calibration circuit, 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 value of the two values falls within the error range, or the comparison result of two consecutive times is different from the comparison result of the previous time, calculating the average value obtained after adding the initial values to be calibrated corresponding to the last two times of adjustment, and taking the average value as the final configuration value of the control register of the crystal oscillator to be calibrated; and

and in the execution process of the successive approximation algorithm, if the value of the control register of the crystal oscillator to be calibrated is adjusted to overflow, the calibration is completed by using the failure identifier.

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

according to the comparison result of the first time of clock comparison, after the initial value to be calibrated is adjusted by a first step length N, the clock comparison module carries out the ith time of clock comparison, wherein i is a positive integer greater than 1;

if the successive approximation algorithm implementation module judges that the comparison result of the ith time is the same as the comparison result of the (i-1) th time, controlling the step length control module to generate a first step length N so that the step length control module continuously adjusts the initial value to be calibrated according to the first step length N and the adjustment direction which is the same as the adjustment direction of the (i-1) th time until the comparison result of the jth time is different from the comparison result of the (j-1) th time, wherein j is a positive integer not less than i;

if the successive approximation algorithm implementation module judges that the result of the comparison at the jth time is different from the result of the comparison at the jth-1 time, the step length control module is controlled to generate a second step length N/2, so that the step length control module continues to adjust the initial value to be calibrated in the second step length N/2 and the adjustment direction opposite to the jth-1 time until the result of the comparison at the kth time is different from the result of the comparison at the kth-1 time, wherein k is a positive integer not less than j;

if the successive approximation algorithm implementation module judges that the comparison result of the kth time is different from the comparison result of the kth-1 time, the control step length control module generates a third step length N/4 so that the step length control module continues to adjust the initial value to be calibrated in the third step length N/4 and the adjusting direction opposite to the kth-1 time until the comparison result of the mth time is different from the comparison result of the m-1 time, and stores the initial value to be calibrated in a control register of the crystal oscillator to be calibrated and records the initial value to be calibrated as a, wherein m is a positive integer not less than k; and

and if the successive approximation algorithm implementation module judges that the comparison result of the mth time is different from the comparison result of the (m-1) th time, the control step length control module generates a fourth step length N/8 so as to enable the step length control module to continuously adjust the initial value to be calibrated in the fourth step length N/8 and the adjusting direction opposite to the (m-1) th time until the comparison result of the h time is different from the comparison result of the h-1 th time, and storing the initial value to be calibrated in a control register of the crystal oscillator to be calibrated and marking the initial value to be calibrated as b, wherein h is a positive integer not less than m.

And the final configuration value of the control register of the crystal oscillator to be calibrated is the value obtained by rounding (a + b)/2.

The invention also provides an on-chip crystal oscillator calibration method, which comprises the following steps:

the clock comparison module compares the clock to be calibrated with the reference clock to obtain a comparison result and provides the comparison result to the state control module;

enabling the state control module to generate a step length control signal through a successive approximation algorithm according to the comparison result so as to provide the step length control signal for the step length control module; and

and enabling the step length control module to generate a calibration signal according to the step length control signal so as to provide the calibration signal for the crystal oscillator to be calibrated.

In the on-chip crystal oscillator calibration circuit and the calibration method provided by the invention, the comparison result is obtained by comparing the clock to be calibrated with the reference clock, the step control signal is generated by a successive approximation algorithm, and the calibration signal is generated according to the step control signal so as to provide the calibration signal for the crystal oscillator to be calibrated, so that calibration with different step lengths is realized, and the calibration efficiency is higher.

The invention adopts a successive approximation algorithm, and the working principle of the algorithm is as follows: the reference clock and the clock expected to be calibrated (target calibration value) have a certain relation, so that when the reference clock count reaches a certain value, the target calibration value of the clock to be calibrated can be converted, and the target calibration value can be given from an external control interface, so that the adjustment of various processes can be adapted. And comparing the count value of the clock to be calibrated with the target calibration value to generate a comparison result which is greater than or less than the target calibration value.

The invention can realize the automatic calibration of the chip oscillator, and can find the effective value meeting the requirement in a certain range after successive approximation. By calculating the average value of the initial values a and b to be calibrated stored in the control register of the crystal oscillator to be calibrated as the final configuration value of the control register of the crystal oscillator to be calibrated, the invention avoids the situation that the calibration cannot be completed because the counting value and the target calibration value in the clock comparison process are always unequal due to clock deviation in the traditional method.

The invention can balance the increase or decrease of the approaching times according to the requirements of precision and speed, for example, when the precision requirement is higher or the speed requirement is not high, the minimum step length can be adjusted to a fifth step length N/16, conversely, when the precision requirement is not high or the speed requirement is higher, the minimum step length can be adjusted to a third step length N/4, the final configuration value is used for calculating the average value according to the initial value to be calibrated corresponding to the final 2-3 step lengths, the technical personnel in the field can carry out allocation according to the process requirement, the scheme is within the protection range of the invention, and the invention has strong adaptability to various process deviations through the flexible alternative scheme.

The clock comparison module can realize calibration only by a small number of comparators and only part of the adder-subtractor in the step length control module, and can realize calibration only by maintaining state machine jump according to the clock comparison result in the state control module.

Drawings

FIG. 1 is a schematic diagram of a conventional on-chip calibration circuit;

FIG. 2 is a schematic diagram of an on-chip calibration circuit according to an embodiment of the present invention;

FIG. 3 is a schematic diagram of a method for calibrating an on-chip crystal oscillator according to another embodiment of the present invention;

shown in the figure: 10-a clock comparison module; 20-step size control module; 30-a state control module; 40-crystal oscillator to be calibrated; 100-a chip to be tested; 200-a central control machine.

Detailed Description

The invention is further elucidated with reference to the drawings in conjunction with the detailed description.

It should be noted that the components in the figures may be exaggerated and not necessarily to scale for illustrative purposes. In the figures, identical or functionally identical components are provided with the same reference symbols.

In the present invention, "disposed on …", "disposed over …" and "disposed over …" do not exclude the presence of an intermediate therebetween, unless specifically noted. Further, "disposed on or above …" merely indicates the relative positional relationship between two components, and may also be converted to "disposed below or below …" and vice versa in certain cases, such as after reversing the product direction.

In the present invention, the embodiments are only intended to illustrate the aspects of the present invention, and should not be construed as limiting.

In the present invention, the terms "a" and "an" do not exclude the context of a plurality of elements, unless otherwise specified.

It is further noted herein that in embodiments of the present invention, only a portion of the components or assemblies may be shown for clarity and simplicity, but those skilled in the art will appreciate that the components or assemblies required may be added as needed in the particular context under the teachings of the present invention. Furthermore, features from different embodiments of the invention may be combined with each other, unless otherwise indicated. For example, a feature of the second embodiment may be substituted for a corresponding or functionally equivalent or similar feature of the first embodiment, and the resulting embodiments may likewise fall within the scope of the disclosure or recitation of the present application.

It is also noted herein that, within the scope of the present invention, the terms "same", "equal", and the like do not mean that the two values are absolutely equal, but allow some reasonable error, that is, the terms also encompass "substantially the same", "substantially equal", and the like. By analogy, in the present invention, the terms "perpendicular", "parallel" and the like in the directions of the tables likewise encompass the meanings of "substantially perpendicular", "substantially parallel".

In addition, the numbering of the steps of the methods of the present invention does not limit the order of execution of the steps of the methods. Unless specifically stated, the method steps may be performed in a different order.

The on-chip oscillator calibration circuit and the calibration method according to the present invention will be described in detail with reference to the accompanying drawings and specific embodiments. The advantages and features of the present invention will become more fully apparent from the following description and appended claims. It is to be noted that the drawings are in a very simplified form and are not to precise scale, which is merely for the purpose of facilitating and distinctly claiming the embodiments of the present invention.

Furthermore, features from different embodiments of the invention may be combined with each other, unless otherwise indicated. For example, a feature of the second embodiment may be substituted for a corresponding or functionally equivalent or similar feature of the first embodiment, and the resulting embodiments are likewise within the scope of the disclosure or recitation of the present application.

The invention aims to provide an on-chip crystal oscillator calibration circuit and a calibration method, which aim to solve the problem of long calibration time of the conventional on-chip crystal oscillator calibration method.

In order to achieve the above object, the present invention provides an on-chip crystal oscillator calibration circuit and a calibration method, including: the clock comparison module compares the clock to be calibrated with the reference clock to obtain a comparison result and provides the comparison result to the state control module; enabling the state control module to generate a step length control signal through a successive approximation algorithm according to the comparison result so as to provide the step length control signal for the step length control module; and enabling the step length control module to generate a calibration signal according to the step length control signal so as to provide the calibration signal for the crystal oscillator to be calibrated.

An embodiment of the present invention provides an on-chip crystal oscillator calibration circuit, which is configured as shown in fig. 2, and includes: a clock comparison module 10 configured to compare the clock to be calibrated with the reference clock to obtain a comparison result and provide the comparison result to the 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 the step control module 20; and a step size control module 20 configured to generate a calibration signal according to the step size control signal to provide the calibration signal to the crystal oscillator 40 to be calibrated.

In an embodiment of the invention, in the on-chip crystal oscillator calibration circuit, the crystal oscillator 40 to be calibrated provides a clock to be calibrated to the clock comparison module 10; step size control module 20 generates calibration signals with different step sizes according to the step size control signal; and the step size control module 20 provides the calibration signals with different step sizes to the crystal oscillator 40 to be calibrated so as to adjust the clock frequency of the crystal oscillator 40 to be calibrated.

In an embodiment of the invention, the on-chip crystal oscillator calibration circuit further includes a central control stage 200, where the central control stage 200 is configured to perform the following actions: the reference clock is provided to the clock comparison module 10 through the IO interface, and the target calibration value and the read calibration result are provided to the clock comparison module 10 through the control interface.

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 integrated together in the chip 100 to be tested; the center control machine 200 is located outside the chip 100 to be tested.

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 a reference clock to count; a to-be-calibrated counter configured to be driven by a to-be-calibrated clock 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.

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

In an embodiment of the present invention, in the on-chip oscillator calibration circuit, a successive approximation algorithm implementation module controls each calibration state and implements state transition of a successive approximation algorithm, and the implementation steps of the successive approximation algorithm are shown in fig. 3 and include: before the calibration is started, storing an initial value to be calibrated in a control register of the crystal oscillator 40 to be calibrated; after receiving the calibration start instruction, the clock comparison module 10 starts the first time 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, and the comparison result is that the clock to be calibrated is faster than the target calibration value, the successive approximation algorithm implementation module generates a first step length N, and the step length control module 20 slows down the crystal oscillator 40 to be calibrated by the first step length 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 smaller than the count value of the reference counter corresponding to the target calibration value, and the comparison result is that the clock to be calibrated is slower than the target calibration value, the successive approximation algorithm implementation module generates a first step length N, and the step length control module 20 adjusts the crystal oscillator 40 to be calibrated by the first step length N on the basis of the initial value to be calibrated.

In an embodiment of the present invention, as shown in fig. 3, in the on-chip oscillator calibration circuit, the successive approximation algorithm further includes: according to the comparison result of the first time of clock comparison, after the initial value to be calibrated is adjusted by a first step length N, the clock comparison module 10 performs the ith time of clock comparison, wherein i is a positive integer greater than 1; if the successive approximation algorithm implementation module judges that the comparison result of a certain time is the same as the comparison result of the previous time, continuing to further adjust in the same direction, otherwise, reducing the step length and then adjusting in the opposite direction. The step size reduction includes: and halving according to the step length adjusted at the previous time.

In an embodiment of the 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 value of the two values falls within the error range, or the comparison result of two consecutive times is different from the comparison result of the previous time, the average value obtained after adding the initial values to be calibrated corresponding to the last two times of adjustment is calculated and used as the final configuration value of the control register of the crystal oscillator to be calibrated; and in the execution process of the successive approximation algorithm, if the value of the control register of the crystal oscillator to be calibrated is adjusted to overflow, the calibration is completed by the failure identifier.

In an embodiment of the present invention, after adjusting the initial value to be calibrated by a first step length N according to the comparison result of the first time clock comparison, the clock comparison module performs the ith time clock comparison, where i is a positive integer greater than 1; if the successive approximation algorithm implementation module judges that the comparison result of the ith time is the same as the comparison result of the (i-1) th time, controlling the step length control module 20 to generate a first step length N so that the step length control module 20 continues to adjust the initial value to be calibrated by the first step length N and the adjustment direction which is the same as the adjustment direction of the (i-1) th time until the comparison result of the jth time is different from the comparison result of the (j-1) th time, wherein j is a positive integer not less than i; if the successive approximation algorithm implementation module judges that the result of the comparison at the jth time is different from the result of the comparison at the jth-1 time, the control step length control module 20 generates a second step length N/2, so that the step length control module 20 continues to adjust the initial value to be calibrated in the first step length N/2 and the adjustment direction opposite to the jth-1 time until the result of the comparison at the kth time is different from the result of the comparison at the kth-1 time, wherein k is a positive integer not less than j; if the successive approximation algorithm implementation module judges that the comparison result of the kth time is different from the comparison result of the kth-1 time, the control step length control module 20 generates a second step length N/4, so that the step length control module 20 continues to adjust the initial value to be calibrated in the first step length N/4 and the adjustment direction opposite to the kth-1 time until the comparison result of the mth time is different from the comparison result of the m-1 time, and stores the initial value to be calibrated stored in a control register of the crystal oscillator 40 to be calibrated at the moment and records the initial value as a, wherein m is a positive integer not less than k; and if the successive approximation algorithm implementation module judges that the comparison result of the mth time is different from the comparison result of the (m-1) th time, controlling the step length control module 20 to generate a second step length N/8 so that the step length control module 20 continues to adjust the initial value to be calibrated according to the first step length N/8 and the adjustment direction opposite to the (m-1) th time until the comparison result of the h time is different from the comparison result of the h-1 th time, storing the initial value to be calibrated in a control register of the crystal oscillator 40 to be calibrated at the moment and recording the initial value to be calibrated as b, wherein h is a positive integer not less than m.

In an embodiment of the present invention, in the on-chip oscillator calibration circuit, the successive approximation algorithm further includes: calculating an average value of initial values a and b to be calibrated stored in a control register of the crystal oscillator 40 to be calibrated, and taking the average value as a final configuration value of the control register of the crystal oscillator 40 to be calibrated; and in the execution process of the successive approximation algorithm, if the value of the control register of the crystal oscillator 40 to be calibrated is adjusted to overflow, the calibration is completed by the failure identifier.

The invention also provides an on-chip crystal oscillator calibration method, which comprises the following steps: the clock comparison module 10 compares the clock to be calibrated with the reference clock to obtain a comparison result and provides the comparison result to the state control module 30; enabling the state control module 30 to generate a step control signal through a successive approximation algorithm according to the comparison result so as to provide the step control signal to the step control module 20; and enabling the step size control module 20 to generate a calibration signal according to the step size control signal so as to provide the calibration signal for the crystal oscillator 40 to be calibrated.

In the on-chip crystal oscillator calibration circuit and the calibration method provided by the invention, the comparison result is obtained by comparing the clock to be calibrated with the reference clock, the step control signal is generated by the successive approximation algorithm, and the calibration signal is generated according to the step control signal so as to provide the calibration signal for the crystal oscillator 40 to be calibrated, so that calibration with different step lengths is realized, and the calibration efficiency is higher.

The invention adopts a successive approximation algorithm, and the working principle of the algorithm is as follows: the reference clock and the clock expected to be calibrated (target calibration value) have a certain relation, so that when the reference clock count reaches a certain value, the target calibration value of the clock to be calibrated can be converted, and the target calibration value can be given from an external control interface, so that the adjustment of various processes can be adapted. And comparing the count value of the clock to be calibrated with the target calibration value to generate comparison results which are greater than and less than.

The invention can realize the automatic calibration of the chip oscillator, and can find the effective value meeting the requirement in a certain range after successive approximation. The average value of the initial values a and b to be calibrated stored in the control register of the crystal oscillator 40 to be calibrated is calculated and used as the final configuration value of the control register of the crystal oscillator 40 to be calibrated, that is, the final configuration value of the control register of the crystal oscillator to be calibrated is the value obtained by rounding (a + b)/2. The invention avoids the situation that the calibration cannot be finished because the counting value and the target calibration value in the clock comparison process are always unequal due to clock deviation in the traditional method.

In some embodiments of the present invention, the increase or decrease of the number of approximations may be weighted according to the requirements of precision and speed, for example, when the precision requirement is high or the speed requirement is not high, the minimum step size may be adjusted to the fifth step size N/16, … or the lth step size N/2L-1And on the contrary, when the precision requirement is not high or the speed requirement is high, the minimum step length can be adjusted to the third step length N/4, and the final configuration value is used for solving the average value by using the initial value to be calibrated corresponding to the final 2-3 step lengths. In the embodiment of the present invention, two adjacent step lengths may not be halved, and it is only necessary to satisfy that the latter step length is smaller than the former step length, which falls into the protection scope of the present invention. The technical personnel in the field can make the allocation according to the process requirements, the above schemes are all in the protection scope of the invention, and the invention has strong adaptability to various process deviations through the flexible alternatives.

The clock comparison module 10 of the invention can realize calibration only by a few comparators and only partial addition and subtraction devices in the step length control module 20, and can realize calibration only by maintaining state machine jump according to the clock comparison result in the state control module 30, the whole on-chip crystal oscillator calibration is relatively simple to realize, and in the adjustment of successive approximation, even if the clock is accidentally interfered at a certain time to cause the error of the comparison result, the on-chip crystal oscillator calibration can be corrected in the next step, thereby having certain fault-tolerant capability.

Specifically, the clock comparison module 10 of the present invention defines a counter and a comparator driven by a reference clock and a clock to be calibrated. The state control module 30 comprises a control and successive approximation algorithm implementation module, and generates a step control signal by detecting the result of the clock comparison module 10. The step length control module 20 adjusts the step length according to the control of the state control module 30, outputs the step length to the crystal oscillator 40 to be calibrated, and adjusts the frequency of the crystal oscillator. The state control module 30 controls the states of the respective calibrations and implements the state transitions of the successive approximation algorithm as shown in fig. 3. The algorithm is realized by the following steps:

at the beginning of calibration, there is some initial value in the control register of the crystal oscillator 40 to be calibrated. After receiving the calibration start instruction, starting a clock comparison, if the count value is greater than the target value, which indicates that the clock to be calibrated is too fast, adjusting the clock to be calibrated downwards by a larger step length N on the basis of the initial value of the control register of the crystal oscillator 40 to be calibrated, and if the count value is less than the target value, which indicates that the clock to be calibrated is too slow, adjusting the clock to be calibrated upwards by a larger step length N. The following steps continue the following process by taking the example that the count value is greater than the target value, and the process that the count value is less than the target value is opposite to the process that the count value is less than the target value.

And after the step length N is used for downward adjustment, performing clock comparison again, if the counting value is still larger than the target value, continuously adjusting the crystal oscillator frequency by the step length N downward until the counting value is smaller than the target value, and then entering the step 3. In the process, if the adjusting register value overflows, the calibration is finished by using a failure identifier.

After the adjustment in step 2, the crystal oscillator frequency is adjusted upwards by the step length N/2, the clock comparison is performed again, if the counting value is still smaller than the target value, the crystal oscillator frequency is continuously adjusted upwards by the step length N/2 until the counting value is larger than the target value, and then the step 4 is performed. In the process, if the adjusting register value overflows, the calibration is finished by using a failure identifier.

After the adjustment in step 3, the crystal oscillator frequency is adjusted downwards by the step length N/4, the clock comparison is performed again, if the counting value is still larger than the target value, the crystal oscillator frequency is continuously adjusted downwards by the step length N/4 until the counting value is smaller than the target value, and the step 5 is entered. In the process, if the adjusting register value overflows, the calibration is finished by using a failure identifier.

After the adjustment of the step 4, the register calibration value of the step 4 is saved, the crystal oscillator frequency is adjusted upwards by the step length N/8, the clock comparison is carried out again, if the counting value is still smaller than the target value, the crystal oscillator frequency is continuously adjusted upwards by the step length N/8 until the counting value is larger than the target value, and the register value is saved and the step 6 is carried out. In the process, if the adjusting register value overflows, the calibration is finished by using a failure identifier.

In step 6, the stored register value of step 4 and the stored register value of step 5 are averaged to obtain an average value, which is used as a final configuration value of the calibration register.

The invention can realize the automatic calibration of the chip oscillator, and can find the effective value meeting the requirement in a certain range after successive approximation. The invention avoids the situation that the calibration cannot be finished because the counting value and the target value in the clock comparison process are always unequal due to clock deviation in the traditional method. The invention can balance and increase or decrease the approximation times according to the requirements of precision and speed, and has strong adaptability to various process deviations. In the implementation of the invention, the clock comparison module 10 only needs a few comparators, only needs part of the adder-subtractor in the step length generation module, and can realize the jump of the state machine through the clock comparison result in the state control. The above scheme can increase or decrease the number of step adjustment, such as increasing the adjustment of N/16 and N/32 step, thereby achieving higher precision, or decrease the number of step adjustment, and increase the calibration speed.

The invention provides an automatic calibration method of an on-chip crystal oscillator based on a successive approximation algorithm, which comprises the steps of firstly adjusting based on a larger step length so as to accelerate the speed of approaching an effective value, then gradually adjusting based on a smaller step length so as to increase the adjustment precision, and obtaining a value near a target value after adjusting for a plurality of times. The step length of the invention can be correspondingly increased or decreased through different states, thereby reducing the complexity of hardware realization.

In summary, the above embodiments have described the different configurations of the on-chip oscillator calibration circuit and the calibration method in detail, and it is understood that the present invention includes but is not limited to the configurations listed in the above embodiments, and any modifications based on the configurations provided in the above embodiments are within the scope of the present invention. One skilled in the art can take the contents of the above embodiments to take a counter-measure.

The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. For the system disclosed by the embodiment, the description is relatively simple because the system corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description.

The above description is only for the purpose of describing the preferred embodiments of the present invention, and is not intended to limit the scope of the present invention, and any variations and modifications made by those skilled in the art based on the above disclosure are within the scope of the appended claims.

15页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种集成VCO式鉴相器及环内混频式锁相环电路

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类