CN116185128A - MCU chip internal clock calibration method and circuit - Google Patents
MCU chip internal clock calibration method and circuit Download PDFInfo
- Publication number
- CN116185128A CN116185128A CN202310209845.0A CN202310209845A CN116185128A CN 116185128 A CN116185128 A CN 116185128A CN 202310209845 A CN202310209845 A CN 202310209845A CN 116185128 A CN116185128 A CN 116185128A
- Authority
- CN
- China
- Prior art keywords
- value
- calibration
- actual frequency
- frequency value
- mcu chip
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 27
- 238000013507 mapping Methods 0.000 claims description 17
- 238000011088 calibration curve Methods 0.000 claims description 12
- 238000010586 diagram Methods 0.000 description 6
- DOSMHBDKKKMIEF-UHFFFAOYSA-N 2-[3-(diethylamino)-6-diethylazaniumylidenexanthen-9-yl]-5-[3-[3-[4-(1-methylindol-3-yl)-2,5-dioxopyrrol-3-yl]indol-1-yl]propylsulfamoyl]benzenesulfonate Chemical compound C1=CC(=[N+](CC)CC)C=C2OC3=CC(N(CC)CC)=CC=C3C(C=3C(=CC(=CC=3)S(=O)(=O)NCCCN3C4=CC=CC=C4C(C=4C(NC(=O)C=4C=4C5=CC=CC=C5N(C)C=4)=O)=C3)S([O-])(=O)=O)=C21 DOSMHBDKKKMIEF-UHFFFAOYSA-N 0.000 description 4
- 238000012360 testing method Methods 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 239000013078 crystal Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/04—Generating or distributing clock signals or signals derived directly therefrom
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Semiconductor Integrated Circuits (AREA)
- Electric Clocks (AREA)
Abstract
The application provides an MCU chip internal clock calibration method and circuit. The method comprises the following steps: acquiring an actual frequency value output by an internal clock of an MCU chip, and determining whether the actual frequency value is within a preset target frequency range; if not, determining a corresponding first calibration value according to the actual frequency value, and determining a calibration center value according to the actual frequency value, the first calibration value and the preset target frequency range; writing the calibration center value into the MCU chip to adjust the actual frequency value of the internal clock output of the MCU chip. According to the method, clock calibration can be automatically carried out on the MCU chip, manual calibration is not needed, chip calibration efficiency is improved, and errors are effectively reduced. In addition, fine tuning can be performed to ensure that the actual frequency value is within a preset target frequency range, and the frequency of the clock inside the chip is accurately calibrated.
Description
Technical Field
The application relates to the technical field of chips, in particular to an internal clock calibration method and circuit for an MCU chip.
Background
The micro control unit (Microcontroller Unit; MCU), also called as single-chip microcomputer or single-chip microcomputer, in MCU, the internal clock is an important component, which is equivalent to the heart of MCU, the accuracy of clock can directly influence the function and stability of the product.
The internal clock of the MCU is easily affected by the use environment, such as voltage, temperature and the like, which affect the precision of the internal clock of the MCU, and currently, the frequency of the internal clock of the MCU chip is calibrated mainly manually to improve the precision.
However, the error of the mode based on manual calibration is large, so that not only is the degree of automation low, but also the technical problems of low efficiency and the like are caused.
Disclosure of Invention
The application provides an internal clock calibration method and circuit of an MCU chip, which are used for solving the problems of large error in manual calibration mode, low automation degree and low efficiency.
In a first aspect, the present application provides a method for calibrating an internal clock of an MCU chip, including:
acquiring an actual frequency value output by an internal clock of an MCU chip, and determining whether the actual frequency value is within a preset target frequency range;
if not, determining a corresponding first calibration value according to the actual frequency value, and determining a calibration center value according to the actual frequency value, the first calibration value and the preset target frequency range;
writing the calibration center value into the MCU chip to adjust the actual frequency value of the internal clock output of the MCU chip.
Optionally, the determining the calibration center value according to the actual frequency value, the first calibration value and the preset target frequency range includes:
acquiring a slope corresponding to a preset internal clock calibration curve;
calculating a corresponding calibration range according to the slope, the actual frequency value, the first calibration value and the preset target frequency range;
and determining a central value of the calibration range as the calibration central value.
Optionally, the determining a corresponding first calibration value according to the actual frequency value includes:
and determining a calibration value corresponding to the preset frequency value matched with the actual frequency value as the first calibration value in the mapping relation between the preset frequency value and the calibration value.
Optionally, after writing the calibration center value into the MCU chip, the method further includes:
acquiring an adjusted actual frequency value output by an internal clock of the MCU chip, and determining whether the adjusted actual frequency value is within the preset target frequency range;
if not, calculating a step length calibration value according to a preset step length and a current calibration value corresponding to the adjusted actual frequency value;
writing the step length calibration value into the MCU chip, and executing the step of determining whether the adjusted actual frequency value is within the preset target frequency range until the adjusted actual frequency value stops adjusting within the preset target frequency range.
Optionally, the calculating the step calibration value according to the preset step and the current calibration value corresponding to the adjusted actual frequency value includes:
if the adjusted actual frequency value is larger than the maximum value corresponding to the preset target frequency range, subtracting the current calibration value corresponding to the adjusted actual frequency value from a preset step length to obtain the step length calibration value;
and if the adjusted actual frequency value is smaller than the minimum value corresponding to the preset target frequency range, adding the current calibration value corresponding to the adjusted actual frequency value with a preset step length to obtain the step length calibration value.
In a second aspect, the present application provides an internal clock calibration circuit of an MCU chip, including: the frequency acquisition unit is respectively connected with the MCU chip and the comparator;
the frequency acquisition unit is used for acquiring an actual frequency value output by the internal clock of the MCU chip and sending the actual frequency value to the comparator;
the comparator is used for determining whether the actual frequency value is in a preset target frequency range; if not, the actual frequency value is sent to the control unit;
the control unit is used for determining a corresponding first calibration value according to the actual frequency value and determining a calibration center value according to the actual frequency value, the first calibration value and the preset target frequency range;
the control unit is also used for writing the calibration center value into the MCU chip so as to adjust the actual frequency value output by the internal clock of the MCU chip.
The control unit is specifically configured to, when determining a calibration center value according to the actual frequency value, the first calibration value, and the preset target frequency range:
acquiring a slope corresponding to a preset internal clock calibration curve;
calculating a corresponding calibration range according to the slope, the actual frequency value, the first calibration value and the preset target frequency range;
and determining a central value of the calibration range as the calibration central value.
Optionally, the control unit is specifically configured to, when determining the corresponding first calibration value according to the actual frequency value:
obtaining a mapping relation between a preset frequency value and a calibration value;
matching the actual frequency value with a preset frequency value in the mapping relation;
and determining a calibration value corresponding to the preset frequency value matched with the actual frequency value as the first calibration value.
Optionally, the circuit further comprises: the counter is respectively connected with the chip and the control unit;
the frequency acquisition unit is further used for acquiring an adjusted actual frequency value output by the internal clock of the MCU chip and sending the adjusted actual frequency value to the comparator;
the comparator is further configured to determine whether the adjusted actual frequency value is within the preset target frequency range; if not, the adjusted actual frequency value is sent to the control unit;
the control unit is further configured to send the adjusted actual frequency value to the counter;
the counter is used for calculating a step length calibration value according to a preset step length and a current calibration value corresponding to the adjusted actual frequency value, and sending the step length calibration value to the control unit;
the control unit is also used for writing the step length calibration value into the MCU chip.
Optionally, when calculating the step calibration value according to the preset step and the current calibration value corresponding to the adjusted actual frequency value, the counter is specifically configured to:
if the adjusted actual frequency value is larger than the maximum value corresponding to the preset target frequency range, subtracting the current calibration value corresponding to the adjusted actual frequency value from a preset step length to obtain the step length calibration value;
and if the adjusted actual frequency value is smaller than the minimum value corresponding to the preset target frequency range, adding the current calibration value corresponding to the adjusted actual frequency value with a preset step length to obtain the step length calibration value.
Optionally, the control unit is connected with a display, and the display is used for displaying the actual frequency value sent by the control unit.
The method and the circuit for calibrating the internal clock of the MCU chip acquire the actual frequency value output by the internal clock of the MCU chip and determine whether the actual frequency value is in a preset target frequency range or not; if not, determining a corresponding first calibration value according to the actual frequency value, and determining a calibration center value according to the actual frequency value, the first calibration value and the preset target frequency range; the calibration center value is written into the MCU chip to adjust the actual frequency value of the internal clock output of the MCU chip, so that the clock calibration can be automatically carried out on the MCU chip without manual calibration, the chip calibration efficiency is improved, and the error is effectively reduced. In addition, fine tuning can be performed to ensure that the actual frequency value is within a preset target frequency range, and the frequency of the clock inside the chip is accurately calibrated.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic diagram of an application scenario of an internal clock calibration method of an MCU chip provided in the present application;
fig. 2 is a flow chart of an internal clock calibration method of an MCU chip provided in the present application;
FIG. 3 is a flowchart illustrating another method for calibrating an internal clock of an MCU chip according to the present application;
fig. 4 is a schematic structural diagram of an internal clock calibration circuit of an MCU chip provided in the present application;
FIG. 5 is a schematic diagram of an internal clock calibration circuit of another MCU chip provided in the present application;
fig. 6 is a schematic structural diagram of an internal clock calibration circuit and a display of an MCU chip provided in the present application.
Symbol description:
101-control unit 102-comparator 103-frequency acquisition unit
104-MCU chip 105-counter 106-display
Specific embodiments thereof have been shown by way of example in the drawings and will herein be described in more detail. These drawings and the written description are not intended to limit the scope of the inventive concepts in any way, but to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present application. Rather, they are merely examples of circuits and methods that are consistent with aspects of the present application as detailed in the accompanying claims.
For a clear understanding of the technical solutions of the present application, the prior art solutions will be described in detail first.
The micro control unit (Microcontroller Unit; MCU), also called as single-chip microcomputer or single-chip microcomputer, in MCU, the internal clock is an important component, which is equivalent to the heart of MCU, the accuracy of clock can directly influence the function and stability of the product.
The internal clock of the MCU is easily affected by the use environment, such as voltage, temperature and the like, which affect the precision of the internal clock of the MCU, and currently, the frequency of the internal clock of the MCU chip is calibrated mainly manually to improve the precision.
However, the manual calibration method has the technical problems of large error, complex algorithm, low calibration precision, low automation degree, low efficiency and the like.
Therefore, aiming at the problems of high error, low automation degree and low efficiency of the manual calibration mode in the prior art, the inventor finds out in the research that the actual frequency value output by the internal clock of the MCU chip is acquired and whether the actual frequency value is in the preset target frequency range is determined; if not, determining a corresponding first calibration value according to the actual frequency value, and determining a calibration center value according to the actual frequency value, the first calibration value and a preset target frequency range; writing the calibration center value into the MCU chip to adjust the actual frequency value of the clock output inside the MCU chip. The MCU chip can be automatically calibrated without manual calibration, so that the chip calibration efficiency is improved, and the error is effectively reduced.
The inventor proposes the technical solution of the embodiments of the present application based on the inventive findings described above. The application scenario of the data processing method provided in the embodiment of the present application is described below.
As shown in fig. 1, the application scenario corresponding to the method for calibrating the internal clock of the MCU chip provided in the embodiment of the present application includes: the MCU chip internal clock calibration device 1 comprises a control unit, a comparator and a frequency acquisition unit, the MCU chip internal clock calibration device 1 is connected with the MCU chip 2, the frequency acquisition unit of the MCU chip internal clock calibration device 1 acquires an actual frequency value output by the MCU chip internal clock, the comparator of the MCU chip internal clock calibration device 1 determines whether the actual frequency value is in a preset target frequency range, if not, the control unit of the MCU chip internal clock calibration device 1 determines a first calibration value according to the actual frequency value, the calibration center value is further calculated according to the actual frequency value, the first calibration value and the preset target frequency range, and the control unit of the MCU chip internal clock calibration device 1 writes the calibration center value into the MCU chip to adjust the actual frequency value output by the MCU chip internal clock, so that clock calibration can be automatically performed on the MCU chip without manual calibration, chip calibration efficiency is improved, and errors are effectively reduced.
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
Fig. 2 is a flow chart of an internal clock calibration method of an MCU chip provided in the present application, where the method is applied to an electronic device. Wherein the electronic device may be a digital computer representing various forms. Such as cellular telephones, smart phones, laptops, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. As shown in fig. 2, the method includes:
In this embodiment, the actual frequency value of the internal clock output of the MCU chip is collected, and it is further determined whether the actual frequency value of the internal clock output of the MCU chip is within a preset target frequency range, where the preset target frequency range may be set according to actual requirements, for example, the preset target frequency range may be set to 8mhz±0.5% by default, and the preset target frequency range may be set to [7.96,8.04] MHz, and it is determined whether the actual frequency value of the internal clock output of the MCU chip is within [7.96,8.04] MHz.
In this embodiment, if the actual frequency value output by the internal clock of the MCU chip is not within the preset target frequency range, it is indicated that calibration is required, a first calibration value is further calculated according to the actual frequency value output by the internal clock of the MCU chip, and a calibration center value is calculated according to the actual frequency value output by the internal clock of the MCU chip, the first calibration value and the preset target frequency range, and the calibration center value is adopted to facilitate subsequent fine adjustment, so as to improve calibration efficiency.
It should be noted that, if the actual frequency value of the clock output inside the MCU chip is within the preset target frequency range, calibration is not required.
And 203, writing the calibration center value into the MCU chip to adjust the actual frequency value of the internal clock output of the MCU chip.
In this embodiment, in the configuration mode, the calibration center value is written into the MCU chip, so as to adjust the actual frequency value of the internal clock output of the MCU chip.
In this embodiment, the actual frequency value output by the internal clock of the MCU chip is collected, so as to determine whether the actual frequency value is within the preset target frequency range, if not, determine the first calibration value according to the actual frequency value, further calculate the calibration center value according to the actual frequency value, the first calibration value and the preset target frequency range, write the calibration center value into the MCU chip, so as to adjust the actual frequency value output by the internal clock of the MCU chip, and thus, clock calibration can be automatically performed on the MCU chip, without manual calibration, chip calibration efficiency is improved, and errors are effectively reduced.
Fig. 3 is a flow chart of another method for calibrating an internal clock of an MCU chip provided in the present application, where the method is applied to an electronic device, as shown in fig. 3, and the method includes:
In this embodiment, the step 301 and the step 201 have the same technical features, and the detailed description will refer to the step 201, and will not be repeated here.
In one possible implementation, determining the corresponding first calibration value from the actual frequency value includes:
and determining a calibration value corresponding to the preset frequency value matched with the actual frequency value as a first calibration value in the mapping relation between the preset frequency value and the calibration value.
In this embodiment, a mapping relationship between a preset frequency value and a calibration value is obtained, where the mapping relationship may be a preset internal calibration curve, the preset frequency value in the mapping relationship corresponds to the calibration value one by one, an actual frequency value output by an internal clock of the MCU chip is matched with the preset frequency value in the mapping relationship, and the calibration value corresponding to the preset frequency value matched with the actual frequency value is determined as a first calibration value.
In one possible implementation, determining the calibration center value according to the actual frequency value, the first calibration value, and the preset target frequency range includes:
acquiring a slope corresponding to a preset internal clock calibration curve; calculating a corresponding calibration range according to the slope, the actual frequency value, the first calibration value and a preset target frequency range; the center value of the calibration range is determined as the calibration center value.
In this embodiment, a slope corresponding to a preset internal clock calibration curve is obtained, and the preset internal clock calibration curve is obtained through a test in advance. Before calculating the calibration range, the magnitude relation between the actual frequency value output by the internal clock of the MCU chip and the minimum value and the maximum value corresponding to the preset target frequency range needs to be compared, if the actual frequency value output by the internal clock of the MCU chip is larger than the maximum value corresponding to the preset target frequency range, the slope, the actual frequency value, the first calibration value and the preset target frequency range are substituted into a formula (1), the calibration value range is calculated, and the formula (1) is:
wherein T is rimo Represents a range of calibration values, f i For the actual frequency value, f o Represents a preset target frequency range, f o Can be set as [7.96,8.04]]MHz, d is slope, T rim1 Is the first calibration value.
Further, if the actual frequency value output by the internal clock of the MCU chip is smaller than the minimum value corresponding to the preset target frequency range, substituting the slope, the actual frequency value, the first calibration value and the preset target frequency range into the formula (2), and calculating the calibration value range, where the formula (2) is:
wherein T is rimo Represents a range of calibration values, f i For the actual frequency value, f o Represents a preset target frequency range, f o Can be set as [7.96,8.04]]MHz, d is slope, T rim1 Is the first calibration value.
Further, a center value is selected from the calibration range, the center value of the calibration range is determined to be the calibration center value, and the calibration center value is selected so as to facilitate subsequent fine adjustment.
In step 303, the calibration center value is written into the MCU chip to adjust the actual frequency value of the clock output inside the MCU chip.
In this embodiment, the step 303 and the step 203 have the same technical features, and the detailed description will refer to the step 203, which is not described herein.
In this embodiment, the adjusted actual frequency value output by the internal clock of the MCU chip is collected, and it is determined whether the adjusted actual frequency value is within the preset target frequency range, and if the adjusted actual frequency value of the internal clock of the MCU chip is within the preset target frequency range, recalibration is not required.
In this embodiment, if the actual frequency value after the internal clock of the MCU chip is adjusted is not within the preset target frequency range, it is described that fine adjustment is further required to be performed on the MCU chip to perform recalibration, and further, the step calibration value is calculated according to the preset step and the current calibration value corresponding to the adjusted actual frequency value, where the preset step may be set to 1, and before calculating the step calibration value, the magnitude relation between the actual frequency value after the internal clock of the MCU chip is adjusted and the minimum value and the maximum value in the preset target frequency range needs to be compared, and the step calibration value is calculated according to the comparison result.
Optionally, calculating the step calibration value according to the preset step and the current calibration value corresponding to the adjusted actual frequency value includes:
if the adjusted actual frequency value is larger than the maximum value corresponding to the preset target frequency range, subtracting the current calibration value corresponding to the adjusted actual frequency value from the preset step length to obtain a step length calibration value; if the adjusted actual frequency value is smaller than the minimum value corresponding to the preset target frequency range, adding the current calibration value corresponding to the adjusted actual frequency value with the preset step length to obtain a step length calibration value.
In this embodiment, if the adjusted actual frequency value is greater than the maximum value corresponding to the preset target frequency range, the current calibration value corresponding to the adjusted actual frequency value is subtracted from the preset step length, for example, the preset step length may be set to 1, and the current calibration value corresponding to the adjusted actual frequency value is subtracted from 1 to obtain the step length calibration value. If the adjusted actual frequency value is smaller than the minimum value corresponding to the preset target frequency range, adding the current calibration value corresponding to the adjusted actual frequency value to a preset step length, and if the current calibration value corresponding to the adjusted actual frequency value is added to 1, obtaining a step length calibration value. And fine tuning the frequency value by adopting the step length calibration value. It should be noted that the preset step size is not limited to the above values, and may be set according to practical situations.
In this embodiment, the step calibration value is written into the MCU chip to readjust the actual frequency value output by the internal clock of the MCU chip, and after each adjustment, it needs to be determined again whether the calibration result needs to be trimmed, and whether the adjusted actual frequency value is within the preset target frequency range is determined until the adjusted actual frequency value stops adjusting within the preset target frequency range.
In this embodiment, clock calibration can be automatically performed on the MCU chip, manual calibration is not required, chip calibration efficiency is improved, errors are effectively reduced, and fine adjustment can be performed to ensure that an actual frequency value is within a preset target frequency range, and the frequency of the clock inside the chip is accurately calibrated.
Fig. 4 is a schematic structural diagram of an internal clock calibration circuit of an MCU chip provided in the present application, as shown in fig. 4, the internal clock calibration circuit of an MCU chip provided in the present application mainly includes: the device comprises a control unit 101, a comparator 102 and a frequency acquisition unit 103, wherein the control unit 101 is respectively connected with an MCU chip 104 and the comparator 102, and the frequency acquisition unit 103 is respectively connected with the MCU chip 104 and the comparator 102.
Specifically, the frequency acquisition unit 103 is configured to acquire an actual frequency value output by an internal clock of the MCU chip 104, and send the actual frequency value to the comparator 102; a comparator 102 for determining whether the actual frequency value is within a preset target frequency range; if not, the actual frequency value is sent to the control unit 101; a control unit 101, configured to determine a corresponding first calibration value according to the actual frequency value, and determine a calibration center value according to the actual frequency value, the first calibration value, and a preset target frequency range; the control unit 101 is further configured to write the calibration center value into the MCU chip 104, so as to adjust an actual frequency value of the clock output inside the MCU chip 104.
Optionally, the internal clock calibration circuit of the MCU chip is used for calibrating the MCU chip 104, the internal clock calibration needs to be performed on the MCU chip before the output, the internal clock calibration circuit of the MCU chip is connected with the MCU chip 104, specifically, the frequency acquisition unit 103 of the internal clock calibration circuit of the MCU chip is connected with the MCU chip 104, the frequency acquisition unit 103 is used for acquiring an actual frequency value of the internal clock output of the MCU chip 104, and the frequency acquisition unit 103 sends the acquired actual frequency value of the internal clock output of the MCU chip 104 to the comparator 102.
Optionally, the comparator 102 is configured to determine whether the actual frequency value of the internal clock output of the MCU chip 104 is within a preset target frequency range, where the preset target frequency range may be set according to actual requirements, for example, the high-speed crystal oscillator in the MCU chip 104 is usually calibrated to 8mhz±0.5% by default, the preset target frequency range may be set to [7.96,8.04] MHz, and whether the actual frequency value of the internal clock output of the MCU chip 104 is within [7.96,8.04] MHz is determined. If the actual frequency value of the internal clock output of the MCU chip 104 is not within the preset target frequency range, the comparator 102 indicates that calibration is required, and the comparator 102 sends the actual frequency value of the internal clock output of the MCU chip 104 to the control unit 101.
In addition, the control unit 101 is configured to calculate a first calibration value according to an actual frequency value output by the internal clock of the MCU chip 104, calculate a calibration center value according to the actual frequency value output by the internal clock of the MCU chip 104, the first calibration value and a preset target frequency range, and use the calibration center value to facilitate subsequent fine adjustment, so as to improve calibration efficiency. The control unit 101 is further configured to write the calibration center value to the MCU chip 104, thereby adjusting an actual frequency value of the clock output inside the MCU chip 104.
The clock calibration circuit inside the MCU chip can automatically calibrate the clock of the MCU chip without manual calibration, so that the chip calibration efficiency is improved, and the error is effectively reduced.
Optionally, the control unit is specifically configured to, when determining the corresponding first calibration value according to the actual frequency value: obtaining a mapping relation between a preset frequency value and a calibration value; matching the actual frequency value with a preset frequency value in the mapping relation; and determining a calibration value corresponding to the preset frequency value matched with the actual frequency value as a first calibration value.
Specifically, the control unit is further configured to obtain a mapping relationship between a preset frequency value and a calibration value, where the mapping relationship may be a preset internal calibration curve, the preset frequency value in the mapping relationship corresponds to the calibration value one by one, and the control unit is further configured to match an actual frequency value output by an internal clock of the MCU chip with the preset frequency value in the mapping relationship, and determine, as the first calibration value, a calibration value corresponding to the preset frequency value matched with the actual frequency value.
Optionally, when determining the calibration center value according to the actual frequency value, the first calibration value and the preset target frequency range, the control unit is specifically configured to: acquiring a slope corresponding to a preset internal clock calibration curve; calculating a corresponding calibration range according to the slope, the actual frequency value, the first calibration value and a preset target frequency range; the center value of the calibration range is determined as the calibration center value.
The control unit is used for acquiring a slope corresponding to a preset internal clock calibration curve, and the preset internal clock calibration curve is obtained through a test in advance. Before the control unit calculates the calibration range, the magnitude relation between the actual frequency value output by the internal clock of the MCU chip and the minimum value and the maximum value corresponding to the preset target frequency range needs to be compared, if the actual frequency value output by the internal clock of the MCU chip is greater than the maximum value corresponding to the preset target frequency range, the slope, the actual frequency value, the first calibration value and the preset target frequency range are substituted into the formula (3), the calibration value range is calculated, and the formula (3) is:
wherein T is rimo Represents a range of calibration values, f i For the actual frequency value, f o Represents a preset target frequency range, f o Can be set as [7.96,8.04]]MHz, d is slope, T rim1 Is the first calibration value.
Further, if the actual frequency value output by the internal clock of the MCU chip is smaller than the minimum value corresponding to the preset target frequency range, the control unit substitutes the slope, the actual frequency value, the first calibration value and the preset target frequency range into the formula (4), and calculates the calibration value range, where the formula (4) is:
wherein T is rimo Represents a range of calibration values, f i For the actual frequency value, f o Represents a preset target frequency range, f o Can be set as [7.96,8.04]]MHz, d is slope, T rim1 Is the first calibration value.
Further, a center value is selected from the calibration range, the center value of the calibration range is determined to be the calibration center value, and the calibration center value is selected so as to facilitate subsequent fine adjustment.
Fig. 5 is a schematic structural diagram of another internal clock calibration circuit of an MCU chip provided in the present application, where, on the basis of the embodiment shown in fig. 4, the circuit in fig. 5 further includes: the counter 105, the counter 105 is connected with the chip and the control unit 101 respectively.
Specifically, the frequency acquisition unit 103 is further configured to acquire an adjusted actual frequency value output by an internal clock of the MCU chip 104, and send the adjusted actual frequency value to the comparator 102; the comparator 102 is further configured to determine whether the adjusted actual frequency value is within a preset target frequency range; if not, the adjusted actual frequency value is sent to the control unit 101; the control unit 101 is further configured to send the adjusted actual frequency value to the counter 105; a counter 105, configured to calculate a step calibration value according to a preset step and a current calibration value corresponding to the adjusted actual frequency value, and send the step calibration value to the control unit 101; the control unit 101 is further configured to write a step calibration value to the MCU chip 104.
Optionally, the frequency acquisition unit 103 is further configured to acquire an adjusted actual frequency value output by the internal clock of the MCU chip 104, and the frequency acquisition unit 103 is further configured to send the adjusted actual frequency value to the comparator 102.
Optionally, the comparator 102 is further configured to determine whether the adjusted actual frequency value is within a preset target frequency range, and if the adjusted actual frequency value of the internal clock of the MCU chip 104 is not within the preset target frequency range, the MCU chip 104 needs to be fine-tuned to perform recalibration, and the comparator 102 sends the adjusted actual frequency value to the control unit 101.
The control unit 101 transmits the adjusted actual frequency value to the counter 105, and calculates the actual frequency value by the timer. Specifically, the counter 105 is configured to calculate a step calibration value according to a current calibration value corresponding to a preset step and an adjusted actual frequency value, where the preset step may be set to 1, and before calculating the step calibration value, a magnitude relation between the adjusted actual frequency value of the internal clock of the MCU chip 104 and a minimum value and a maximum value in a preset target frequency range needs to be compared, and the step calibration value is calculated according to a comparison result. The calculator sends the step calibration value to the control unit 101.
Optionally, the control unit 101 is further configured to write a step calibration value to the MCU chip 104, so as to readjust the actual frequency value of the clock output inside the MCU chip 104.
Optionally, when calculating the step calibration value according to the current calibration value corresponding to the preset step and the adjusted actual frequency value, the counter 105 is specifically configured to: if the adjusted actual frequency value is larger than the maximum value corresponding to the preset target frequency range, subtracting the current calibration value corresponding to the adjusted actual frequency value from the preset step length to obtain a step length calibration value; if the adjusted actual frequency value is smaller than the minimum value corresponding to the preset target frequency range, adding the current calibration value corresponding to the adjusted actual frequency value with the preset step length to obtain a step length calibration value.
Specifically, the counter 105 is further configured to subtract the current calibration value corresponding to the adjusted actual frequency value from the preset step length if the adjusted actual frequency value is greater than the maximum value corresponding to the preset target frequency range, that is, subtract the current calibration value corresponding to the adjusted actual frequency value from 1, and take the difference value as the step length calibration value. The counter 105 is further configured to, if the adjusted actual frequency value is smaller than the minimum value corresponding to the preset target frequency range, add the current calibration value corresponding to the adjusted actual frequency value to the preset step size, i.e. add the current calibration value corresponding to the adjusted actual frequency value to 1, and use the sum as the step size calibration value. And fine tuning the frequency value by adopting the step length calibration value. It should be noted that the preset step size is not limited to the above values, and may be set according to practical situations.
Optionally, referring to fig. 6, the control unit 101 is connected to a display 106, and the display 106 is used for displaying the actual frequency value sent by the control unit 101, so as to facilitate the debugging personnel to check the value.
The internal clock calibration circuit of the MCU chip can automatically calibrate the clock of the MCU chip without manual calibration, so that the chip calibration efficiency is improved, errors are effectively reduced, fine adjustment can be performed, the actual frequency value is ensured to be within the preset target frequency range, and the internal clock calibration circuit of the MCU chip can accurately calibrate the frequency of the internal clock of the chip.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the present application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.
Claims (11)
1. An internal clock calibration method for an MCU chip, which is characterized by comprising the following steps:
acquiring an actual frequency value output by an internal clock of an MCU chip, and determining whether the actual frequency value is within a preset target frequency range;
if not, determining a corresponding first calibration value according to the actual frequency value, and determining a calibration center value according to the actual frequency value, the first calibration value and the preset target frequency range;
writing the calibration center value into the MCU chip to adjust the actual frequency value of the internal clock output of the MCU chip.
2. The method of claim 1, wherein the determining a calibration center value from the actual frequency value, the first calibration value, and the preset target frequency range comprises:
acquiring a slope corresponding to a preset internal clock calibration curve;
calculating a corresponding calibration range according to the slope, the actual frequency value, the first calibration value and the preset target frequency range;
and determining a central value of the calibration range as the calibration central value.
3. The method of claim 1, wherein said determining a corresponding first calibration value from said actual frequency value comprises:
and determining a calibration value corresponding to the preset frequency value matched with the actual frequency value as the first calibration value in the mapping relation between the preset frequency value and the calibration value.
4. A method according to any one of claims 1 to 3, wherein after writing the calibration center value to the MCU chip, further comprising:
acquiring an adjusted actual frequency value output by an internal clock of the MCU chip, and determining whether the adjusted actual frequency value is within the preset target frequency range;
if not, calculating a step length calibration value according to a preset step length and a current calibration value corresponding to the adjusted actual frequency value;
writing the step length calibration value into the MCU chip, and executing the step of determining whether the adjusted actual frequency value is within the preset target frequency range until the adjusted actual frequency value stops adjusting within the preset target frequency range.
5. The method of claim 4, wherein calculating a step calibration value from a current calibration value corresponding to the preset step and the adjusted actual frequency value comprises:
if the adjusted actual frequency value is larger than the maximum value corresponding to the preset target frequency range, subtracting the current calibration value corresponding to the adjusted actual frequency value from a preset step length to obtain the step length calibration value;
and if the adjusted actual frequency value is smaller than the minimum value corresponding to the preset target frequency range, adding the current calibration value corresponding to the adjusted actual frequency value with a preset step length to obtain the step length calibration value.
6. An MCU chip internal clock calibration circuit, the circuit comprising: the frequency acquisition unit is respectively connected with the MCU chip and the comparator;
the frequency acquisition unit is used for acquiring an actual frequency value output by the internal clock of the MCU chip and sending the actual frequency value to the comparator;
the comparator is used for determining whether the actual frequency value is in a preset target frequency range; if not, the actual frequency value is sent to the control unit;
the control unit is used for determining a corresponding first calibration value according to the actual frequency value and determining a calibration center value according to the actual frequency value, the first calibration value and the preset target frequency range;
the control unit is also used for writing the calibration center value into the MCU chip so as to adjust the actual frequency value output by the internal clock of the MCU chip.
7. The circuit of claim 6, wherein the control unit is configured to, when determining a calibration center value based on the actual frequency value, the first calibration value, and the preset target frequency range:
acquiring a slope corresponding to a preset internal clock calibration curve;
calculating a corresponding calibration range according to the slope, the actual frequency value, the first calibration value and the preset target frequency range;
and determining a central value of the calibration range as the calibration central value.
8. The circuit according to claim 6, wherein the control unit, when determining the corresponding first calibration value from the actual frequency value, is specifically configured to:
obtaining a mapping relation between a preset frequency value and a calibration value;
matching the actual frequency value with a preset frequency value in the mapping relation;
and determining a calibration value corresponding to the preset frequency value matched with the actual frequency value as the first calibration value.
9. The circuit of claim 6, wherein the circuit further comprises: the counter is respectively connected with the chip and the control unit;
the frequency acquisition unit is further used for acquiring an adjusted actual frequency value output by the internal clock of the MCU chip and sending the adjusted actual frequency value to the comparator;
the comparator is further configured to determine whether the adjusted actual frequency value is within the preset target frequency range; if not, the adjusted actual frequency value is sent to the control unit;
the control unit is further configured to send the adjusted actual frequency value to the counter;
the counter is used for calculating a step length calibration value according to a preset step length and a current calibration value corresponding to the adjusted actual frequency value, and sending the step length calibration value to the control unit;
the control unit is also used for writing the step length calibration value into the MCU chip.
10. The circuit according to claim 9, wherein the counter is configured to, when calculating the step calibration value from a preset step and a current calibration value corresponding to the adjusted actual frequency value:
if the adjusted actual frequency value is larger than the maximum value corresponding to the preset target frequency range, subtracting the current calibration value corresponding to the adjusted actual frequency value from a preset step length to obtain the step length calibration value;
and if the adjusted actual frequency value is smaller than the minimum value corresponding to the preset target frequency range, adding the current calibration value corresponding to the adjusted actual frequency value with a preset step length to obtain the step length calibration value.
11. A circuit according to any one of claims 6 to 10, wherein the control unit is connected to a display for displaying the actual frequency values transmitted by the control unit.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310209845.0A CN116185128B (en) | 2023-03-06 | 2023-03-06 | MCU chip internal clock calibration method and circuit |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310209845.0A CN116185128B (en) | 2023-03-06 | 2023-03-06 | MCU chip internal clock calibration method and circuit |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116185128A true CN116185128A (en) | 2023-05-30 |
CN116185128B CN116185128B (en) | 2024-05-17 |
Family
ID=86448640
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310209845.0A Active CN116185128B (en) | 2023-03-06 | 2023-03-06 | MCU chip internal clock calibration method and circuit |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116185128B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117938154A (en) * | 2024-02-20 | 2024-04-26 | 广芯微电子(广州)股份有限公司 | Method for calibrating clock source frequency in chip |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20070063241A (en) * | 2005-12-14 | 2007-06-19 | 어보브반도체 주식회사 | Calibration device of the frequency and calibration method of the frequency using the same |
CN101322369A (en) * | 2005-12-01 | 2008-12-10 | 汤姆逊许可公司 | Method and device for confirming frequency offset of receiver |
CN109283967A (en) * | 2018-11-20 | 2019-01-29 | 深圳芯邦科技股份有限公司 | A kind of micro-control unit MCU clock correcting method and relevant device |
CN110174922A (en) * | 2019-04-15 | 2019-08-27 | 合肥格易集成电路有限公司 | A kind of calibration method and device of HSI clock frequency |
CN113034620A (en) * | 2021-04-29 | 2021-06-25 | 京东方科技集团股份有限公司 | Correction method, correction device, computer-readable storage medium, and computer apparatus |
CN113377155A (en) * | 2021-06-08 | 2021-09-10 | 深圳市汇顶科技股份有限公司 | Clock calibration method and device and electronic equipment |
JP2021189037A (en) * | 2020-05-29 | 2021-12-13 | セイコーエプソン株式会社 | Real time clock circuit, real time clock module, electronic apparatus and correction method for real time clock circuit |
US20220149824A1 (en) * | 2020-11-12 | 2022-05-12 | Lx Semicon Co., Ltd. | Frequency generator and method of calibrating frequency thereof |
-
2023
- 2023-03-06 CN CN202310209845.0A patent/CN116185128B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101322369A (en) * | 2005-12-01 | 2008-12-10 | 汤姆逊许可公司 | Method and device for confirming frequency offset of receiver |
KR20070063241A (en) * | 2005-12-14 | 2007-06-19 | 어보브반도체 주식회사 | Calibration device of the frequency and calibration method of the frequency using the same |
CN109283967A (en) * | 2018-11-20 | 2019-01-29 | 深圳芯邦科技股份有限公司 | A kind of micro-control unit MCU clock correcting method and relevant device |
CN110174922A (en) * | 2019-04-15 | 2019-08-27 | 合肥格易集成电路有限公司 | A kind of calibration method and device of HSI clock frequency |
JP2021189037A (en) * | 2020-05-29 | 2021-12-13 | セイコーエプソン株式会社 | Real time clock circuit, real time clock module, electronic apparatus and correction method for real time clock circuit |
US20220149824A1 (en) * | 2020-11-12 | 2022-05-12 | Lx Semicon Co., Ltd. | Frequency generator and method of calibrating frequency thereof |
CN113034620A (en) * | 2021-04-29 | 2021-06-25 | 京东方科技集团股份有限公司 | Correction method, correction device, computer-readable storage medium, and computer apparatus |
CN113377155A (en) * | 2021-06-08 | 2021-09-10 | 深圳市汇顶科技股份有限公司 | Clock calibration method and device and electronic equipment |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117938154A (en) * | 2024-02-20 | 2024-04-26 | 广芯微电子(广州)股份有限公司 | Method for calibrating clock source frequency in chip |
Also Published As
Publication number | Publication date |
---|---|
CN116185128B (en) | 2024-05-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109462446A (en) | A kind of RF calibration method, apparatus and computer readable storage medium | |
CN116185128B (en) | MCU chip internal clock calibration method and circuit | |
CN107272821B (en) | Real-time clock calibration method and device, storage medium and electronic equipment | |
CN109283967B (en) | MCU clock calibration method and related equipment | |
US20100210231A1 (en) | Compensation method of radio frequency module performance and radio frequency module | |
CN105259528B (en) | A kind of the internal calibration circuit and calibration method of microwave power probe | |
US8422959B2 (en) | Compensating method for capacity of radio frequency module and a radio frequency module | |
CN105388445A (en) | Automatic meter calibration method for single-phase electric energy meter | |
US20240069591A1 (en) | Clock calibration method and electronic device | |
CN109444547B (en) | RFID chip impedance measuring method and device based on two-port network | |
WO2016206384A1 (en) | Crystal oscillator circuit, crystal oscillator circuit tuning method, and storage medium | |
US11356105B2 (en) | Method for calibrating crystal frequency offset through internal loop of central processing unit | |
CN114499521A (en) | Signal calibration method and device, computer equipment and storage medium | |
CN113377155A (en) | Clock calibration method and device and electronic equipment | |
CN115993565A (en) | Error compensation method for radio frequency chip test system | |
CN114201001A (en) | Compensation method and device of real-time clock, terminal equipment and medium | |
CN114421977A (en) | Quick calibration device and method for frequency of crystal oscillator for communication equipment | |
US9231810B2 (en) | Carrier frequency offset calibration method | |
CN104467701B (en) | A kind of voltage correction method and electric terminal of power amplifier | |
CN114500209B (en) | Frequency offset compensation method, system, electronic equipment and computer readable storage medium | |
CN112083226A (en) | Frequency calibration method and device for electronic equipment, medium and electronic equipment | |
JP7528049B2 (en) | Oscillator circuit with negative resistance margin test | |
CN111964836B (en) | Barometer calibration method and device and electronic equipment | |
CN108900181B (en) | Clock delay adjusting device and clock delay adjusting system | |
CN114866033B (en) | Crystal oscillator aging compensation method and system, terminal device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |