Automatic frequency correction circuit and automatic frequency correction method of oscillator

By inputting multiple pre-scan data within a selected range of the oscillator, identifying and adjusting the input data to correct the frequency, the problem of correction failure caused by differences in the operating curves of different oscillators is solved, and fast and efficient frequency correction is achieved.

CN120979425APending Publication Date: 2025-11-18NUVOTON
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411130871.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2024-05-17
Filing Date
2024-08-16
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing automatic calibration circuits struggle to effectively correct clock frequencies when faced with differences in the operating curves of different oscillators, leading to calibration failures or excessively long calibration times.

Method used

Multiple pre-scan data are input within a selected range of the oscillator through a pre-scanning circuit to identify the oscillator's operating curve. The input data is then adjusted based on the operating curve and the target frequency using a frequency code correction circuit. A binary approximation method is employed to identify frequency breakpoints and corresponding frequency switching data, thereby achieving precise correction.

Benefits of technology

Accurate identification of the oscillator's operating curve characteristics improves the success rate and efficiency of frequency correction, enabling flexible adaptation to the characteristics of different oscillators and achieving fast and efficient frequency correction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120979425A_ABST
    Figure CN120979425A_ABST
Patent Text Reader

Abstract

The better embodiment of the invention relates to an automatic frequency correction circuit and an automatic frequency correction method of an oscillator. The method comprises the following steps: firstly, dividing a plurality of pre-scanning data in a selected range, and respectively inputting the pre-scanning data into an oscillator to obtain corresponding output frequencies; a working curve of the oscillator is obtained according to the pre-scanning data and the output frequency, and the type of the working curve is determined by the sign of the difference value of the adjacent output frequencies. And if the working curve is of the third type, further scanning between adjacent digital data is needed to find frequency breakpoints and corresponding frequency switching digital data. Digital data of the target frequency are input and compared with the actual oscillation clock frequency generated by the oscillator; and finally, continuously adjusting the input digital data according to the working curve, the target frequency and the actual frequency until the actual frequency reaches the target frequency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a technique for frequency correction of an oscillator, and more particularly to an automatic frequency correction circuit and method for an oscillator. Background Technology

[0002] Generally, calibration is required when a new clock generator is installed in a circuit. This is because high-speed RC oscillators (HIRC) typically generate a corresponding clock frequency based on the input digital data. An HIRC is an internal high-speed resistor-capacitor oscillator that can generate clock frequencies of different frequencies based on the input digital data. However, the actual output clock frequency often deviates from the expected frequency; for example, inputting 40MHz data might result in an actual output of 38MHz. This deviation can be caused by various factors, such as component manufacturing tolerances and temperature variations affecting the oscillator's frequency stability. Therefore, calibration is necessary after replacing the clock generator to ensure that the output clock frequency matches the system requirements.

[0003] An automatic calibration circuit can solve this problem. Figure 1 The diagram shows a circuit block diagram of a prior art automatic correction circuit. Please refer to it. Figure 1 This automatic calibration circuit includes a counter 101, a judgment unit 102, and a high-speed clock generator 103. The counter 101 automatically generates data, and the judgment unit 102 measures the clock frequency from the clock signal of the high-speed clock generator 103 and performs calibration according to the frequency that this data should correspond to. If the clock frequency is normal, no calibration is needed; however, if the frequency differs from the expected frequency, the data needs to be corrected to the correct frequency, and the adjusted data is recorded. This ensures that the clock frequency output by the system is accurate and meets the system requirements. However, not all clock generators are so simple. In fact, the operating profile of each clock generator may be different. Some oscillators increase frequency with increasing data, while others decrease frequency with increasing data. This difference in operating profiles presents some challenges for the automatic calibration circuit.

[0004] Automatic calibration circuits that rely solely on counters for data input may fail to correct or require more time when the operating curve is opposite to the correction direction. For example, for a given oscillator, increasing the input data might cause a frequency decrease, while the automatic calibration circuit might interpret this as an increase, creating a contradiction and preventing effective correction. To address this issue, automatic calibration circuits need more intelligent algorithms capable of recognizing the operating curve characteristics of different clock generators and adopting appropriate correction strategies based on the specific circumstances. Therefore, previous technologies have some shortcomings, necessitating the search for better solutions. Summary of the Invention

[0005] Embodiments of the present invention provide an automatic frequency correction circuit and an automatic frequency correction method for an oscillator, which obtains the corresponding operation profile before correcting the clock frequency of the oscillator.

[0006] Embodiments of the present invention provide an automatic frequency correction circuit and an automatic frequency correction method for an oscillator, for providing a corrected oscillator frequency correction strategy.

[0007] An embodiment of the present invention provides an automatic frequency correction circuit for calibrating an oscillator. This automatic frequency correction circuit includes a pre-scan circuit and a frequency code correction circuit. The pre-scan circuit inputs multiple pre-scan data into the oscillator and detects the frequencies of multiple oscillation clocks output by the oscillator, thereby obtaining an operating curve of the oscillator. The frequency code correction circuit inputs correction data into the oscillator, compares the frequency of the oscillation clock generated by the oscillator with a target frequency, and adjusts the correction data according to the operating curve and the comparison result until the oscillator generates an oscillation clock with the target frequency.

[0008] In the above embodiment, the frequency corresponding to the Kth scan data minus the frequency corresponding to the (K+1)th scan data is a first result, and the frequency corresponding to the (K+1)th scan data minus the frequency corresponding to the (K+2)th scan data is a second result. When the first result and the second result are not equal in sign, the pre-scan circuit uses the scan data between the (K+1)th and (K+2)th scan data to input to the oscillator to measure a frequency breakpoint and a corresponding frequency switching data, where K is a natural number greater than 0.

[0009] Another embodiment of the present invention provides an automatic frequency correction method for correcting the frequency of an oscillator. The automatic frequency correction method includes: inputting multiple pre-scan data into the oscillator to obtain the frequencies of a plurality of oscillation clocks; subtracting the frequency corresponding to the (K+1)th pre-scan data from the frequency corresponding to the Kth pre-scan data to obtain a first result; subtracting the frequency corresponding to the (K+1)th pre-scan data from the frequency corresponding to the (K+2)th pre-scan data to obtain a second result; when the signs of the first result and the second result are not equal, inputting the pre-scan data between the (K+1)th and (K+2)th pre-scan data into the oscillator to measure the frequency of the oscillation clock, identifying a frequency breakpoint and a corresponding frequency switching digital data; inputting a correction digital data into the oscillator, comparing the frequency of the oscillation clock generated by the oscillator with a target frequency, and adjusting the correction data according to the operating curve and a comparison result until the oscillator generates the oscillation clock with the target frequency, wherein K is a natural number greater than 0.

[0010] In summary, the automatic frequency correction circuit and method for oscillators proposed in the embodiments of the present invention can accurately identify the operating curve characteristics of the oscillator. By inputting multiple pre-scan data within a selected range, multiple corresponding output frequencies are obtained, thereby analyzing the specific operating curve of the oscillator. Based on the frequency change relationship corresponding to the Kth, K+1th, and K+2th scan data, it can be determined whether the oscillator belongs to the first operating curve (frequency increases with increasing data), the second operating curve (frequency decreases with increasing data), or the third operating curve (the relationship between data and frequency is not fixed). This accurate operating curve identification lays the foundation for subsequent frequency correction. Furthermore, the embodiments of the present invention adopt different correction strategies for different operating curve characteristics. For the third operating curve, the embodiments of the present invention use a pre-scan circuit to further subdivide the scan data between the K+1th and K+2th scan data to find frequency breakpoints and corresponding frequency switching data. This can more accurately locate the digital data corresponding to the target frequency, significantly improving the success rate of correction. For the first and second operating curves, the embodiments of the present invention can directly adjust the input data according to the operating curve characteristics to achieve the target frequency.

[0011] To further understand the technology, means, and effects of the present invention, reference can be made to the following detailed description and accompanying drawings, which will provide a thorough and concrete understanding of the purpose, features, and concepts of the present invention. However, the following detailed description and accompanying drawings are for reference and illustration only and are not intended to limit the present invention. Attached Figure Description

[0012] The accompanying drawings are provided to enable those skilled in the art to further understand the invention, and are incorporated in and constitute a part of the specification of the invention. The drawings illustrate exemplary embodiments of the invention and are used together with the specification to explain the principles of the invention.

[0013] Figure 1 The diagram shows a circuit block diagram of an autocorrect circuit of the prior art.

[0014] Figure 2 The diagram shows an automatic frequency correction circuit for an oscillator according to a preferred embodiment of the present invention.

[0015] Figure 3 The diagram illustrates the oscillation frequency versus digital data operation curve of an oscillator according to a preferred embodiment of the present invention.

[0016] Figure 4 The diagram illustrates the oscillation frequency versus digital data operation curve of an oscillator according to a preferred embodiment of the present invention.

[0017] Figure 5 The diagram illustrates the oscillation frequency versus digital data operation curve of an oscillator according to a preferred embodiment of the present invention.

[0018] Figure 6 The diagram shows a circuit block diagram of a frequency code correction circuit 202 of an oscillator automatic frequency correction circuit according to a preferred embodiment of the present invention.

[0019] Figure 7 The flowchart illustrates an automatic frequency correction method for an oscillator according to a preferred embodiment of the present invention.

[0020] Figure 8 The diagram illustrates a sub-step flowchart of step S704 of the automatic frequency correction method for an oscillator according to a preferred embodiment of the present invention. Detailed Implementation

[0021] Reference will now be made in detail to exemplary embodiments of the invention, which are illustrated in the accompanying drawings. Where possible, the same component reference numerals are used in the drawings and description to refer to the same or similar parts. Furthermore, the exemplary embodiments are merely one way of implementing the design concept of the invention, and the following examples are not intended to limit the invention.

[0022] Figure 2 The diagram illustrates an automatic frequency correction circuit for an oscillator according to a preferred embodiment of the present invention. Please refer to... Figure 2The automatic frequency correction circuit of this oscillator includes a pre-scan circuit 201 and a frequency code correction circuit 202. To enable those skilled in the art to understand the embodiments of the invention, an oscillator 203 is additionally illustrated herein. The pre-scan circuit 201 is used to divide a selected range within the specifications of the oscillator 203 into a plurality of pre-scan data. For example, the oscillator 203 is an 8-bit digitally controlled oscillator, and its data selection range is 00000000 (00h) to 11111111 (FFh). In this embodiment, for example, five pre-scan data points are selected from 00h to FFh: 00, 63 (3Fh), 127 (7Fh), 191 (BFh), and 255 (FFh). Figure 3 As shown, Figure 3 The diagram illustrates the operation profile of the oscillator's oscillation frequency versus data, representing a preferred embodiment of the present invention. The five pre-scan data points 00, 63 (3Fh), 127 (7Fh), 191 (BFh), and 255 (FFh) are input to, for example... Figure 3 By using the oscillator, the clock frequency corresponding to the five pre-scan data points can be obtained. This allows for a rough understanding of the relationship between frequency and clock, which is the operating curve 301 of the oscillator 203. Subsequently, the pre-scan circuit 201 provides the information from the operating curve 301 to the frequency code correction circuit 202.

[0023] The frequency code correction circuit 202 can then follow the aforementioned operating curve, which in this embodiment is an upward curve where the input data is positively correlated with the clock frequency. It inputs data at the target frequency, compares it to the corresponding frequency of the generated oscillating clock, and adjusts the data according to the difference between the operating curve (the positively correlated upward curve), the target frequency, and the actual frequency of the oscillating clock until the corresponding frequency of the oscillating clock reaches the target frequency. For example, suppose the input data corresponds to a target frequency of 40MHz, but the actual clock frequency output by the oscillator 203 is 38MHz. In this case, the operating curve 301 provided by the pre-scan circuit 201 shows that the data is positively correlated with the clock frequency. Therefore, the frequency code correction circuit 202 will increase the input data until the clock frequency reaches 40MHz, record the data corresponding to the 40MHz clock frequency, and complete the correction of the 40MHz data.

[0024] Figure 4 The diagram illustrates the oscillation frequency versus data operation curve of an oscillator according to a preferred embodiment of the present invention. Please refer to... Figure 4 Similarly, suppose in another design, oscillator 203 is replaced with... Figure 4An 8-bit digitally controlled oscillator is input to, for example, the five pre-scan data points 00, 63 (3Fh), 127 (7Fh), 191 (BFh), and 255 (FFh). Figure 4 By using the oscillator, the clock frequency corresponding to the five pre-scan data points can be obtained. The relationship between frequency and clock frequency can then be roughly obtained, which is the operating curve 301 of the oscillator 203. The pre-scan circuit 201 then provides the frequency code correction circuit 202 with the information from the operating curve 301. In this embodiment, the input data is a decreasing curve that is inversely correlated with the clock frequency. Therefore, following the above operation, frequency correction, for example, to 40MHz can be achieved by correcting the input data.

[0025] Figure 5 The diagram illustrates the oscillation frequency versus data operation curve of an oscillator according to a preferred embodiment of the present invention. Please refer to... Figure 5 Similarly, suppose in another design, oscillator 203 is replaced with... Figure 5 An 8-bit digitally controlled oscillator is input to, for example, the five pre-scan data points 00, 63 (3Fh), 127 (7Fh), 191 (BFh), and 255 (FFh). Figure 5 The oscillator can then obtain the clock frequencies corresponding to the five pre-scan data. However, in this embodiment, the frequencies generated by adjacent pre-scan data are subtracted to obtain the results of mutual subtraction. That is, the frequency corresponding to pre-scan data 63 (3Fh) is subtracted from the frequency corresponding to pre-scan data 00 to obtain the first result 501; the frequency corresponding to pre-scan data 127 (7Fh) is subtracted from the frequency corresponding to pre-scan data 63 (3Fh) to obtain the second result 502; the frequency corresponding to pre-scan data 191 (BFh) is subtracted from the frequency corresponding to pre-scan data 127 (7Fh) to obtain the third result 503; and the frequency corresponding to pre-scan data 255 (FFh) is subtracted from the frequency corresponding to pre-scan data 191 (BFh) to obtain the fourth result 504.

[0026] Please return Figure 3 , Figure 4 In the above embodiments, the same four subtraction results will be generated. These are used to determine... Figure 3 The reason why the working curve is a positively correlated upward curve is that, Figure 3 In this context, every subtraction result has the same sign (positive or negative), indicating that the larger the data, the greater the frequency. This allows us to obtain... Figure 3 The working curve is a positively correlated upward curve. The same logic applies to judging... Figure 4 The reason why the working curve is a negatively correlated downward curve is that, Figure 4In this context, every subtraction result has the same sign (both positive and negative), indicating that the larger the data, the lower the frequency. This allows us to obtain... Figure 4 The working curve is a negatively correlated downward curve.

[0027] Please return Figure 5 In the above embodiment, among the four results of mutual subtraction, the first result 501 is positive; the second result 502 is positive; the third result 503 is negative; and the fourth result 504 is positive. Therefore, in this embodiment, the relationship between frequency and clock is obtained as an interrupt-type working curve, and the frequency switching data corresponding to the frequency breakpoint is between pre-scan data 191 (BFh) and pre-scan data 127 (7Fh). At this time, the pre-scan circuit 201 will further perform a detailed scan between pre-scan data 191 (BFh) and pre-scan data 127 (7Fh) to find the frequency switching data 505 corresponding to the frequency breakpoint. Subsequently, the pre-scan circuit 201 provides the frequency code correction circuit 202 with the aforementioned operating curve information. Specifically, the frequency switching data from pre-scan data 00 to the frequency breakpoint shows an upward trend, and the frequency switching data at the breakpoint corresponds to the highest frequency. Furthermore, the frequency switching data +1 from the breakpoint to pre-scan data 255 (FFh) shows an upward trend, and the frequency switching data +1 at the breakpoint corresponds to the lowest frequency. Therefore, the frequency code correction circuit 202 can also perform frequency correction, for example, at 40MHz, by correcting the input data.

[0028] In the above embodiments, the method by which the pre-scan circuit 201 performs a detailed scan between pre-scan data 191 (BFh) and pre-scan data 127 (7Fh) can be, for example, a binary approximation method. For instance, the median 159 (9Fh) of the pre-scan data 191 (BFh) and pre-scan data 127 (7Fh) is taken as the pre-scan data, input to the oscillator 203, and the clock frequency is measured; then, the clock frequency is subtracted from the frequency corresponding to the pre-scan data 127 (7Fh) to obtain a subtraction result; finally, it is determined whether the sign of this subtraction result is the same as that of the second result 502. If the signs are the same, it means that the frequency switching data corresponding to the frequency breakpoint is between the median 159 (9Fh) and the pre-scan data 191 (BFh). At this time, the median 175 (AFh) is taken between the median 159 (9Fh) and the pre-scan data 191 (BFh), and the second result is replaced by the subtraction of the previous median 159 (9Fh) and the pre-scan data 127 (7Fh). The above operation is continued until the frequency breakpoint and the corresponding frequency switching data are found.

[0029] Similarly, if the signs are different, it means that the frequency breakpoint is between the pre-scan data 127 (7Fh) and the median 159 (9Fh). In this case, continue to take the median 143 (8Fh) between the pre-scan data 127 (7Fh) and the median 159 (9Fh), and continue the above operation until the frequency switching data corresponding to the frequency breakpoint is found.

[0030] Similarly, another method involves taking the median 159 (9Fh) of both the pre-scan data 191 (BFh) and the pre-scan data 127 (7Fh) as pre-scan data, inputting it into the oscillator 203, and measuring the clock frequency. Then, subtract the frequency corresponding to the higher pre-scan data 191 (BFh) from this clock frequency to obtain a subtraction result. Finally, determine if this subtraction result has the same sign as the third result 503. If the signs are different, it indicates that the frequency switching data corresponding to the frequency breakpoint is between the median 159 (9Fh) and the pre-scan data 191 (BFh). In this case, take the median 175 (AFh) between the median 159 (9Fh) and the pre-scan data 191 (BFh), and replace the second result with the subtraction of the previous median 159 (9Fh) and the pre-scan data 127 (7Fh). Continue the above calculation until the frequency switching data corresponding to the frequency breakpoint is found.

[0031] Similarly, if the signs are the same, it means that the frequency switching data corresponding to the frequency breakpoint is between the pre-scan data 127 (7Fh) and the median 159 (9Fh). At this time, the median 143 (8Fh) is taken between the pre-scan data 127 (7Fh) and the median 159 (9Fh), and the above operation is continued until the frequency switching data corresponding to the frequency breakpoint is found.

[0032] Those skilled in the art will understand that the above approximation method can be replaced by other methods, and this invention is not limited thereto. Furthermore, the pre-scan data of the above-mentioned scanning working curve does not necessarily have to be an arithmetic progression as in this invention, but can be modified according to different designs. This invention is not limited thereto. Additionally, although the above embodiment determines whether the sign of the subtraction result is the same as the sign of the second result 502, in fact, the position of the frequency switching data corresponding to the frequency breakpoint can also be determined by whether the signs of the subtraction result and the third result 503 are the same; therefore, this invention is not limited thereto.

[0033] Figure 6 The diagram illustrates a frequency code correction circuit 202 of an oscillator's automatic frequency correction circuit according to a preferred embodiment of the present invention. Please refer to... Figure 6The frequency code correction circuit 202 includes a counting circuit 601, a judgment circuit 602, and a correction circuit 603. The counting circuit 601 uses a counter to generate data input to the oscillator 203 and increments the data value every time. The judgment circuit 602 sends the data generated by the counting circuit 601 to a lookup table 604 corresponding to the oscillator 203 to find the target frequency corresponding to the data. Simultaneously, it detects the corresponding frequency of the oscillation clock of the oscillator 203 and compares the two. If the comparison shows a match, correction is skipped. If the two do not match, for example, if the target frequency is 40MHz and the measured frequency is 38MHz, the frequency needs to be increased.

[0034] The correction circuit 603 is coupled to the judgment circuit 602 to receive the judgment result. When the judgment circuit 602 determines that the target frequency does not match the corresponding frequency of the oscillation clock, it performs frequency correction according to the difference between the target frequency and the oscillation clock and the operating curve. For example, if the oscillation clock is 38MHz, which is less than the target frequency of 40MHz, the correction circuit 603 determines the direction of data adjustment based on the received operating curve and the difference between the oscillation clock and the target frequency. In this embodiment, the correction circuit 603 includes a selection circuit 605 to select the direction of data adjustment based on the operating curve and the difference between the target frequency and the oscillation clock. For example, in the above embodiment, the difference is negative, therefore, the frequency needs to be increased. Assume the received operating curve is... Figure 3 The pattern indicates that as the data increases, the frequency also increases. Therefore, the selection circuit 605 within the correction circuit 603 selects the addition operation channel of line 1, increases the data value until the target frequency matches the corresponding frequency of the oscillation clock, and records the result to complete the correction.

[0035] Furthermore, assuming that the working curve is changed in the above embodiment... Figure 4 At this point, the difference between the operating curve and the target frequency and the oscillation clock is negative; therefore, the frequency needs to be increased. Since the operating curve is... Figure 4 This means that as the data increases, the frequency will decrease accordingly. Therefore, the selection circuit 605 in the correction circuit 603 will select the subtraction operation channel of line 2, reduce the value of the data, and increase the frequency until the target frequency matches the corresponding frequency of the oscillation clock, and record it to complete the correction.

[0036] Similarly, assuming the oscillation clock is 42MHz in the above embodiment, and the operating curve is still... Figure 3 At this point, the difference between the operating curve and the target frequency and the oscillation clock is positive; therefore, the frequency needs to be reduced. Since the operating curve is still... Figure 3This means that as the data increases, the frequency will also increase. Therefore, the selection circuit 605 in the correction circuit 603 will select the subtraction operation channel of line 2 to reduce the data value, thereby reducing the frequency, until the target frequency matches the corresponding frequency of the oscillation clock, and record it to complete the correction.

[0037] Furthermore, assuming that in the above embodiment, the oscillation clock is 42MHz and the operating curve is Figure 4 At this point, the difference between the operating curve and the target frequency and the oscillation clock is positive; therefore, the frequency needs to be reduced. Since the operating curve is... Figure 4 This indicates that as the data increases, the frequency will decrease accordingly. Therefore, the selection circuit 605 within the correction circuit 603 will select the addition operation channel of line 1, increase the data value, and decrease the frequency until the target frequency matches the corresponding frequency of the oscillation clock, and record it to complete the correction.

[0038] In addition, for interruption-type operating curves, such as Figure 5 Since the frequency switching data corresponding to the frequency breakpoint has been recorded, as long as the value of the data falls before or after the frequency switching data corresponding to the frequency breakpoint, the correction can be performed according to the above rules.

[0039] Based on the circuit block description of the above embodiments, a method for automatically correcting the frequency of an oscillator can be summarized. Figure 7 A flowchart illustrating an automatic frequency correction method for an oscillator according to a preferred embodiment of the present invention is shown. Please refer to... Figure 7 The automatic frequency correction method for this oscillator includes the following steps:

[0040] Step S701: Begin.

[0041] Step S702: Divide the data into multiple pre-scan data within a selected range. Such as the pre-scan data 00, 63 (3Fh), 127 (7Fh), 191 (BFh), 255 (FFh) mentioned above, but not limited to these.

[0042] Step S703: Input the above-mentioned multiple pre-scan data into the oscillator respectively to obtain multiple output frequencies.

[0043] Step S704: Obtain an operating curve of the oscillator based on a plurality of pre-scan data and a plurality of output frequencies.

[0044] Step S705: Calibration step. As described in the above embodiment, the counter 601 is used to input data corresponding to a target frequency to the oscillator 203, the corresponding frequency of the generated oscillation clock is compared, and the above data is adjusted according to the working curve, the target frequency, and the corresponding frequency of the oscillation clock until the corresponding frequency of the oscillation clock reaches the target frequency.

[0045] Step S706: End.

[0046] Figure 8 The diagram illustrates a sub-step flowchart of step S704 of the automatic frequency correction method for an oscillator according to a preferred embodiment of the present invention. Please refer to... Figure 8 The steps for obtaining the oscillator's operating curve based on multiple pre-scan data points and multiple output frequencies include:

[0047] Step S801: K ranges from 1 to 3 (5-2), K++. In this embodiment, there are 5 pre-scan data points. Subsequent calculations will use K, K+1, and K+2, so the value of K is between 1 and 3.

[0048] Step S802: The frequency corresponding to the Kth pre-scan data minus the frequency corresponding to the (K+1)th pre-scan data is a first result.

[0049] Step S803: The frequency corresponding to the (K+1)th pre-scan data minus the frequency corresponding to the (K+2)th pre-scan data is a second result.

[0050] Step S804: Judgment step. If the signs of any first result and second result are not equal, proceed to step S809. If the first result and second result are both of the same sign, proceed to step S805.

[0051] Step S805: Determine if K equals 3. If not, return to step S801 and continue until completion. If K already equals 3, proceed to step S806.

[0052] Step S806: Determine the sign of the sign. If the sign is positive, proceed to step S807. If the sign is negative, proceed to step S808.

[0053] Step S807: The working curve is a first working curve. That is, the working curve in which digital data is positively correlated with clock frequency.

[0054] Step S808: The operating curve is a second operating curve. That is, the operating curve inversely correlated with the digital data and the clock frequency.

[0055] Step S809: The working curve is a third working curve. Continue to step S808. That is, the working curve with frequency discontinuities in the correlation between digital data and clock frequency.

[0056] Step S810: Input the pre-scan data between the (K+1)th and (K+2)th pre-scan data before and after the frequency switching data corresponding to the frequency breakpoint into the oscillator to measure the frequency of the oscillation clock, find the frequency breakpoint and the corresponding frequency switching digital data. This step can be performed, for example, using the binary approximation method described above or other approximation methods. This invention is not limited thereto.

[0057] In summary, the automatic frequency correction circuit and method for oscillators proposed in a preferred embodiment of the present invention can accurately identify the operating curve characteristics of the oscillator. By inputting multiple pre-scan data within a selected range, multiple corresponding output frequencies are obtained, thereby analyzing the specific operating curve of the oscillator. Based on the frequency change relationship corresponding to the Kth, K+1th, and K+2th scan data, it can be determined whether the oscillator belongs to the first operating curve (frequency increases with increasing data), the second operating curve (frequency decreases with increasing data), or the third operating curve (the relationship between data and frequency is not fixed). This accurate operating curve identification lays the foundation for subsequent frequency correction. Furthermore, the embodiments of the present invention adopt different correction strategies for different operating curve characteristics. For the third operating curve, the embodiments of the present invention use a pre-scan circuit to further subdivide the scan data between the K+1th and K+2th scan data to find frequency breakpoints and corresponding frequency switching data. This allows for more precise positioning of the digital data corresponding to the target frequency, significantly improving the success rate of correction. For the first and second operating curves, embodiments of the present invention can directly adjust the input digital data according to the characteristics of the operating curves to achieve the target frequency. Therefore, it can flexibly respond to the characteristics of different oscillators, adopt targeted correction strategies, and achieve fast and efficient frequency correction.

[0058] It should be understood that the examples and embodiments described herein are for illustrative purposes only, and various modifications or changes thereto will be suggested to those skilled in the art and will be included within the spirit and scope of this application and the scope of the appended claims.

Claims

1. An automatic frequency correction circuit for calibrating an oscillator, characterized in that, The automatic frequency correction circuit includes: A pre-scan circuit inputs multiple pre-scan data into the oscillator and detects the frequencies of multiple oscillation clocks output by the oscillator, thereby obtaining a working curve of the oscillator; and A frequency code correction circuit inputs correction data to the oscillator, compares the frequency of the oscillation clock generated by the oscillator with a target frequency, and adjusts the correction data according to the operating curve and the comparison result until the oscillator generates the oscillation clock with the target frequency. Among them, the frequency corresponding to the Kth scan data minus the frequency corresponding to the (K+1)th scan data is a first result; Among them, the frequency corresponding to the (K+1)th scan data minus the frequency corresponding to the (K+2)th scan data is a second result; Where the signs of the first result and the second result are not equal, the pre-scan circuit uses the scan data between the (K+1)th scan data and the (K+2)th scan data as input to the oscillator to measure a frequency breakpoint and a corresponding frequency switching data. Where K is a natural number greater than 0.

2. The automatic frequency correction circuit according to claim 1, characterized in that, The frequency code correction circuit includes: A counting circuit generates the correction digital data and increments the value of the correction digital data at regular intervals. A judgment circuit compares the corresponding frequency of the oscillation clock of the oscillator with the target frequency; and A correction circuit, coupled to the judgment circuit, performs frequency correction based on the difference between the target frequency and the oscillation clock and the working curve, in order to find a target data corresponding to the target frequency.

3. The automatic frequency correction circuit according to claim 1, characterized in that, The correction circuit includes: A selection circuit is used to select the adjustment direction of the digital data based on the operating curve and the difference between the target frequency and the oscillation clock, wherein, When both the first result and the second result are positive, the working curve is a first working curve; when both the first result and the second result are negative, the working curve is a second working curve. When the operating curve is the first operating curve, and the difference between the oscillation clock and the target frequency is negative, the selection circuit is activated with an addition operation channel to increase the digital data. When the operating curve is the first operating curve, and the difference between the oscillation clock and the target frequency is positive, the selection circuit is activated with a subtraction operation channel to reduce the digital data. When the operating curve is the second operating curve, and the difference between the oscillation clock and the target frequency is negative, the selection circuit is activated with a subtraction operation channel to reduce the digital data. When the operating curve is the second operating curve, and the difference between the oscillation clocks and the target frequency is positive, the selection circuit activates an addition operation channel to increase the digital data. Specifically, by adjusting the correction digital data as described above, the correction circuit identifies the target data corresponding to the target frequency and records it.

4. The automatic frequency correction circuit according to claim 1, characterized in that, When the signs of the first result and the second result are not equal, the pre-scan circuit uses the scan data between the (K+1)th scan data and the (K+2)th scan data as input to the oscillator to measure the frequency breakpoint and the corresponding frequency switching data, further including: The first step: Find an intermediate pre-scan data point between the (K+1)th and (K+2)th pre-scan data points; The second step: Input the intermediate pre-scan data into the oscillator to obtain an intermediate frequency of the oscillation clock; The third step: Subtract the intermediate frequency from the frequency corresponding to the (K+2)th pre-scan data to obtain a fourth result; and Fourth step: Determine whether the sign of the fourth result is the same as that of the second result; Wherein, when the fourth result has the same sign as the second result, the intermediate frequency is set to the (K+2)th pre-scan data and the process returns to the first step; and Wherein, when the sign of the third result is different from that of the first result, the intermediate frequency is set as the K+1th pre-scan data and the process returns to the first step.

5. An automatic frequency correction method for correcting the frequency of an oscillator, characterized in that, The automatic frequency correction method includes: Multiple pre-scan data are input into the oscillator to obtain the frequencies of multiple oscillation clocks; Based on the plurality of pre-scan data and the frequencies of the plurality of oscillation clocks, an operating curve of the oscillator is obtained; The frequency corresponding to the Kth pre-scan data is subtracted from the frequency corresponding to the (K+1)th pre-scan data to obtain a first result. The frequency corresponding to the (K+1)th pre-scan data is subtracted from the frequency corresponding to the (K+2)th pre-scan data to obtain a second result. When the signs of the first result and the second result are not equal, the pre-scan data between the (K+1)th and (K+2)th pre-scan data is input to the oscillator to measure the frequency of the oscillation clock, find a frequency breakpoint and the corresponding frequency switching digital data; and Input a correction digital data to the oscillator, compare the frequency of the oscillation clock generated by the oscillator with a target frequency, and adjust the correction data according to the operating curve and the comparison result until the oscillator generates the oscillation clock with the target frequency. Where K is a natural number greater than 0.

6. The automatic frequency correction method according to claim 5, characterized in that, When both the first and second results are positive, the working curve is a first working curve; when both the first and second results are negative, the working curve is a second working curve; when the working curve is the third curve, the pre-scan circuit uses the pre-scan data between the (K+1)th and (K+2)th pre-scan data, input to the oscillator to measure the frequency of the oscillation clock, find a frequency breakpoint and a corresponding frequency switching digital data, and further includes: The first step: Find an intermediate pre-scan data point between the (K+1)th and (K+2)th pre-scan data points; The second step: Input the intermediate pre-scan data into the oscillator to obtain an intermediate frequency of the oscillation clock; A third step: Subtract the frequency corresponding to the (K+1)th pre-scan data from the intermediate frequency to obtain a third result; and subtract the intermediate frequency from the frequency corresponding to the (K+2)th pre-scan data to obtain a fourth result; and Fourth step: Determine whether the sign of the third result is the same as that of the first result; Wherein, when the sign of the third result is the same as that of the first result, the intermediate frequency is set to the (K+1)th pre-scan data and the process returns to the first step; and Wherein, when the sign of the third result is different from that of the first result, the intermediate frequency is set as the K+2th pre-scan data and the process returns to the first step.

7. The automatic frequency correction method according to claim 5, characterized in that, When the working curve is the third curve, the pre-scan circuit uses the pre-scan data between the (K+1)th and (K+2)th pre-scan data, input to the oscillator to measure the frequency of the oscillation clock, find the frequency breakpoint and the corresponding frequency switching digital data, and further includes: The first step: Find an intermediate pre-scan data point between the (K+1)th and (K+2)th pre-scan data points; The second step: Input the intermediate pre-scan data into the oscillator to obtain an intermediate frequency of the oscillation clock; The third step: Subtract the intermediate frequency from the frequency corresponding to the (K+2)th pre-scan data to obtain a fourth result; and Fourth step: Determine whether the sign of the fourth result is the same as that of the second result; Wherein, when the fourth result has the same sign as the second result, the intermediate frequency is set to the (K+2)th pre-scan data and the process returns to the first step; and Wherein, when the sign of the third result is different from that of the first result, the intermediate frequency is set as the K+1th pre-scan data and the process returns to the first step.