[0056] Hereinafter, the embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the embodiments in the application and the features in the embodiments can be combined with each other arbitrarily if there is no conflict.
[0057] The steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical sequence is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than here.
[0058] See figure 1 , The embodiment of the present invention provides a device for calibrating clock frequency, including:
[0059] The clock detection circuit is used to periodically count the clock signal output by the parameter adjustable oscillator to obtain the count value, determine that the absolute value of the difference between the obtained count value and the expected count value is greater than or equal to the preset threshold, and output the first to the calibration circuit Enable signal to control the calibration circuit to enter the working state;
[0060] The calibration circuit is used to enter the working state when receiving the first enable signal, and output a control signal to the parameter adjustable oscillator according to the obtained count value, so that the parameter adjustable oscillator can adjust the frequency of the clock signal;
[0061] The parameter adjustable oscillator is used to output the output clock signal to the clock detection circuit and other circuits that work based on the clock signal, and adjust the frequency of the clock signal according to the control signal.
[0062] Optionally, the clock detection circuit is also used for:
[0063] It is determined that the absolute value of the difference between the obtained count value and the expected count value is less than the preset threshold value, and the second enable signal is output to the calibration circuit to control the calibration circuit to enter a non-working state;
[0064] The calibration circuit is also used for:
[0065] When receiving the second enable signal, it enters the non-working state.
[0066] In the above device, the first enable signal EN is 0, and the second enable signal EN is 1;
[0067] Or, the first enable signal EN is 1, and the second enable signal EN is 0.
[0068] It depends on the implementation of the calibration circuit.
[0069] Optional, also includes:
[0070] Reference clock circuit for generating periodic detection pulses;
[0071] The clock detection circuit is specifically used to implement timing counting of the clock signal output by the parameter adjustable oscillator to obtain the count value by adopting the following methods:
[0072] When receiving the detection pulse from the reference clock circuit in the non-counting state, start counting the clock signal output by the parameter adjustable oscillator; when receiving the detection pulse from the reference clock circuit in the counting state, stop outputting the parameter adjustable oscillator Count the clock signal and get the count value.
[0073] Among them, the time interval between three adjacent detection pulses is equal to one calibration period.
[0074] For example, the clock detection circuit starts counting when it receives the first detection pulse, stops counting when it receives the second detection pulse, starts counting when it receives the third detection pulse, and when it receives the fourth detection pulse Stop counting, ..., and so on.
[0075] Among them, the clock detection circuit counting the clock signal output by the parameter adjustable oscillator refers to counting the pulses of the clock signal output by the parameter adjustable oscillator.
[0076] Specifically, see figure 2 , The clock detection circuit includes a counter and a state control circuit;
[0077] Among them, the counter is used to count the clock signal output by the parameter adjustable oscillator to obtain the count value;
[0078] The state control circuit is used to determine that the absolute value of the difference between the obtained count value and the expected count value is greater than or equal to the preset threshold value, and output the first enable signal to the calibration circuit to control the calibration circuit to enter the working state; determine the obtained The absolute value of the difference between the count value and the expected count value is less than the preset threshold, and the second enable signal is output to the calibration circuit to control the calibration circuit to enter a non-working state.
[0079] Among them, the counter is specifically used for:
[0080] When receiving the detection pulse from the reference clock circuit in the non-counting state, start counting the clock signal output by the parameter adjustable oscillator; when receiving the detection pulse from the reference clock circuit in the counting state, stop outputting the parameter adjustable oscillator Count the clock signal and get the count value.
[0081] Optionally, the calibration circuit is specifically configured to output a control signal to the parameter-tunable oscillator according to the obtained count value in the following manner:
[0082] Determine that the obtained count value is greater than the expected count value, and output a control signal for instructing the parameter-tunable oscillator to reduce the frequency of the clock signal to the parameter-tunable oscillator;
[0083] The parameter adjustable oscillator is specifically used for:
[0084] The output clock signal is output to the clock detection circuit and other circuits that operate based on the clock signal, and the frequency of the clock signal is reduced according to the control signal for instructing the parameter-tunable oscillator to reduce the frequency of the clock signal.
[0085] Optionally, the calibration circuit is specifically configured to output a control signal to the parameter-tunable oscillator according to the obtained count value in the following manner:
[0086] Determine that the obtained count value is less than the expected count value, and output a control signal for instructing the parameter-tunable oscillator to increase the frequency of the clock signal to the parameter-tunable oscillator;
[0087] The parameter adjustable oscillator is specifically used for:
[0088] The output clock signal is output to the clock detection circuit and other circuits that operate based on the clock signal, and the frequency of the clock signal is reduced according to the control signal for instructing the parameter-tunable oscillator to increase the frequency of the clock signal.
[0089] Specifically, the frequency of the clock signal is adjusted by adjusting the adjustable parameters in the parameter adjustable oscillator. The adjustable parameters can be resistance value, capacitance value, inductance value, and so on.
[0090] For example, when the frequency of the clock signal is adjusted by the resistance value, the resistance can be set to have multiple adjustable gear positions, and each gear position corresponds to a resistance value; when receiving an instruction to instruct the parameter adjustable oscillator to reduce the frequency of the clock signal When controlling the signal, turn down a resistance gear; when receiving a control signal for instructing the parameter-tunable oscillator to increase the frequency of the clock signal, turn up a resistance gear.
[0091] Of course, other adjustment methods can also be used, which are not limited in the embodiment of the present invention.
[0092] Among them, other circuits that work based on clock signals can be digital circuits or analog circuits.
[0093] Through the solution of the embodiment of the present invention, the frequency of the clock signal output by the parameter tunable oscillator is adjusted in real time according to the count value of the clock signal output by the parameter tunable oscillator, which reduces the impact of changes in the surrounding environment and application temperature on the oscillator. The influence of the clock frequency improves the accuracy of the oscillator frequency; and the clock detection circuit sends an enable signal to the calibration circuit to control the working state of the calibration circuit, thereby reducing power consumption.
[0094] See image 3 The embodiment of the present invention also proposes a method for calibrating the clock frequency, including:
[0095] Step 300: The parameter adjustable oscillator outputs the output clock signal to the clock detection circuit and other circuits that operate based on the clock signal.
[0096] Step 301: The clock detection circuit regularly counts the clock signal output by the parameter adjustable oscillator to obtain the count value, determines that the absolute value of the difference between the obtained count value and the expected count value is greater than or equal to the preset threshold, and outputs the first value to the calibration circuit. Enable signal to control the calibration circuit to enter the working state.
[0097] In this step, the clock detection circuit regularly counts the clock signal output by the parameter adjustable oscillator to obtain the count value including:
[0098] The reference clock circuit generates periodic detection pulses;
[0099] When the clock detection circuit receives the detection pulse from the reference clock circuit in the non-counting state, it starts to count the clock signal output by the parameter adjustable oscillator; when it receives the detection pulse from the reference clock circuit in the counting state, it stops adjusting the parameter The clock signal output by the oscillator counts and the count value is obtained.
[0100] Among them, the time interval between three adjacent detection pulses is equal to one calibration period.
[0101] For example, the clock detection circuit starts counting when it receives the first detection pulse, stops counting when it receives the second detection pulse, starts counting when it receives the third detection pulse, and when it receives the fourth detection pulse Stop counting, ..., and so on.
[0102] Among them, the clock detection circuit counting the clock signal output by the parameter adjustable oscillator refers to counting the pulses of the clock signal output by the parameter adjustable oscillator.
[0103] Step 302: When the calibration circuit receives the first enable signal, it enters the working state, and outputs a control signal to the parameter-tunable oscillator according to the obtained count value, so that the parameter-tunable oscillator adjusts the frequency of the clock signal.
[0104] In this step, the calibration circuit outputting a control signal to the parameter adjustable oscillator according to the obtained count value includes:
[0105] The calibration circuit determines that the count value obtained is greater than the expected count value, and outputs a control signal for instructing the parameter-tunable oscillator to reduce the frequency of the clock signal to the parameter-tunable oscillator;
[0106] It is determined that the obtained count value is less than the expected count value, and a control signal for instructing the parameter adjustable oscillator to increase the frequency of the clock signal is output to the parameter adjustable oscillator.
[0107] Step 303: The parameter adjustable oscillator adjusts the frequency of the clock signal according to the control signal. include:
[0108] Reduce the frequency of the clock signal according to the control signal used to instruct the parameter-tunable oscillator to reduce the frequency of the clock signal;
[0109] The frequency of the clock signal is increased according to a control signal for instructing the parameter adjustable oscillator to increase the frequency of the clock signal. The adjusted parameter adjustable oscillator outputs the output clock signal to the clock detection circuit and other circuits that work based on the clock signal. Under the control of the detection pulse, it enters the next round of detection and calibration.
[0110] Specifically, the frequency of the clock signal is adjusted by adjusting the adjustable parameters in the parameter adjustable oscillator. The adjustable parameters can be resistance value, capacitance value, inductance value, and so on.
[0111] For example, when the frequency of the clock signal is adjusted by the resistance value, the resistance can be set to have multiple adjustable gears, each of which corresponds to a resistance value; when receiving an instruction to instruct the parameter adjustable oscillator to reduce the frequency of the clock signal When controlling the signal, turn down a resistance gear; when receiving a control signal for instructing the parameter-tunable oscillator to increase the frequency of the clock signal, turn up a resistance gear.
[0112] Of course, other adjustment methods can also be used, which are not limited in the embodiment of the present invention.
[0113] Optionally, the method further includes:
[0114] The clock detection circuit determines that the absolute value of the difference between the obtained count value and the expected count value is less than the preset threshold value, and outputs the second enable signal to the calibration circuit to control the calibration circuit to enter a non-working state;
[0115] The calibration circuit enters a non-working state when receiving the second enable signal.
[0116] In the above method, the first enable signal EN is 0, and the second enable signal EN is 1;
[0117] Or, the first enable signal EN is 1, and the second enable signal EN is 0.
[0118] It depends on the implementation of the calibration circuit.
[0119] The embodiment of the present invention also proposes a chip, including all modules of any of the above-mentioned clock frequency calibration devices, and further including:
[0120] The configuration module is used to configure the parameters of the parameter-tunable oscillator when the chip is powered on;
[0121] Other circuits that work based on clock signals are used to work according to the clock signal output by the parameter-tunable oscillator;
[0122] Parameter adjustable oscillators are also used for:
[0123] After the configuration module performs parameter configuration, a clock signal with a frequency corresponding to the configured parameter is output.
[0124] Among them, the configuration module can be a CPU.
[0125] Although the embodiments disclosed in the present invention are as above, the content described is only the embodiments used to facilitate the understanding of the present invention, and is not intended to limit the present invention. Anyone skilled in the art to which the present invention belongs can make any modifications and changes in the implementation form and details without departing from the spirit and scope of the present invention. However, the patent protection scope of the present invention still requires The scope defined by the appended claims shall prevail.