An in-chip clock frequency automatic calibration method and related apparatus
By using an in-chip clock frequency automatic calibration method, the oscillator frequency parameters are adjusted using a reference clock and calibration module, which solves the problems of long test time and high cost in the existing technology, and achieves the effect of simplifying the test circuit and reducing costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN INJOINIC TECH
- Filing Date
- 2020-09-28
- Publication Date
- 2026-04-21
AI Technical Summary
In existing technologies, the frequency calibration process of the internal oscillator of a chip requires frequency division and output to the outside of the chip for measurement, which results in long testing time, high cost and complex peripheral circuits.
An automatic clock frequency calibration method with an internal chip is adopted. By cooperating with a reference clock through a calibration module, the difference between the theoretical number of cycles and the actual number of cycles is calculated using a formula, and the oscillator frequency control parameters are adjusted to achieve internal frequency calibration.
It shortens calibration time, simplifies test circuits, and reduces chip testing costs.
Smart Images

Figure CN114285409B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of chip technology, specifically to a method and apparatus for automatic calibration of the clock frequency within a chip. Background Technology
[0002] The clock, as the unified conductor of sequential circuits, is an indispensable component of a chip. There are generally two methods for designing a chip's clock source. One is to use an external quartz crystal oscillator, providing the clock source through chip pins. The advantage of this method is accurate clock frequency, but it is costly. The other method is to design an oscillator circuit internally to generate the clock. The advantages of this method are high integration and low cost, but the disadvantage is that the oscillator period can vary with process deviations or voltage and temperature changes, resulting in significant individual differences in clock frequency across multiple chips. Therefore, the calibration of the internal oscillator frequency is particularly important.
[0003] like Figure 1 This describes an existing clock frequency calibration scheme. This scheme involves dividing the clock generated by the chip's internal oscillator (OSC) to the kilohertz (kHz) level and outputting it externally via a chip pin. Externally, a precise megahertz (MHz) clock is used to sample the output divided clock, calculating its actual frequency. Then, based on the direction and magnitude of the deviation between the actual and target frequencies, the internal frequency parameters are adjusted. Under the new frequency parameters, the oscillator will generate a new clock frequency, which is then measured externally again. This process is repeated until frequency calibration parameters are found that match the clock oscillator's frequency to the target frequency, completing the calibration process.
[0004] However, the applicant discovered the following drawbacks in the existing technology:
[0005] 1. When the internal oscillator frequency is high, due to the speed limitation of the chip pins, the higher frequency clock signal cannot be directly output to the outside of the chip and needs to be divided to a lower frequency before being released.
[0006] 2. When measuring a low-frequency clock outside the chip, the measurement of one cycle takes a long time because the low-frequency clock cycle is relatively long. In order to ensure the accuracy of the measurement, it is often necessary to measure multiple low-frequency clock cycles and then take the average value, which significantly increases the test time and chip test cost.
[0007] 3. The results of external measurements and calculations need to be fed back to the chip through a dedicated communication interface, which complicates the external testing circuitry. Summary of the Invention
[0008] This application provides a method and related products for automatic calibration of the internal clock frequency of a chip, which can automatically calibrate the internal clock frequency of the chip, shorten calibration time, save external test circuits, and effectively shorten chip testing time and reduce chip testing costs.
[0009] The first aspect of this application provides an automatic clock frequency calibration method for an internal chip, wherein the chip is connected to a calibrated reference clock externally, the chip includes an oscillator, a calibration module, and a parameter adjustment module, and the method includes the following steps:
[0010] The calibration module obtains the reference clock containing N. ref The reference level for each cycle;
[0011] The calibration module uses the current clock of the oscillator to calculate the width of the reference level, which includes N. o One cycle;
[0012] If the theoretical period number N os With the N o If the absolute value of the difference is greater than the set error DN, the calibration module adjusts the frequency control parameter through the parameter adjustment module. The frequency control parameter is used to change the current frequency of the oscillator; the N os Based on the reference frequency of the reference clock, the target frequency of the oscillator, and N ref Sure;
[0013] If the N os With the N o If the absolute value of the difference is less than the set error DN, the calibration module determines that the oscillator has been successfully calibrated.
[0014] The reference clock in this embodiment can be calibrated, and its clock frequency can be used by the chip for reference. The clock frequency of the reference clock can also be called the reference frequency. The reference clock can come from the clock of the oscillator of another calibrated chip, or it can come from a crystal oscillator. This embodiment does not limit the reference clock.
[0015] Furthermore, the calibration module calculates the theoretical number of cycles N of the oscillator according to the following formula. os :
[0016] N os =(f osc / f ref )*N ref ;
[0017] Among them, f osc f is the target frequency of the oscillator. ref The reference frequency is the reference clock frequency.
[0018] Furthermore, after the calibration module adjusts the frequency control parameters through the parameter adjustment module, the method further includes: the calibration module continuing to perform the process of acquiring the reference clock containing N... ref The step of determining the reference level for each cycle, or continuing to execute the step of statistically analyzing the reference level within the width of N cycles using the current clock of the oscillator. o Each cycle consists of steps.
[0019] Furthermore, if the theoretical period number N os With the N o If the absolute value of the difference is greater than the set error DN, the calibration module adjusts the frequency control parameters through the parameter adjustment module, including:
[0020] If N O -N OS >DN, the calibration module increases the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment module, so as to reduce the current frequency of the oscillator;
[0021] If N OS -N O >DN, the calibration module reduces the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment module, thereby increasing the current frequency of the oscillator.
[0022] Furthermore, the so-called N O -N OS >DN, after the calibration module increases the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment module to reduce the current frequency of the oscillator, the method further includes:
[0023] If N OS -N O >DN, the calibration module determines that the oscillator calibration failed.
[0024] Furthermore, if N OS -N O >DN, after the calibration module reduces the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment module to increase the current frequency of the oscillator, the method further includes:
[0025] If N O -N OS >DN, the calibration module determines that the oscillator calibration failed.
[0026] Furthermore, the method also includes:
[0027] When the frequency control parameter is increased to its maximum, if N O -N OS >DN, the calibration module determines that the oscillator calibration has failed;
[0028] When the frequency control parameter is reduced to its minimum, if N OS -N O >DN, the calibration module determines that the oscillator calibration failed.
[0029] Furthermore, the N ref Determine according to the following formula:
[0030] N ref ≥f ref / [β*(1-α)*f osc ];
[0031] Among them, f osc f is the target frequency of the oscillator. ref α is the reference frequency of the reference clock, α is the deviation error between the current frequency of the oscillator and the target frequency, and β is the statistical error of the calibration module in calculating the reference level using the current clock of the oscillator.
[0032] Furthermore, the set error DN is determined according to the following formula:
[0033] DN = N ref *f osc *γ / f ref ;
[0034] Among them, f osc f is the target frequency of the oscillator. ref γ is the reference frequency of the reference clock, and γ is the frequency adjustment accuracy of the oscillator.
[0035] Furthermore, the calibration module acquires the reference clock containing N ref Before the reference level for each cycle, the method further includes:
[0036] The calibration module receives a calibration start signal, which is used to instruct the calibration module to enter a waiting state from an idle state.
[0037] After a preset waiting time, the calibration module switches from the waiting state to the calibration state.
[0038] Further, after the calibration module increases the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment module to reduce the current frequency of the oscillator, the method includes:
[0039] The calibration module enters the waiting state.
[0040] Further, after the calibration module reduces the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment module to increase the current frequency of the oscillator, the method includes:
[0041] The calibration module enters the waiting state.
[0042] Furthermore, after the calibration module determines that the oscillator has been successfully calibrated, the method further includes:
[0043] The calibration module enters the idle state.
[0044] Furthermore, after the calibration module determines that the oscillator calibration has failed, the method further includes:
[0045] The calibration module enters the idle state.
[0046] Furthermore, the calibration module acquires the reference clock containing N ref The calibration module uses the current clock of the oscillator to calculate the reference level, which contains N cycles within its width. o Each cycle includes:
[0047] The calibration module uses the reference clock to count the N values contained within the width of the reference level. ref Each cycle, using the current clock of the oscillator, counts the N values contained within the width of the reference level. o One cycle.
[0048] Furthermore, before the calibration module increases the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment module to reduce the current frequency of the oscillator, the method further includes:
[0049] If N O -N OS >DN, the calibration module determines N O -N OS Is it less than the first threshold?
[0050] In N O -N OS If the value is less than the first threshold, the calibration module performs the step of increasing the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment module;
[0051] Before the calibration module reduces the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment module to increase the current frequency of the oscillator, the method further includes:
[0052] If N OS -N O >DN, the calibration module determines N OS -N O Is it less than the second threshold?
[0053] In N OS -N O If the value is less than the second threshold, the calibration module performs the step of reducing the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment module.
[0054] Furthermore, the method also includes:
[0055] In N O -N OS If the difference is greater than the first threshold, the calibration module determines the value of N based on the mapping from the difference set to the minimum adjustable unit number set. O -N OS The corresponding N smallest adjustable units, where N is greater than or equal to 2;
[0056] The calibration module increases the current frequency parameter of the oscillator by the N target adjustable units through the parameter adjustment module, thereby reducing the current frequency of the oscillator;
[0057] In N OS -N O If the difference is greater than the second threshold, the calibration module determines the value of N based on the mapping from the difference set to the minimum adjustable unit number set. OS -N O The corresponding M minimum adjustable units, wherein M is greater than or equal to 2;
[0058] The calibration module reduces the current frequency parameter of the oscillator by the M target adjustable units through the parameter adjustment module, thereby increasing the current frequency of the oscillator;
[0059] The set of differences includes at least two differences, and the set of minimum adjustable unit quantities includes at least two minimum adjustable unit quantities; the mapping from the at least two differences to the at least two minimum adjustable unit quantities is a monotonically increasing function.
[0060] In a second aspect, the present invention provides a chip comprising an oscillator, a calibration module and a parameter adjustment module, wherein the chip is externally connected to a calibrated reference clock;
[0061] The calibration module is used to obtain the reference clock containing N ref The reference level for each cycle;
[0062] The calibration module is further configured to use the current clock of the oscillator to calculate the width of the reference level, which includes N. o One cycle;
[0063] The calibration module is also used to perform calibration on theoretical cycles N. os With the N o If the absolute value of the difference is greater than the set error DN, the frequency control parameter is adjusted by the parameter adjustment module. The frequency control parameter is used to change the current frequency of the oscillator; the N os Based on the reference frequency of the reference clock, the target frequency of the oscillator, and N ref Sure;
[0064] The calibration module is also used in the N os With the N o If the absolute value of the difference is less than the set error DN, the oscillator is determined to be successfully calibrated.
[0065] In a third aspect, the present invention provides a calibration module for an on-chip clock frequency, wherein the chip is externally connected to a calibrated reference clock, the chip includes an oscillator, the calibration module, and a parameter adjustment module, the calibration module comprising:
[0066] Acquisition unit, used to acquire the reference clock containing N ref The reference level for each cycle;
[0067] A statistics unit is used to count the width of the reference level containing N using the current clock of the oscillator. o One cycle;
[0068] The parameter adjustment unit is used to adjust the theoretical number of cycles N. os With the N o If the absolute value of the difference is greater than the set error DN, the frequency control parameter is adjusted by the parameter adjustment module. The frequency control parameter is used to change the current frequency of the oscillator; the N os Based on the reference frequency of the reference clock, the target frequency of the oscillator, and N ref Sure;
[0069] Determining unit, used in the N os With the N o If the absolute value of the difference is less than the set error DN, the oscillator is determined to be successfully calibrated.
[0070] In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method described in the first aspect of the present invention.
[0071] The present invention has the following main advantages:
[0072] The present invention, by adopting the above-described technical solution, compares N os With N o The calibration success is determined by whether the absolute value of the difference is greater than the set error DN. Only a calibrated reference clock needs to be connected to the chip to complete the automatic calibration of the chip's internal clock frequency, which shortens the calibration time. No external test circuit is required, which simplifies the chip test circuit and thus effectively shortens the chip test time and reduces the chip test cost. Attached Figure Description
[0073] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0074] Figure 1 This is a schematic diagram illustrating the principle of existing in-chip clock frequency calibration methods;
[0075] Figure 2 This is a schematic diagram of the structure of a chip provided in an embodiment of this application;
[0076] Figure 3 This is a schematic diagram showing the number of cycles included in the width of the current clock statistical reference level of a reference clock and oscillator provided in an embodiment of this application;
[0077] Figure 4 This is a schematic flowchart of an automatic on-chip clock frequency calibration method provided in an embodiment of this application;
[0078] Figure 5 This is a flowchart illustrating another method for automatic calibration of in-chip clock frequency provided in an embodiment of this application;
[0079] Figure 6 This is a schematic diagram of the state changes of a calibration module provided in an embodiment of this application;
[0080] Figure 7 This is a schematic diagram of the structure of an in-chip clock frequency calibration module provided in an embodiment of this application. Detailed Implementation
[0081] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0082] The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0083] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.
[0084] In the embodiments of this application, please refer to Figure 2 , Figure 2 This is a schematic diagram of the structure of a chip provided in an embodiment of this application, such as... Figure 2 As shown, the chip 200 includes an oscillator 201, a calibration module 202, and a parameter adjustment module 203.
[0085] The calibration module 202 is used to obtain the reference clock containing N ref The reference level for each cycle;
[0086] The calibration module 202 is further configured to use the current clock of the oscillator 201 to calculate the width of the reference level containing N. o One cycle;
[0087] The calibration module 202 is also used to perform calibration on theoretical cycles N. os With the N o If the absolute value of the difference is greater than the set error DN, the frequency control parameter is adjusted by the parameter adjustment module 203. The frequency control parameter is used to change the current frequency of the oscillator 201; the N osBased on the reference frequency of the reference clock, the target frequency of the oscillator 201, and the N ref Sure;
[0088] The calibration module 202 is also used in the N os With the N o If the absolute value of the difference is less than the set error DN, the oscillator 201 is determined to be successfully calibrated.
[0089] The oscillator 201 can be an RC oscillator 201, an LC oscillator 201, etc. An oscillator 201 generally includes a capacitor, and may also include one or a combination of resistors and inductors. An oscillator 201 is an energy conversion device that can convert direct current (DC) energy into alternating current (AC) energy with a certain frequency. An oscillator 201 is an electronic component used to generate repetitive signals (such as sine wave signals, square wave signals, etc.), and the circuit it forms is called an oscillation circuit. An oscillator 201 is an electronic circuit or device that can convert DC power into an AC signal output with a certain frequency. There are many types of oscillators 201; according to the oscillation excitation method, they can be divided into self-excited oscillators 201 and externally excited oscillators 201; according to the circuit structure, they can be divided into RC oscillators 201 and inductor-capacitor oscillators 201, etc.
[0090] For example, the reference clock generates N ref The reference level for each cycle can be either a periodic square wave level signal or a periodic sine wave level signal. The current clock of oscillator 201 can be used to statistically determine the N values contained within the width of the reference level by generating the periodic square wave level signal or the sine wave level signal. o One cycle. The reference clock and the current clock of oscillator 201 generate the same type of level signal, such as periodic square wave level signal or periodic sine wave level signal.
[0091] It should be noted that the oscillator 201 in this application is an oscillator 201 located inside the chip, which is different from a crystal oscillator 201. A crystal oscillator 201 is large in size and consumes a lot of power, making it impossible to place inside the chip. A crystal oscillator 201 can be located outside the chip.
[0092] The calibration module 202 is used to calibrate the clock frequency of the oscillator 201. For example, if the target frequency of the oscillator 201 is 2.4 MHz, then the calibration module 202 is to calibrate the clock frequency of the oscillator 201 to 2.4 MHz.
[0093] The parameter adjustment module 203 is used to adjust the current frequency of the oscillator 201. Specifically, the parameter adjustment module 203 can change the current frequency of the oscillator 201 by adjusting the component parameters of the oscillator 201. For example, if the oscillator 201 is an RC oscillator 201, the parameter adjustment module 203 can change the current frequency of the oscillator 201 by adjusting the values of the resistor and capacitor of the oscillator 201; if the oscillator 201 is an LC oscillator 201, the parameter adjustment module 203 can change the current frequency of the oscillator 201 by adjusting the values of the inductor and capacitor of the oscillator 201.
[0094] Due to variations in the electronic components inside oscillator 201, such as component aging and manufacturing processes, as well as the influence of environmental factors like temperature and humidity, the clock frequency of oscillator 201 may drift, deviating from the previously set target frequency. Therefore, the clock frequency of oscillator 201 needs to be calibrated.
[0095] The reference clock in this embodiment can be calibrated, and its clock frequency can be used by the chip for reference. The clock frequency of the reference clock can also be called the reference frequency. The reference clock can come from the clock of the oscillator 201 of another calibrated chip, or it can come from the crystal oscillator 201. This embodiment does not limit the reference clock.
[0096] The reference clock can generate a segment containing N ref The reference level is for each cycle, and the width of the reference level is N. ref *f ref f ref This is the reference frequency. For example, if the clock frequency of the reference clock (i.e., the reference frequency) is 4MHz, N ref If the value is 10000, then the width of the reference level is 2.5 milliseconds (ms).
[0097] The calibration module 202 uses the current clock of the oscillator 201 to calculate the width of the reference level, which includes N. o For example, if the width of the reference level is 2.5ms, and the current clock frequency of oscillator 201 (i.e., the current frequency of oscillator 201) is 1.95MHz (in fact, calibration module 202 does not know the magnitude of the current frequency of oscillator 201), then the current clock of oscillator 201 counts N cycles within the width of the reference level. o =2.5*10 -3 *1.95*10 6 = 4875 cycles.
[0098] For details, please see Figure 3 , Figure 3This is a schematic diagram showing the number of cycles included in the width of the current clock statistical reference level of a reference clock and oscillator provided in an embodiment of this application. Figure 3 Taking a square wave signal as an example, within the same reference level width (2 microseconds), the reference clock (reference frequency 4MHz) generates N. ref =8 cycles of square wave, the current clock of oscillator 201 (current clock frequency is 2MHz) statistically generates N o = 4 cycles of square wave. It can be seen that, with the same reference level width, the higher the frequency, the greater the number of square waves generated.
[0099] The calibration module 202 calibrates according to the reference frequency of the reference clock, the target frequency of the oscillator 201, and the N... ref Calculate the theoretical number of cycles N of the oscillator 201. os Among them, N os =(f osc / f ref )*N ref ;f osc f is the target frequency of the oscillator 201. ref This refers to the reference frequency of the reference clock. For example, if the reference frequency is 4MHz, N... ref If the value equals 10000, and the target frequency of oscillator 201 is 2MHz, then the theoretical number of cycles N of oscillator 201 is... os = (2 / 4) * 10000 = 5000.
[0100] If the N os With the N o If the absolute value of the difference is less than the set error DN, the calibration module 202 determines that the oscillator 201 has been successfully calibrated.
[0101] Among them, the set error DN is based on the frequency adjustment accuracy of the oscillator 201 and the target frequency f of the oscillator 201. osc Reference frequency f ref and N ref The frequency adjustment accuracy of oscillator 201 is determined by factors including the influence of the minimum adjustable unit of its electronic components. For example, the factors affecting the frequency adjustment accuracy include the resistance and capacitance values of the RC circuit, as well as the minimum adjustable units of the resistance and capacitance values. If the minimum adjustment unit for the resistance is 1 ohm (Ω) and the minimum adjustment unit for the capacitance is 0.1 microfarads (μF), then if the current resistance of the RC circuit of oscillator 201 increases by 1 Ω and the current capacitance increases by 1 μF, and the current frequency of oscillator 201 changes between 0.6% and 1%, then the frequency adjustment accuracy of oscillator 201 is 0.6%.
[0102] If N os With the N o If the absolute value of the difference is less than the set error DN, then the calibration module 202 determines that the oscillator 201 has been successfully calibrated.
[0103] If N os With the N o If the absolute value of the difference is greater than the set error DN, the calibration module 202 adjusts the frequency control parameter through the parameter adjustment module 203. The frequency control parameter is used to change the current frequency of the oscillator 201. After the current frequency of the oscillator 201 is adjusted, the comparison of N continues. os With the new N o If the absolute value of the difference is less than the set error DN, and it is still greater than the set error, then continue to adjust the current frequency of oscillator 201 until N... os With N o If the absolute value of the difference is less than the set error DN, then the calibration is considered successful.
[0104] Optionally, the calibration module 202 calculates the theoretical number of cycles N of the oscillator 201 according to the following formula. os :
[0105] N os =(f osc / f ref )*N ref ;
[0106] Among them, f osc f is the target frequency of the oscillator 201. ref The reference frequency is the reference clock frequency.
[0107] Optionally, the calibration module 202 is further configured to, after adjusting the frequency control parameters through the parameter adjustment module 203, continue to execute the process of obtaining the reference clock containing N... ref The step of determining the reference level for each cycle, or continuing to execute the step of statistically analyzing the reference level within the width of N cycles using the current clock of the oscillator 201. o Each cycle consists of steps.
[0108] Optionally, in the N os With the N o When the absolute value of the difference is greater than the set error DN, the calibration module 202 adjusts the frequency control parameter through the parameter adjustment module 203, specifically as follows:
[0109] If N O -N OS>DN, the calibration module 202 increases the current frequency parameter of the oscillator 201 by a minimum adjustable unit through the parameter adjustment module 203, so as to reduce the current frequency of the oscillator 201;
[0110] If N OS -N O >DN, the calibration module 202 reduces the current frequency parameter of the oscillator 201 by one minimum adjustable unit through the parameter adjustment module 203, so as to increase the current frequency of the oscillator 201.
[0111] In this embodiment, theoretically, the current frequency parameters (e.g., capacitance, resistance, inductance, etc.) of the oscillator 201 can be adjusted to any value. However, due to manufacturing processes, ambient temperature, etc., the minimum adjustable unit of the capacitor, resistor, and inductor cannot infinitely approach 0; there will be a minimum adjustable unit, which is the smallest adjustment amplitude each time. The frequency parameters can include parameters that affect the frequency of the oscillator 201. For example, for an RC oscillator 201 (where the resistor can be an adjustable resistor and the capacitor can be an adjustable capacitor), the frequency f of the RC oscillator 201 is f = 1 / 2πRC; the frequency parameters can include resistance and capacitance, and the minimum adjustable unit of the current frequency parameter can include the minimum adjustable unit of the resistance (e.g., 1Ω) or the minimum adjustable unit of the capacitance (e.g., 1μF). For an LC oscillator 201 (where the inductor can be an adjustable inductor and the capacitor can be an adjustable capacitor), the frequency of the LC oscillator 201... Frequency parameters may include inductance and capacitance, and the smallest adjustable unit of the current frequency parameter may be the smallest adjustable unit of inductance (e.g., 1 microhenry (μH)) or the smallest adjustable unit of capacitance (e.g., 1 μF).
[0112] It should be noted that, regardless of whether it is an RC oscillator 201 or an LC oscillator 201, the frequency of the oscillator 201 is inversely proportional to the capacitance, resistance, and inductance. That is, if you need to increase the frequency of the oscillator 201, you need to decrease the values of the capacitance, resistance, and inductance; if you need to decrease the frequency of the oscillator 201, you need to increase the values of the capacitance, resistance, and inductance.
[0113] Optionally, if N O -N OS >DN, the calibration module 202, through the parameter adjustment module 203, increases the current frequency parameter of the oscillator 201 by a minimum adjustable unit to reduce the current frequency of the oscillator 201. If N OS -N O >DN, the calibration module 202 determines that the oscillator 201 has failed calibration.
[0114] Optionally, if N OS -N O >DN, the calibration module 202 reduces the current frequency parameter of the oscillator 201 by one minimum adjustable unit through the parameter adjustment module 203, thereby increasing the current frequency of the oscillator 201. If N O -N OS >DN, the calibration module 202 determines that the oscillator 201 has failed calibration.
[0115] Optionally, the calibration module 202 is further configured to increase the frequency control parameter to its maximum, and N O -N OS In the case of >DN, the calibration module 202 determines that the oscillator 201 has failed calibration;
[0116] The calibration module 202 is further configured to reduce the frequency control parameter to a minimum, and N OS -N O In the case of >DN, the calibration module 202 determines that the oscillator 201 has failed calibration.
[0117] Optionally, the N ref Determine according to the following formula:
[0118] N ref ≥f ref / [β*(1-α)*f osc ];
[0119] Among them, f osc f is the target frequency of the oscillator 201. ref α is the reference frequency of the reference clock, α is the deviation error between the current frequency of the oscillator 201 and the target frequency, and β is the statistical error of the calibration module 202 in calculating the reference level using the current clock of the oscillator 201.
[0120] Optionally, the set error DN is determined according to the following formula:
[0121] DN = N ref *f osc *γ / f ref ;
[0122] Among them, f osc f is the target frequency of the oscillator 201. ref γ is the reference frequency of the reference clock, and γ is the frequency adjustment accuracy of the oscillator 201.
[0123] Optionally, the calibration module 202 is further configured to, upon acquiring the reference clock, generate a function containing N...ref Before the reference level of one cycle, a calibration start signal is received, which is used to instruct the calibration module 202 to enter a waiting state from an idle state;
[0124] The calibration module 202 is also used to switch from the waiting state to the calibration state after a preset waiting time has elapsed.
[0125] Optionally, the calibration module 202 is further configured to increase the current frequency parameter of the oscillator 201 by a minimum adjustable unit through the parameter adjustment module 203, so as to reduce the current frequency of the oscillator 201 and then enter the waiting state.
[0126] Optionally, the calibration module 202 is further configured to reduce the current frequency parameter of the oscillator 201 by a minimum adjustable unit through the parameter adjustment module 203, so as to increase the current frequency of the oscillator 201 and then enter the waiting state.
[0127] Optionally, the calibration module 202 is further configured to enter the idle state after determining that the oscillator 201 has been successfully calibrated.
[0128] Optionally, the calibration module 202 is further configured to enter the idle state after determining that the oscillator 201 has failed to calibrate.
[0129] In this embodiment of the application, by comparing N os With N o The calibration success is determined by whether the absolute value of the difference is greater than the set error DN. Only a calibrated reference clock needs to be connected to the chip to complete the automatic calibration of the chip's internal clock frequency, which shortens the calibration time. No external test circuit is required, which simplifies the chip test circuit and thus effectively shortens the chip test time and reduces the chip test cost.
[0130] Figure 4 This is a flowchart illustrating an automatic clock frequency calibration method for an in-chip device provided in an embodiment of this application. Figure 4 The method shown is applied to Figure 2 The chip shown. (As shown) Figure 4 As shown, the automatic clock frequency calibration method within the chip may include the following steps.
[0131] 401, The calibration module obtains the reference clock containing N ref The reference level for each cycle.
[0132] In this embodiment of the application, the reference clock can generate a segment containing N ref The reference level is for each cycle, and the width of the reference level is N. ref *f ref fref This is the reference frequency. For example, if the clock frequency of the reference clock (i.e., the reference frequency) is 4MHz, N ref If the value is 10000, then the width of the reference level is 2.5 milliseconds (ms).
[0133] The reference clock in this embodiment can be calibrated, and its clock frequency can be used by the chip for reference. The clock frequency of the reference clock can also be called the reference frequency. The reference clock can come from the oscillator of another calibrated chip, or it can come from a crystal oscillator; this embodiment does not limit this. The clock frequency of the reference clock is considered accurate, and the chip can receive an externally injected accurate reference clock.
[0134] Specifically, the calibration module can use the reference clock to statistically analyze the N contained within the reference level. ref One cycle.
[0135] 402, the calibration module uses the current clock of the oscillator to statistically determine the reference level, which contains N values within its width. o One cycle.
[0136] In this embodiment of the application, the calibration module uses a reference clock to statistically analyze the N contained in the reference level. ref Each cycle, within the width of the reference level statistically analyzed by the calibration module using the current clock of the oscillator, contains N. o These two steps can be performed simultaneously, meaning that the reference clock and the oscillator's current clock can simultaneously count the number of cycles contained within the same reference level.
[0137] In one embodiment, the calibration module uses a reference clock to statistically analyze the N contained within the reference level. ref Each cycle, within the width of the reference level statistically analyzed by the calibration module using the current clock of the oscillator, contains N. o These two steps can be performed sequentially within a cycle. For example, the calibration module uses a reference clock to count the N values contained in the reference level. ref Each cycle can be executed first, and then the calibration module uses the current clock of the oscillator to count the reference level within the width of N. o One cycle. That is, the reference clock starts counting first, then the oscillator's current clock starts counting, then the reference clock finishes counting first, and then the oscillator finishes counting. It is ensured that the level width of the statistics for the reference clock and the oscillator's current clock are the same.
[0138] Optionally, step 401 may specifically include the following steps:
[0139] The calibration module uses the reference clock to count the N values contained within the width of the reference level. ref One cycle
[0140] Step 402 may specifically include the following steps:
[0141] The calibration module uses the current clock of the oscillator to count the N values contained within the width of the reference level. o One cycle.
[0142] Steps 401 and 402 can be executed simultaneously.
[0143] 403, if the theoretical period number N os With N o If the absolute value of the difference is greater than the set error DN, the calibration module adjusts the frequency control parameter through the parameter adjustment module. The frequency control parameter is used to change the current frequency of the oscillator; N os Based on the reference clock's reference frequency, the oscillator's target frequency, and N... ref Sure.
[0144] In this embodiment of the application, the theoretical number of cycles N os It can be determined using the following formula:
[0145] N os =(f osc / f ref )*N ref ;
[0146] Among them, f osc f is the target frequency of the oscillator. ref The reference frequency is the reference clock frequency.
[0147] For example, if f osc =2.4MHz, f ref =4MHz, N ref =1200, then N os =720.
[0148] Theoretical number of cycles N os It is the number of cycles contained within the width of the current clock statistical reference level of the oscillator when the current frequency of the oscillator is equal to the target frequency.
[0149] Optionally, after performing step 403, you can continue to perform step 401 or step 402. Figure 4 Taking step 401 as an example, the cycle continues until the condition of step 404 is met, at which point the frequency calibration of the oscillator ends.
[0150] Optionally, in step 403, if the theoretical number of cycles N os With N o If the absolute value of the difference is greater than the set error DN, the calibration module adjusts the frequency control parameters through the parameter adjustment module, which may include the following steps:
[0151] If N O -N OS >DN, the calibration module increases the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment module, thereby reducing the current frequency of the oscillator; the current frequency of the oscillator is the frequency of the current clock of the oscillator;
[0152] If N OS -N O >DN, the calibration module reduces the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment module, thereby increasing the current frequency of the oscillator.
[0153] In this embodiment, theoretically, the current frequency parameters (e.g., capacitance, resistance, inductance, etc.) of the oscillator 201 can be adjusted to any value. However, due to manufacturing processes, ambient temperature, etc., the minimum adjustable unit of the capacitor, resistor, and inductor cannot infinitely approach 0; there will be a minimum adjustable unit, which is the smallest adjustment amplitude each time. The frequency parameters can include parameters that affect the frequency of the oscillator 201. For example, for an RC oscillator 201 (where the resistor can be an adjustable resistor and the capacitor can be an adjustable capacitor), the frequency f of the RC oscillator 201 is f = 1 / 2πRC; the frequency parameters can include resistance and capacitance, and the minimum adjustable unit of the current frequency parameter can include the minimum adjustable unit of the resistance (e.g., 1Ω) or the minimum adjustable unit of the capacitance (e.g., 1μF). For an LC oscillator 201 (where the inductor can be an adjustable inductor and the capacitor can be an adjustable capacitor), the frequency of the LC oscillator 201... Frequency parameters may include inductance and capacitance, and the smallest adjustable unit of the current frequency parameter may be the smallest adjustable unit of inductance (e.g., 1 microhenry (μH)) or the smallest adjustable unit of capacitance (e.g., 1 μF).
[0154] It should be noted that, regardless of whether it is an RC oscillator 201 or an LC oscillator 201, the frequency of the oscillator 201 is inversely proportional to the capacitance, resistance, and inductance. That is, if you need to increase the frequency of the oscillator 201, you need to decrease the values of the capacitance, resistance, and inductance; if you need to decrease the frequency of the oscillator 201, you need to increase the values of the capacitance, resistance, and inductance.
[0155] Optionally, before the calibration module increases the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment module to reduce the current frequency of the oscillator, the following steps are also included:
[0156] If N O -N OS>DN, the calibration module determines N O -N OS Is it less than the first threshold?
[0157] In N O -N OS If the value is less than the first threshold, the calibration module performs the step of increasing the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment module;
[0158] Before the calibration module reduces the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment module to increase the current frequency of the oscillator, it also includes the following steps:
[0159] If N OS -N O >DN, the calibration module determines N OS -N O Is it less than the second threshold?
[0160] In N OS -N O If the value is less than the second threshold, the calibration module performs the step of reducing the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment module.
[0161] The first threshold and the second threshold can be set according to DN. For example, both the first threshold and the second threshold can be set to ten times DN. The first threshold and the second threshold can be the same or different.
[0162] Both the first and second thresholds can be set to ten times DN. When the difference is small, the current frequency parameter of the oscillator can be adjusted using the smallest adjustable unit, thereby adjusting the current frequency of the oscillator. It only takes a maximum of ten adjustments to adjust the current frequency of the oscillator to the target frequency, which can quickly adjust the current frequency of the oscillator to the target frequency and improve the frequency adjustment speed of the oscillator.
[0163] Optional, Figure 4 The method may also include the following steps:
[0164] In N O -N OS If the difference is greater than the first threshold, the calibration module determines the value of N based on the mapping from the difference set to the minimum adjustable unit number set. O -N OS The corresponding N smallest adjustable units, where N is greater than or equal to 2;
[0165] The calibration module increases the current frequency parameter of the oscillator by the N target adjustable units through the parameter adjustment module, thereby reducing the current frequency of the oscillator;
[0166] In N OS -N O If the difference is greater than the second threshold, the calibration module determines the value of N based on the mapping from the difference set to the minimum adjustable unit number set. OS -N O The corresponding M minimum adjustable units, wherein M is greater than or equal to 2;
[0167] The calibration module reduces the current frequency parameter of the oscillator by the M target adjustable units through the parameter adjustment module, thereby increasing the current frequency of the oscillator;
[0168] The set of differences includes at least two differences, and the set of minimum adjustable unit quantities includes at least two minimum adjustable unit quantities; the mapping from the at least two differences to the at least two minimum adjustable unit quantities is a monotonically increasing function.
[0169] In this embodiment, the mapping from the difference set to the minimum adjustable unit quantity set can be stored in the calibration module as a mapping table. For example, please refer to Table 1, which is a mapping table from the difference set to the minimum adjustable unit quantity set provided in this embodiment.
[0170] Table 1
[0171] Set of differences (multiples of DN) Minimum number of adjustable units (pieces) 10~20 15 20~50 35 50~100 75 Greater than 100 100
[0172] As shown in Table 1, the larger the difference in the difference set, the larger the corresponding minimum adjustable unit number. In this embodiment, when the difference is large, at least two minimum adjustable units can be used to adjust the current frequency parameter of the oscillator. Alternatively, when the difference is large (greater than a first or second threshold), instead of adjusting the current frequency parameter of the oscillator with the minimum adjustable unit number, the adjustment can be performed with the minimum adjustable unit number corresponding to the difference. Each adjustment when the difference is large can adjust the current frequency of the oscillator by a larger amplitude, thereby quickly adjusting the difference to below the first or second threshold, and thus quickly adjusting the current frequency of the oscillator to the target frequency, improving the frequency adjustment speed of the oscillator.
[0173] 404, if N os With N o If the absolute value of the difference is less than the set error DN, the calibration module determines that the oscillator calibration is successful.
[0174] Theoretically speaking, if N os >N o This indicates that the current frequency of the oscillator is too low; if Nos <N o This indicates that the current frequency of the oscillator is too high; if N os =N o This indicates that the current frequency of the oscillator is equal to the target frequency. However, in actual circuits, due to statistical errors in the current clock of the oscillator, the number of cycles contained within the width of the statistical reference level of the current clock will have a certain error.
[0175] In this embodiment of the application, a set error DN is provided, as long as N os With N o If the absolute value of the difference is less than the set error DN, it indicates that the current frequency of the oscillator is equal to the target frequency, confirming successful oscillator calibration. If N os With N o If the absolute value of the difference is greater than the set error DN, it indicates that the current frequency of the oscillator is not equal to the target frequency, and the current frequency of the oscillator needs to be adjusted.
[0176] In this embodiment of the application, by comparing N os With N o The calibration success is determined by whether the absolute value of the difference is greater than the set error DN. Only a calibrated reference clock needs to be connected to the chip to complete the automatic calibration of the chip's internal clock frequency, which shortens the calibration time. No external test circuit is required, which simplifies the chip test circuit and thus effectively shortens the chip test time and reduces the chip test cost.
[0177] Please see Figure 5 , Figure 5 This is a flowchart illustrating another method for automatic calibration of the in-chip clock frequency provided in an embodiment of this application. Figure 5 The method shown is applied to Figure 2 The chip shown. Figure 5 Is Figure 4 It was obtained through further optimization based on the existing model, such as Figure 5 As shown, the automatic clock frequency calibration method within the chip may include the following steps.
[0178] 501, The calibration module receives a calibration start signal, which is used to indicate that the calibration module enters a waiting state from an idle state.
[0179] In this embodiment, the calibration module can receive a calibration start signal, and the calibration module switches from an idle state to a waiting state. In the idle state, the calibration module does not perform calibration operations. In the waiting state, the calibration module prepares for calibration.
[0180] 502. After a preset time, the calibration module switches from the waiting state to the calibration state.
[0181] In this embodiment, the preset duration can be pre-set. After the parameter adjustment module adjusts the oscillator frequency, the oscillator needs a certain period of time to stabilize its output. After receiving the calibration start signal, the calibration module will not directly enter the calibration state from the idle state, but will first enter the waiting state, and then enter the calibration state after a certain period of time (preset duration). Since steps 501 and 502 may enter subsequent loop steps, a preset duration needs to be set so that when the calibration module is in the calibration state, the oscillator can output a stable frequency square wave signal or sine wave signal. That is, the oscillator can output a stable frequency square wave signal or sine wave signal after the last frequency adjustment and before the next frequency adjustment, ensuring that the oscillator can output a stable frequency square wave signal or sine wave signal in the calibration state. The preset duration is the time required for the oscillator to output a stable frequency signal after frequency adjustment.
[0182] 503, The calibration module obtains the reference clock containing N ref The reference level for each cycle.
[0183] 504, the calibration module uses the current clock of the oscillator to statistically determine the reference level, which contains N values within its width. o One cycle.
[0184] 505, if N O -N OS >DN, the calibration module increases the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment module, thereby reducing the current frequency of the oscillator.
[0185] Optionally, after performing step 505, the calibration module enters the waiting state and enters the next cycle.
[0186] Optionally, after executing step 505, after the next execution of steps 502, 503, and 504, if N OS -N O >DN, the calibration module determines that the oscillator calibration has failed. This indicates that after adjusting the oscillator's current frequency parameter in the smallest adjustable unit, the oscillator's current frequency repeatedly switches between the target frequency and the target frequency, still failing to meet N. os With N o If the absolute value of the difference is less than the set error DN, then the oscillator is determined to be in a roll state or the calibration has failed.
[0187] 506, if N OS -N O >DN, the calibration module reduces the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment module, thereby increasing the current frequency of the oscillator.
[0188] Optionally, after performing step 506, the calibration module enters the waiting state and proceeds to the next cycle.
[0189] Optionally, after executing step 506, and after the next execution of steps 502, 503, and 504, N O -N OS >DN, the calibration module determines that the oscillator calibration has failed. This indicates that after adjusting the oscillator's current frequency parameter in the smallest adjustable unit, the oscillator's current frequency repeatedly switches between the target frequency and the target frequency, still failing to meet N. os With N o If the absolute value of the difference is less than the set error DN, then the oscillator is determined to be in a roll state or the calibration has failed.
[0190] Optionally, if the frequency control parameter is increased to its maximum, and N O -N OS >DN, the calibration module determines that the oscillator calibration has failed;
[0191] When the frequency control parameter is reduced to its minimum, if N OS -N O >DN, the calibration module determines that the oscillator calibration failed.
[0192] In this embodiment, if the frequency control parameter is increased to its maximum, that is, the current frequency of the oscillator is adjusted to its minimum, the current frequency of the oscillator is still greater than the target frequency, i.e., N. O -N OS >DN, the calibration module determines that the oscillator calibration has failed. If the frequency control parameter is reduced to its minimum, that is, the current frequency of the oscillator is adjusted to its maximum, but the current frequency of the oscillator is still less than the target frequency, i.e., N OS -N O >DN, the calibration module determines that the oscillator calibration failed.
[0193] Optionally, the calibration module enters an idle state after the oscillator calibration fails.
[0194] Optionally, the calibration module enters an idle state after the oscillator is in the tumbling state.
[0195] 507, if N os With N o If the absolute value of the difference is less than the set error DN, the calibration module determines that the oscillator calibration is successful.
[0196] Optionally, after performing step 507, the calibration module enters the idle state and waits for the next calibration start command.
[0197] Optionally, the N ref Determine according to the following formula:
[0198] N ref ≥f ref / [β*(1-α)*f osc ];
[0199] Among them, f osc f is the target frequency of the oscillator. ref α is the reference frequency of the reference clock, α is the deviation error between the current frequency of the oscillator and the target frequency, and β is the statistical error of the calibration module in calculating the reference level using the current clock of the oscillator.
[0200] The deviation error α between the current frequency and the target frequency of the oscillator refers to the following: if the deviation error between the current frequency and the target frequency of the oscillator is less than or equal to α, the frequency of the oscillator can be calibrated back before the frequency of the oscillator is calibrated; if the deviation error is greater than α, the frequency of the oscillator cannot be calibrated back.
[0201] For example, if α is set to 30%, and if the error between the oscillator's current frequency and the target frequency is within 30%, then in N... ref Satisfying formula N ref ≥f ref / [β*(1-α)*f osc In the case of [missing information], the oscillator frequency can be calibrated back; if the error between the current frequency and the target frequency of the oscillator is more than 30%, then in N... ref Satisfying formula N ref ≥f ref / [β*(1-α)*f osc In the case of [the oscillator frequency being calibrated], there is no guarantee that the oscillator frequency can be calibrated back.
[0202] β represents the statistical error of the reference level calculated by the calibration module using the current clock of the oscillator. β refers to the statistical error of the counter corresponding to the oscillator, which is determined by the oscillator's frequency error and is related to the oscillator's hardware parameters.
[0203] For example, if α is 30% and β is 0.2%, f osc It is 2.4MHz, f ref If it is 4MHz, then N ref ≥f ref / [β*(1-α)*f osc = 4 / 0.2% * (1 - 30%) * 2.4 = 1190. N can be set. ref It is 1200.
[0204] If N is set ref Set the value to 1200, and define the statistical value N. ref The counter (e.g., counter 1) has 11 bits (2) 10 <1200<2 11 This will satisfy the requirements. The current clock count of the oscillator is the highest count of the counter corresponding to the reference level, N = N. ref *f osc *(1+α) / f ref =1200*2.4*1.3 / 4=936, then the number of bits in the counter (e.g., counter 2) for the current clock statistical reference level of the oscillator is 10 bits (2 9 <936<2 10 Therefore, a 10-bit counter for the oscillator is sufficient to meet the requirements. Counter 1 is used to count N in step 503. ref Counter 2 is used to count N in step 504. o .
[0205] Using the above formula, N ref The limitations allow for the selection of N, provided that the deviation error between the oscillator's current frequency and the target frequency is less than α, and the statistical error of the calibration module using the oscillator's current clock statistical reference level is less than β. ref It can meet the calibration requirements.
[0206] It should be noted that N ref =f ref / β*(1-α)*f osc This can also meet the calibration requirements. To shorten the calibration time, N can be set. ref =f ref / β*(1-α)*f osc .
[0207] Optionally, the set error DN is determined according to the following formula:
[0208] DN = N ref *f osc *γ / f ref ;
[0209] Among them, f osc f is the target frequency of the oscillator. ref γ is the reference frequency of the reference clock, and γ is the frequency adjustment accuracy of the oscillator.
[0210] In this embodiment, the frequency adjustment accuracy γ of the oscillator refers to the error caused by adjusting the frequency parameters of the oscillator in the smallest unit.
[0211] For example, if the frequency adjustment accuracy γ of the oscillator is 0.66%, f osc It is 2.4MHz, f ref 4MHz, N ref If the value is 1200, then DN = N ref *f osc *γ / f ref =1200*2.4*0.66% / 4 = 4.75. Since DN is an integer, DN can be set to 4 or 5.
[0212] The specific implementation of steps 503 to 507 can be found in steps 401 to 404, and will not be repeated here.
[0213] In this embodiment of the application, by comparing N os With N o The calibration success is determined by whether the absolute value of the difference is greater than the set error DN. Only a calibrated reference clock needs to be connected to the chip to complete the automatic calibration of the chip's internal clock frequency, which shortens the calibration time. No external test circuit is required, which simplifies the chip test circuit and thus effectively shortens the chip test time and reduces the chip test cost.
[0214] Please see Figure 6 , Figure 6 This is a schematic diagram illustrating the state changes of a calibration module provided in an embodiment of this application. The state of the calibration module can also be referred to as the state of the state machine.
[0215] (1) The initial state of the state machine is the idle state, and the oscillator operates at the initial default parameters;
[0216] (2) When the calibration module receives the calibration start signal, the state machine transitions from the idle state to the wait state. In the wait state, a counter is enabled for delay waiting. When the count time reaches the set value, the state machine enters the calibration (TRACK) state;
[0217] (3) In calibration state, N is generated by counting with a reference clock. ref The count value N is obtained by using the high-level width of the oscillator's internal clock cycle. O ;
[0218] A: If N O >N OS N O -N OS>DN indicates that the internal OSC frequency is higher than the reference frequency. The state machine enters the parameter increment state and increments the current frequency parameter (FCCTL) of the oscillator by 1 (that is, the calibration module increases the current frequency parameter FCCTL of the oscillator by one minimum adjustable unit through the parameter adjustment module), thereby reducing the frequency of the oscillator by one level.
[0219] B: If N OS >N O N OS -N O >DN indicates that the internal OSC frequency is lower than the reference frequency. The state machine enters the parameter reduction state, decrements the current frequency parameter FCCTL of the oscillator by 1, and increases the frequency of the oscillator by one level.
[0220] C: If N is at the current frequency parameter of the previous oscillator O -N OS >DN, denoted as L(N) O -N OS >DN), the current N obtained by adding 1 to the current frequency parameter. OS -N O >DN, denoted as C(N) OS -N O If the oscillator's current frequency drops from above the reference frequency range by one level and then falls below the reference frequency range again, it enters a rolling state. This indicates that a frequency roll has occurred and cannot be adjusted within the error range. The chip is currently marked as rolling and cannot be calibrated to the required range, so it is discarded. Similarly, when the oscillator's current frequency drops from below the reference frequency range L(N)... OS -N O >DN), after increasing one level, it becomes higher than the reference frequency range C(N). O -N OS >DN), which also belongs to the category of being unable to be calibrated to the required range and entering the tumbling state, and being unable to be calibrated to the required range and being discarded;
[0221] D: When the current frequency parameter of the oscillator is increased to its maximum, it still makes N... O -N OS >DN, or the current frequency parameter of the oscillator is reduced to a minimum, yet N still makes OS -N O >DN indicates that the current frequency parameter of the oscillator has reached the boundary state and the current frequency of the oscillator cannot be calibrated to the required range. In this case, it enters the failure (FAIL) state and the current chip is marked as failed and discarded.
[0222] E: As long as the current frequency parameter of the oscillator is adjusted to a certain value, N can be made O With N OSThe relative difference between them is less than the allowable error range DN, that is, |N O - N OS |< DN, indicating that the oscillator has been successfully calibrated and enters the completed (DONE) state.
[0223] (4) Whether in the parameter reduction state or the parameter increase state, after completion, it enters the waiting state. Mainly after the hardware adjusts the current frequency parameter of the oscillator for frequency compensation, the internal oscillator of the chip needs some time to reach a stable output;
[0224] (5) After the tumbling / failure / completion state completes the corresponding selection and marking, it returns to the idle state and waits for the next calibration start instruction.
[0225] In this way, through the method described in the embodiments of the present application, the automatic calibration of the internal clock frequency of the chip can be completed, the calibration time is shortened, the peripheral test circuit is saved, the chip test circuit is simplified, thereby effectively shortening the chip test time and reducing the chip test cost.
[0226] Please refer to Figure 7 , Figure 7 which is a schematic structural diagram of a calibration module for the internal clock frequency of a chip provided by the embodiments of the present application. This calibration module 700 is applied to Figure 2 the chip shown. The chip is externally connected to a calibrated reference clock. The chip includes an oscillator, the calibration module, and a parameter adjustment module. The calibration module 700 includes:
[0227] An acquisition unit 701, configured to acquire a reference level including N ref cycles generated by the reference clock;
[0228] A statistical unit 702, configured to count that the width of the reference level includes N o cycles through the current clock of the oscillator;
[0229] A parameter adjustment unit 703, configured to adjust the frequency control parameter through the parameter adjustment module when the absolute value of the difference between the theoretical number of cycles N os and the N o is greater than the set error DN. The frequency control parameter is used to change the current frequency of the oscillator; the N os is determined based on the reference frequency of the reference clock, the target frequency of the oscillator, and the N ref ;
[0230] A determination unit 704, configured to determine that the oscillator is successfully calibrated when the absolute value of the difference between the N os and the N o is less than the set error DN.
[0231] in, Figure 7 For details on the implementation of the calibration module, please refer to Figures 4 to 5 The method embodiments shown are not described in detail here.
[0232] In this embodiment of the application, by comparing N os With N o The calibration success is determined by whether the absolute value of the difference is greater than the set error DN. Only a calibrated reference clock needs to be connected to the chip to complete the automatic calibration of the chip's internal clock frequency, which shortens the calibration time. No external test circuit is required, which simplifies the chip test circuit and thus effectively shortens the chip test time and reduces the chip test cost.
[0233] This application also provides a computer-readable storage medium storing a computer program for electronic data interchange, which causes a computer to perform some or all of the steps of any of the in-chip clock frequency automatic calibration methods described in the above method embodiments.
[0234] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0235] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0236] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0237] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0238] Furthermore, the functional units in the various embodiments of the application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software program module.
[0239] If the integrated unit is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0240] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage device, which may include: a flash drive, a read-only memory, a random access memory, a magnetic disk, or an optical disk, etc.
[0241] The embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for automatic calibration of on-chip clock frequency, characterized in that, The chip is connected to an externally calibrated reference clock. The chip includes an oscillator, a calibration circuit, and a parameter adjustment circuit. The reference clock comes from the clock of the oscillator of another calibrated chip or a crystal oscillator. The method includes the following steps: The calibration circuit acquires the reference clock containing N. ref The reference level for each cycle; The calibration circuit uses the current clock of the oscillator to calculate the width of the reference level, which includes N. o The N cycles o One positive integer; If the theoretical period number N os With the N o If the absolute value of the difference is greater than the set error DN, the calibration circuit adjusts the frequency control parameter through the parameter adjustment circuit. The frequency control parameter is used to change the current frequency of the oscillator; the N os Based on the reference frequency of the reference clock, the target frequency of the oscillator, and N ref Sure; If the N os With the N o If the absolute value of the difference is less than the set error DN, the calibration circuit determines that the oscillator has been successfully calibrated.
2. The automatic clock frequency calibration method within a chip according to claim 1, characterized in that, The calibration circuit calculates the theoretical number of cycles N of the oscillator according to the following formula. os : N os =(f osc / f ref )* N ref ; Among them, f osc f is the target frequency of the oscillator. ref The reference frequency is the reference clock frequency.
3. The automatic clock frequency calibration method within a chip according to claim 2, characterized in that, After the calibration circuit adjusts the frequency control parameters through the parameter adjustment circuit, the method further includes: the calibration circuit continuing to perform the process of acquiring the reference clock containing N... ref The step of determining the reference level for each cycle, or continuing to execute the step of statistically analyzing the reference level within the width of N cycles using the current clock of the oscillator. o Each cycle consists of steps.
4. The automatic clock frequency calibration method within a chip according to claim 3, characterized in that, If the theoretical period number N os With the N o If the absolute value of the difference is greater than the set error DN, the calibration circuit adjusts the frequency control parameters through the parameter adjustment circuit, including: If N O -N OS >DN, the calibration circuit increases the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment circuit, thereby reducing the current frequency of the oscillator; If N OS -N O >DN, the calibration circuit reduces the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment circuit, thereby increasing the current frequency of the oscillator.
5. The automatic clock frequency calibration method within a chip according to claim 4, characterized in that, If N O -N OS >DN, after the calibration circuit increases the current frequency parameter of the oscillator by a minimum adjustable unit through the parameter adjustment circuit to reduce the current frequency of the oscillator, the method further includes: If N OS -N O >DN, the calibration circuit determines that the oscillator calibration has failed.
6. The automatic clock frequency calibration method within a chip according to claim 4, characterized in that, If N OS -N O >DN, after the calibration circuit reduces the current frequency parameter of the oscillator by one minimum adjustable unit through the parameter adjustment circuit to increase the current frequency of the oscillator, the method further includes: If N O -N OS >DN, the calibration circuit determines that the oscillator calibration has failed.
7. The automatic clock frequency calibration method within a chip according to claim 4, characterized in that, The method further includes: When the frequency control parameter is increased to its maximum, if N O -N OS >DN, the calibration circuit determines that the oscillator calibration has failed; When the frequency control parameter is reduced to its minimum, if N OS -N O >DN, the calibration circuit determines that the oscillator calibration has failed.
8. A calibration circuit for an in-chip clock frequency, characterized in that, The chip is connected to an externally calibrated reference clock. The chip includes an oscillator, the calibration circuit, and a parameter adjustment circuit. The reference clock comes from the clock of the oscillator of another calibrated chip or a crystal oscillator. The calibration circuit includes: Acquisition circuit, used to acquire the reference clock containing N ref The reference level for each cycle; A statistical circuit is used to count the width of the reference level containing N using the current clock of the oscillator. o One cycle; Parameter adjustment circuit, used to adjust the theoretical number of cycles N os With the N o If the absolute value of the difference is greater than the set error DN, the frequency control parameter is adjusted by the parameter adjustment circuit. This frequency control parameter is used to change the current frequency of the oscillator; the N... os Based on the reference frequency of the reference clock, the target frequency of the oscillator, and N ref Sure; Determine the circuit for use in the N os With the N o If the absolute value of the difference is less than the set error DN, the oscillator is determined to be successfully calibrated.
9. A chip, characterized in that, The chip includes an oscillator, a calibration circuit, and a parameter adjustment circuit, and the chip is externally connected to a calibrated reference clock; The reference clock comes from the clock of the oscillator of another calibrated chip or a crystal oscillator; The calibration circuit is used to obtain the reference clock containing N ref The reference level for each cycle; The calibration circuit is also used to count the width of the reference level containing N using the current clock of the oscillator. o One cycle; The calibration circuit is also used to perform calibrations on theoretically numbered N cycles. os With the N o If the absolute value of the difference is greater than the set error DN, the frequency control parameter is adjusted by the parameter adjustment circuit. This frequency control parameter is used to change the current frequency of the oscillator; the N... os Based on the reference frequency of the reference clock, the target frequency of the oscillator, and N ref Sure; The calibration circuit is also used in the N os With the N o If the absolute value of the difference is less than the set error DN, the oscillator is determined to be successfully calibrated.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Processing method of field synchronizing signals, and control circuit
CN105491434A