CN116185128B - MCU chip internal clock calibration method and circuit - Google Patents

MCU chip internal clock calibration method and circuit Download PDF

Info

Publication number
CN116185128B
CN116185128B CN202310209845.0A CN202310209845A CN116185128B CN 116185128 B CN116185128 B CN 116185128B CN 202310209845 A CN202310209845 A CN 202310209845A CN 116185128 B CN116185128 B CN 116185128B
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.)
Active
Application number
CN202310209845.0A
Other languages
Chinese (zh)
Other versions
CN116185128A (en
Inventor
王佐
葛俊
苏振权
李鹏
余景亮
曾豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhuhai Geehy Semiconductor Co Ltd
Original Assignee
Zhuhai Geehy Semiconductor Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhuhai Geehy Semiconductor Co Ltd filed Critical Zhuhai Geehy Semiconductor Co Ltd
Priority to CN202310209845.0A priority Critical patent/CN116185128B/en
Publication of CN116185128A publication Critical patent/CN116185128A/en
Application granted granted Critical
Publication of CN116185128B publication Critical patent/CN116185128B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/04Generating or distributing clock signals or signals derived directly therefrom
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy 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 a method and a circuit for calibrating an internal clock of an MCU chip. 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. The method can automatically calibrate the clock of the MCU chip without manual calibration, improves the chip calibration efficiency and effectively reduces errors. 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

MCU chip internal clock calibration method and circuit
Technical Field
The application relates to the technical field of chips, in particular to an internal clock calibration method and circuit of 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 part, 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 larger, so that the automatic degree is low, and the technical problems of low efficiency and the like are caused.
Disclosure of Invention
The application provides a method and a circuit for calibrating an internal clock of an MCU chip, which are used for solving the problems of large error, low automation degree and low efficiency of manual calibration.
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 for an MCU chip, 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.
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.
According to the MCU chip internal clock calibration method and circuit provided by the application, the actual frequency value output by the MCU chip internal clock is collected, and whether the actual frequency value is in the preset target frequency range or not 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 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 by the present application;
FIG. 2 is a schematic flow chart of a method for calibrating an internal clock of an MCU chip according to 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 diagram of an internal clock calibration circuit of an MCU chip according to the present application;
FIG. 5 is a schematic diagram of an internal clock calibration circuit of another MCU chip according to the present application;
fig. 6 is a schematic structural diagram of an internal clock calibration circuit and a display of an MCU chip according to the present application.
Symbol description:
101-control unit 102-comparator 103-frequency acquisition unit
104-MCU chip 105-counter 106-display
Specific embodiments of the present application have been shown by way of the above drawings and will be described in more detail below. The drawings and the written description are not intended to limit the scope of the inventive concepts in any way, but rather to illustrate the inventive concepts to those skilled in the art by reference to the 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 do not represent all implementations consistent with the application. Rather, they are merely examples of circuits and methods that are consistent with aspects of the 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 part, 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 mode has larger error, the algorithm is more complex, the calibration precision is not high, the degree of automation is low, and the technical problems of lower efficiency and the like are caused.
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 scheme of the embodiment of the application based on the creative discovery. The application scenario of the data processing method provided by the embodiment of the 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 by 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 according to 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:
Step 201, collecting an actual frequency value output by an internal clock of the MCU chip, and determining whether the actual frequency value is within a preset target frequency range.
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.
Step 202, 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.
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 according to the present application, where the method is applied to an electronic device, as shown in fig. 3, and the method includes:
step 301, collecting an actual frequency value output by an internal clock of the MCU chip, and determining whether the actual frequency value is within a preset target frequency range.
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.
Step 302, 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.
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 rimo represents the calibration value range, f i represents the actual frequency value, f o represents the preset target frequency range, f o can be set to [7.96,8.04] MHz, d is the slope, and 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 rimo represents the calibration value range, f i represents the actual frequency value, f o represents the preset target frequency range, f o can be set to [7.96,8.04] MHz, d is the slope, and 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.
Step 304, the adjusted actual frequency value output by the internal clock of the MCU chip is collected, and whether the adjusted actual frequency value is within a preset target frequency range is determined.
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.
Step 305, if not, calculating a step calibration value according to the preset step and the current calibration value corresponding to the adjusted actual frequency value.
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.
Step 306, writing the step 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.
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 according to the present application, and as shown in fig. 4, the internal clock calibration circuit of an MCU chip according to 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 rimo represents the calibration value range, f i represents the actual frequency value, f o represents the preset target frequency range, f o can be set to [7.96,8.04] MHz, d is the slope, and 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 rimo represents the calibration value range, f i represents the actual frequency value, f o represents the preset target frequency range, f o can be set to [7.96,8.04] MHz, d is the slope, and 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 according to 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 application will be apparent to those skilled in the art from consideration of the specification and practice of the application 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 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 (5)

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 output by the internal clock of the MCU chip;
The determining a 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;
Determining a central value of the calibration range as the calibration central value, wherein the calibration central value is used for subsequent fine adjustment so as to improve the calibration efficiency;
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 to readjust the actual frequency value output by the internal clock of the MCU chip, determining whether the calibration result needs to be finely tuned again after each adjustment, and executing the step of determining whether the adjusted actual frequency value is in the preset target frequency range until the adjusted actual frequency value stops adjusting in the preset target frequency range;
the step length calibration value calculating according to the preset step length and the current calibration value corresponding to the adjusted actual frequency value comprises the following steps:
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.
2. 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.
3. An MCU chip internal clock calibration circuit, the circuit comprising: the frequency acquisition unit is respectively connected with the MCU chip and the comparator, and the counter is respectively connected with the chip and the control unit;
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;
determining a center value of the calibration range as the calibration center value;
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 counter is specifically configured to, when calculating a step calibration value according to 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;
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;
the control unit is also used for writing the step length calibration value into the MCU chip.
4. A circuit according to claim 3, 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.
5. A circuit according to claim 3 or 4, wherein the control unit is connected to a display for displaying the actual frequency values transmitted by the control unit.
CN202310209845.0A 2023-03-06 2023-03-06 MCU chip internal clock calibration method and circuit Active CN116185128B (en)

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 CN116185128A (en) 2023-05-30
CN116185128B true 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)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117938154B (en) * 2024-02-20 2024-09-17 广芯微电子(广州)股份有限公司 Method for calibrating clock source frequency in chip

Citations (7)

* Cited by examiner, † Cited by third party
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

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20220064637A (en) * 2020-11-12 2022-05-19 주식회사 엘엑스세미콘 Frequency Generator and Method of Calibrating Frequency Thereof

Patent Citations (7)

* Cited by examiner, † Cited by third party
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
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

Also Published As

Publication number Publication date
CN116185128A (en) 2023-05-30

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
US20100210231A1 (en) Compensation method of radio frequency module performance and radio frequency module
CN107272821B (en) Real-time clock calibration method and device, storage medium and electronic equipment
CN105388445A (en) Automatic meter calibration method for single-phase electric energy meter
US20240069591A1 (en) Clock calibration method and electronic device
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
CN113377155A (en) Clock calibration method and device and electronic equipment
CN114499521A (en) Signal calibration method and device, computer equipment and storage medium
CN113114108A (en) Method for estimating crystal oscillator frequency
CN115993565A (en) Error compensation method for radio frequency chip test system
CN114421977A (en) Quick calibration device and method for frequency of crystal oscillator for communication equipment
CN114201001A (en) Compensation method and device of real-time clock, terminal equipment and medium
US9231810B2 (en) Carrier frequency offset calibration method
CN104467701B (en) A kind of voltage correction method and electric terminal of power amplifier
CN112083226A (en) Frequency calibration method and device for electronic equipment, medium and electronic equipment
CN114500209B (en) Frequency offset compensation method, system, electronic equipment and computer readable storage medium
CN111026232A (en) Clock calibration method, chip and electronic equipment
JP7528049B2 (en) Oscillator circuit with negative resistance margin test
CN114553330A (en) Compensation processing method, device, processor and storage medium for improving influence of environmental temperature on radio frequency output aiming at signal source
CN108900181B (en) Clock delay adjusting device and clock delay adjusting system
CN113328744A (en) Method for calibrating high-precision PLL output frequency in broadband transceiver chip
US10222419B2 (en) Method, system and apparatus for tuning an integrated embedded subsystem
CN117348686B (en) Clock signal temperature drift correction method, circuit, chip and electronic equipment

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