CN-114285409-B - Automatic calibration method and related device for clock frequency in chip
Abstract
The embodiment of the application provides an automatic calibration method and a related device for clock frequency in a chip, wherein the automatic calibration method for clock frequency in the chip comprises the steps that a calibration module obtains a reference level which is generated by a reference clock and contains N ref periods, the calibration module counts the width of the reference level through the current clock of an oscillator and contains N o periods, if the absolute value of the difference value of theoretical periods N os and N o is larger than a set error DN, the calibration module adjusts a frequency control parameter through a parameter adjustment module, the frequency control parameter is used for changing the current frequency of the oscillator, N os is determined based on the reference frequency of the reference clock, the target frequency of the oscillator and N ref , and if the absolute value of the difference value of N os and N o is smaller than the set error DN, the calibration module determines that the oscillator is successfully calibrated. The embodiment of the application can shorten the calibration time of the clock frequency in the chip.
Inventors
- ZHENG WENJIE
Assignees
- 深圳英集芯科技股份有限公司
- 深圳英集芯科技股份有限公司
Dates
- Publication Date
- 20260421
- Application Date
- 20200928
- Priority Date
- 20200928
Claims (10)
- 1. An automatic calibrating method for clock frequency in a chip is characterized in that the chip is externally connected with a calibrated reference clock, the chip comprises an oscillator, a calibrating circuit and a parameter adjusting circuit, and the reference clock is from the clock or crystal oscillator of the oscillator of other calibrated chips; the method comprises the steps of: The calibration circuit obtains a reference level which is generated by the reference clock and comprises N ref periods; The calibration circuit counts N o periods, N o positive integers, within the width of the reference level through the current clock of the oscillator; if the absolute value of the difference between the theoretical cycle number N os and the N o is greater than the set error DN, the calibration circuit adjusts a frequency control parameter through the parameter adjusting circuit, wherein the frequency control parameter is used for changing the current frequency of the oscillator; If the absolute value of the difference between N os and N o is smaller than the set error DN, the calibration circuit determines that the oscillator calibration is successful.
- 2. The method of claim 1, wherein the calibration circuit calculates the theoretical number of cycles N os of the oscillator according to the following formula: N os =(f osc /f ref )* N ref ; Wherein f osc is the target frequency of the oscillator, and f ref is the reference frequency of the reference clock.
- 3. The method of claim 2, wherein after the calibration circuit adjusts the frequency control parameters by the parameter adjustment circuit, the method further comprises continuing to perform the step of obtaining the reference level containing N ref cycles generated by the reference clock or continuing to perform the step of counting N o cycles within the width of the reference level by the current clock of the oscillator.
- 4. The method according to claim 3, wherein the absolute value of the difference between the theoretical cycle number N os and the theoretical cycle number N o is greater than a set error DN, and the adjusting circuit adjusts the frequency control parameter through the parameter adjusting 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 so as to reduce 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 so as to adjust the current frequency of the oscillator.
- 5. The method of claim 4, wherein 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 to decrease the current frequency of the oscillator, the method further comprising: If N OS -N O > DN, the calibration circuit determines that the oscillator calibration fails.
- 6. The method of claim 4, wherein if N OS -N O > DN, the calibration circuit reduces the current frequency parameter of the oscillator by a minimum adjustable unit to increase the current frequency of the oscillator by the parameter adjustment circuit, the method further comprising: If N O -N OS > DN, the calibration circuit determines that the oscillator calibration fails.
- 7. The method for automatically calibrating a clock frequency in a chip according to claim 4, further comprising: If N O -N OS > DN, the calibration circuit determines that the oscillator calibration fails if the frequency control parameter increases to a maximum; If N OS -N O > DN, the calibration circuit determines that the oscillator calibration fails, with the frequency control parameter reduced to a minimum.
- 8. A calibration circuit for an on-chip clock frequency, wherein a chip is externally connected with a calibrated reference clock, the chip comprises an oscillator, the calibration circuit and a parameter adjustment circuit, the reference clock is from the clock or the crystal oscillator of the oscillator of other calibrated chips, and the calibration circuit comprises: An acquisition circuit for acquiring a reference level containing N ref cycles generated by the reference clock; a counting circuit for counting N o cycles included in the width of the reference level by the current clock of the oscillator; A parameter adjustment circuit for adjusting a frequency control parameter for changing a current frequency of the oscillator, when an absolute value of a difference between a theoretical cycle number N os and the N o is greater than a set error DN, the N os being determined based on a reference frequency of the reference clock, a target frequency of the oscillator, and the N ref ; and the determining circuit is used for determining that the oscillator is successfully calibrated under the condition that the absolute value of the difference value between the N os and the N o is smaller than the set error DN.
- 9. The chip is characterized by comprising an oscillator, a calibration circuit and a parameter adjustment circuit, wherein the chip is externally connected with a calibrated reference clock; The calibration circuit is used for acquiring a reference level which is generated by the reference clock and comprises N ref periods; the calibration circuit is further used for counting N o periods within the width of the reference level through the current clock of the oscillator; The calibration circuit is further configured to adjust, by the parameter adjustment circuit, a frequency control parameter for changing a current frequency of the oscillator when an absolute value of a difference between the theoretical cycle number N os and the N o is greater than a set error DN; The calibration circuit is further configured to determine that the oscillator calibration is successful if an absolute value of a difference between the N os and the N o is smaller than the set error DN.
- 10. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of any of claims 1 to 7.
Description
Automatic calibration method and related device for clock frequency in chip Technical Field The application relates to the technical field of chips, in particular to an automatic calibration method and a related device for clock frequency in a chip. Background The clock is an integral part of the chip as a unified baton of the time sequence circuit. There are generally two approaches to clock source design of chips. The quartz crystal oscillator is hung outside the chip and is input into the chip through the chip pins to provide a clock source. The other is to design an oscillator circuit inside the chip to generate a clock, which has the advantages of high integration level and low cost, and the disadvantage that the period of the oscillator can be changed along with the process deviation or voltage temperature change, so that the individual difference of the clock frequency on a plurality of chips is larger. Thus, it is particularly important to calibrate the internal oscillator frequency. As in fig. 1, is an existing clock frequency calibration scheme. The prior calibration scheme is to divide the clock generated by an Oscillator (OSC) inside a chip to kilohertz (KHz) level, output the clock to the outside of the chip through a chip pin, sample the discharged divided clock outside the chip by using an accurate clock in megahertz (MHz) level to calculate the actual frequency, then adjust the frequency parameter inside the chip according to the deviation direction and amplitude of the actual frequency and the target frequency, then generate a new clock frequency under the new frequency parameter, and measure the current oscillator frequency outside the chip again, and circulate until the frequency calibration parameter is found so that the frequency of the clock oscillator is consistent with the target frequency, and the calibration process is completed. However, the applicant has found that the prior art has the following drawbacks: 1. When the frequency of the internal oscillator is high, the clock signal with high frequency cannot be directly output to the outside of the chip due to the speed limitation of the chip pin, and the clock signal needs to be divided to low frequency and then released. 2. When a low-frequency clock is measured outside the chip, because the low-frequency clock has a longer period, the measurement of one period needs to take a longer time, and for the accuracy of measurement, the measurement of a plurality of low-frequency clock periods is often needed to be performed and then the average value is obtained, so that the test time and the test cost of the chip are obviously increased. 3. The result of the measurement and calculation outside the chip needs to be fed back to the inside of the chip through a special communication interface, so that the peripheral test circuit of the chip is complex. Disclosure of Invention The embodiment of the application provides an automatic calibration method for clock frequency in a chip and a related product, which can finish automatic calibration of the clock frequency in the chip, shorten the calibration time, save a peripheral test circuit, effectively shorten the test time of the chip and reduce the test cost of the chip. A first aspect of an embodiment of the present application provides a method for automatically calibrating clock frequency in a chip, the chip is externally connected with a calibrated reference clock, the chip includes an oscillator, a calibration module and a parameter adjustment module, the method includes the steps of: The calibration module acquires a reference level which is generated by the reference clock and contains N ref periods; The calibration module counts N o periods within the width of the reference level through the current clock of the oscillator; If the absolute value of the difference between the theoretical cycle number N os and the N o is greater than the set error DN, the calibration module adjusts a frequency control parameter through the parameter adjustment module, wherein the frequency control parameter is used for changing the current frequency of the oscillator; If the absolute value of the difference between N os and N o is smaller than the set error DN, the calibration module determines that the oscillator calibration is successful. The reference clock in the embodiment of the application can be calibrated, the clock frequency of the reference clock can be used for reference by the chip, and the clock frequency of the reference clock can also be called as reference frequency. The reference clock may be from the clock of the oscillator of other calibrated chips or from the crystal oscillator, and embodiments of the present application are not limited. Further, the calibration module calculates the theoretical cycle number N os of the oscillator according to the following formula: Nos=(fosc/fref)*Nref; Wherein f osc is the target frequency of the oscillator, and f ref is the reference frequency