MCU internal clock calibration method, system and chip based on ATE equipment

By using ATE equipment inside the MCU to capture a high-precision clock and adjust the binary operation rules, the problem of high cost and long time-consuming clock calibration inside the MCU is solved, and efficient and low-cost clock calibration is achieved.

CN117539323BActive Publication Date: 2024-10-18SHENZHEN HANGSHUN CHIP TECH DEV CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311519026.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-14
Publication Date
2024-10-18
Estimated Expiration
2043-11-14

AI Technical Summary

Technical Problem

Existing MCU internal clock calibration solutions based on timer capture require additional frequency division circuits or external high-frequency and high-precision clocks, resulting in high cost and long calibration time.

Method used

Adopt a method based on ATE equipment, use the internal clock of the calibrated MCU as the working clock of the timer, capture the high-precision clock generated by ATE, and adjust the value of the internal clock register bit by bit from high to low through the binary operation rule to obtain the calibrated Internal clock.

Benefits of technology

On the premise of ensuring calibration accuracy, it reduces test costs, avoids the need to design frequency division circuits, reduces chip manufacturing costs, improves the applicable scope of ATE equipment, and simplifies the calibration process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117539323B_ABST
    Figure CN117539323B_ABST
Patent Text Reader

Abstract

The present invention provides an MCU internal clock calibration method, system and chip based on ATE equipment, which specifically relates to the field of semiconductor technology. The scheme includes: starting the internal clock of the MCU and obtaining the target calibration frequency of the internal clock; determining the frequency of the ATE clock based on the target calibration frequency, the frequency of the ATE clock being the reference frequency; obtaining a typical value based on the reference frequency and the target calibration frequency; using the internal clock to capture the real-time frequency of the ATE clock, initializing the values ​​of each bit of the register of the internal clock, and constructing a binary operation rule based on the real-time frequency and the typical value, adjusting the value of the corresponding bit bit by bit from the high bit to the low bit, and obtaining the calibrated internal clock. The scheme can improve the calibration accuracy, reduce the test cost and chip manufacturing cost, and has low performance requirements for the ATE equipment, which can improve the application scope of the ATE equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of semiconductor technology, and in particular to an MCU internal clock calibration method, system and chip based on ATE equipment. Background Art

[0002] At present, with the rapid development of science and technology, the demand for microcontroller chips (Microcontroller Unit, MCU), also known as single-chip microcomputers, is increasing in the fields of smart home, medical care, automobiles, etc., and the accuracy requirements for MCU chips are also getting higher and higher. In order to work properly without designing an oscillation circuit outside the MCU, MCU manufacturers will design one or more internal clock signals, that is, internal RC oscillators. Due to the manufacturing process, the accuracy and stability of the internal clock are relatively low compared to the external clock. In order to meet the requirements of normal operation, the clock usually needs to be calibrated.

[0003] Among the existing solutions based on timer (TIM) capture, some add a frequency division circuit to output the calibrated clock signal inside the MCU through the frequency division circuit. This solution will produce a certain error due to the frequency division of the frequency division circuit, and the frequency multiplication operation will further increase the error. Moreover, when the number of bits of the register for adjusting the internal clock is large, the algorithm is too complicated, the calibration takes a long time, and the cost is high. Some provide a clock signal source from the outside, start two counting units inside the MCU, the first counting unit is used to accumulate the number of external reference clocks, and the second counting unit is used to accumulate the number of clocks of the clock generation component inside the monitoring chip, and then calculate the difference between the two clock numbers, and adjust the internal register value based on the difference for calibration. This solution requires the use of an external clock to generate a high-frequency and high-precision clock signal, which is costly and time-consuming to calibrate. Summary of the invention

[0004] In view of the above-mentioned deficiencies in the prior art, the purpose of the present invention is to provide an MCU internal clock calibration method, system and chip based on ATE equipment, aiming to solve the problem that the existing timer capture-based solution requires additional frequency division circuits or external high-frequency and high-precision clocks, resulting in high costs and long calibration time.

[0005] In order to achieve the above object, the first aspect of the present invention provides an MCU internal clock calibration method based on ATE equipment, comprising:

[0006] Starting an internal clock of the MCU and obtaining a target calibration frequency of the internal clock;

[0007] Based on the target calibration frequency, determining the frequency of the ATE clock, the frequency of the ATE clock being a reference frequency;

[0008] Based on the reference frequency and the target calibration frequency, obtaining a typical value;

[0009] The real-time frequency of the ATE clock is captured by the internal clock, the value of each bit of the register of the internal clock is initialized, and based on the real-time frequency and the typical value, a binary operation rule is constructed to adjust the value of the corresponding bit bit by bit from the high bit to the low bit to obtain a calibrated internal clock.

[0010] Optionally, the initializing the value of each bit of the register of the internal clock, and constructing a binary operation rule based on the real-time frequency and the typical value, adjusting the value of the corresponding bit bit by bit from the high bit to the low bit in turn, to obtain the calibrated internal clock, includes:

[0011] Initialize the value of each bit of the register of the internal clock to obtain the intermediate value of the register in binary;

[0012] Based on the intermediate value, using the internal clock to capture the real-time frequency of the ATE clock, and obtaining a captured value based on the real-time frequency and the target calibration frequency;

[0013] Compare the captured value with the typical value, and according to the comparison result between the captured value and the typical value, use the binary operation rule to adjust the value of the corresponding bit from the high bit to the low bit bit by bit, until the captured value is equal to the typical value, or is adjusted to the lowest bit of the register;

[0014] If the adjusted bit is the lowest bit, the value of the lowest bit is adjusted to 0 or 1 respectively, and the calibration error corresponding to different values ​​is obtained. The value of the lowest bit is determined according to the calibration error, and the calibrated internal clock is obtained.

[0015] Optionally, the step of adjusting the values ​​of corresponding bits bit by bit from high bits to low bits in turn according to the comparison result between the captured value and the typical value by using the binary operation rule, until the captured value is equal to the typical value or is adjusted to the lowest bit of the register, includes:

[0016] If the captured value is greater than the typical value, the current bit of the register is assigned to 0, and the next bit of the current bit is assigned to 1; if the captured value is less than the typical value, the next bit of the current bit of the register is assigned to 1, and jump to the next bit, and continue to adjust in round-robin until the captured value is equal to the typical value, or is adjusted to the lowest bit of the register.

[0017] Optionally, determining the value of the least significant bit based on the calibration error corresponding to different values ​​of the least significant bit includes:

[0018] Adjust the least significant bit to 1, use the internal clock to capture the real-time frequency of the ATE clock, and obtain a first captured value; calculate the absolute value of the difference between the first captured value and the typical value, and obtain a first absolute difference;

[0019] Adjust the least significant bit to 0, use the internal clock to capture the real-time frequency of the ATE clock, and obtain a second captured value; calculate the absolute value of the difference between the second captured value and the typical value, and obtain a second absolute difference value;

[0020] The first absolute difference value is compared with the second absolute difference value. If the first absolute difference value is smaller than the second absolute difference value, the lowest bit is assigned a value of 1; otherwise, the lowest bit is assigned a value of 0.

[0021] Optionally, the initializing the value of each bit of the register of the internal clock to obtain the intermediate value of the register in binary includes:

[0022] Obtain all bits of the register of the internal clock, and determine the maximum and minimum values ​​of the register in decimal;

[0023] Based on the maximum value and the minimum value, determining a standard intermediate value of the register in decimal;

[0024] Based on the standard intermediate value, the binary value of each bit of the register is determined to obtain the binary intermediate value of the register.

[0025] Optionally, based on the intermediate value, using the internal clock to capture the real-time frequency of the ATE clock, and based on the real-time frequency and the target calibration frequency, obtaining a captured value, includes:

[0026] Determining a clock period of the internal clock based on the intermediate value, and capturing a real-time frequency of the ATE clock using the internal clock based on the clock period;

[0027] The ratio of the real-time frequency to the target calibration frequency is calculated to obtain the captured value.

[0028] Optionally, obtaining a typical value based on the reference frequency and the target calibration frequency includes:

[0029] Obtaining the stability and fine-tuning step ratio of the internal clock, and obtaining the accuracy of the ATE clock;

[0030] Obtaining a typical value based on a ratio of the reference frequency to the target calibration frequency;

[0031] If the typical value is less than the fine-tuning step ratio, obtaining a typical value based on the stability, the fine-tuning step ratio, and the accuracy of the ATE clock;

[0032] If the typical value is greater than or equal to the fine step ratio, a typical value is obtained based on the stability, the typical value, and the accuracy of the ATE clock.

[0033] A second aspect of the present invention provides an MCU internal clock calibration system based on ATE equipment, the system comprising:

[0034] A target calibration frequency acquisition module is used to start the internal clock of the MCU and obtain the target calibration frequency of the internal clock;

[0035] A reference frequency acquisition module, used to determine the frequency of an ATE clock based on the target calibration frequency, wherein the frequency of the ATE clock is a reference frequency;

[0036] A typical value generating module, used for obtaining a typical value based on the reference frequency and the target calibration frequency;

[0037] The calibration module is used to capture the real-time frequency of the ATE clock using the internal clock, initialize the value of each bit of the register of the internal clock, and construct a binary operation rule based on the real-time frequency and the typical value, and adjust the value of the corresponding bit bit by bit from the high bit to the low bit to obtain the calibrated internal clock.

[0038] A third aspect of the present invention provides a chip, which includes a memory, a processor, an internal clock, and an MCU internal clock calibration program based on an ATE device, which is stored in the memory and can be run on the processor. When the MCU internal clock calibration program based on the ATE device is executed by the processor, any step of the above-mentioned MCU internal clock calibration method based on the ATE device is implemented.

[0039] A fourth aspect of the present invention provides a computer-readable storage medium, on which is stored a MCU internal clock calibration program based on an ATE device. When the MCU internal clock calibration program based on the ATE device is executed by a processor, any step of the above-mentioned MCU internal clock calibration method based on the ATE device is implemented.

[0040] Compared with the prior art, the beneficial effects of this solution are as follows:

[0041] The method of the present invention uses the internal clock of the calibrated MCU as the working clock of the timer to capture the high-precision clock generated by the ATE, and obtains the reference object for calibration, that is, the typical value, based on the reference frequency and the target calibration frequency; by initializing the values ​​of each bit of the register of the internal clock, and based on the real-time frequency and the typical value of the ATE clock captured by the timer, a binary operation rule is constructed, and the value of the corresponding bit is adjusted bit by bit from the high bit to the low bit in a round-robin manner to obtain the calibrated internal clock. The scheme can reduce the test cost while ensuring the calibration accuracy; it can solve the correction of the internal clock of the MCU without a frequency division circuit, and there is no need to design a frequency division circuit, which can reduce the chip manufacturing cost; it has low performance requirements for ATE equipment, improves the application range of ATE equipment, and further reduces the test cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0043] Figure 1 A schematic diagram of a simplified process of the MCU internal clock calibration method based on ATE equipment of the present invention;

[0044] Figure 2 It is a flow chart of the MCU internal clock calibration method based on ATE equipment of the present invention;

[0045] Figure 3 A comparison diagram of a calibrated clock signal, a high-precision clock signal and a TIM capture count of a TIM capture solution in the prior art;

[0046] Figure 4 A comparison diagram of a calibrated clock signal, a high-precision clock signal and a TIM capture count in the calibration method of the present invention;

[0047] Figure 5 It is a schematic diagram of the successive correction results of the dichotomy method of the present invention;

[0048] Figure 6 It is a schematic diagram of the structure of each bit of the register of the present invention;

[0049] Figure 7 It is a structural schematic diagram of the MCU internal clock calibration system based on ATE equipment of the present invention;

[0050] Figure 8 It is a principle block diagram of the chip of the present invention. DETAILED DESCRIPTION

[0051] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

[0052] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0053] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0054] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0055] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0056] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0057] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0058] Since the internal clock stability of MCU is poor, the clock frequencies of different MCUs may vary. In order to ensure the accuracy of the internal clock of MCU, MCU manufacturers need to calibrate the clock of each MCU before leaving the factory. Therefore, the application prospects of calibrating the internal clock of MCU are broad.

[0059] The present invention addresses the problems of high cost and long calibration time in existing timer capture-based solutions. When calibrating an inaccurate clock, this type of solution requires a high-precision clock as a reference. The timer must have a clock source to achieve counting. The present application uses the internal clock of the MCU to be calibrated as the working clock of the timer to capture the high-precision clock generated by the integrated circuit automatic test equipment (Automatic Test Equipment, ATE). The designed binary search method is used to adjust the value of the corresponding bit of the register of the internal clock from the high bit to the low bit in a cycle. When the value captured by the timer is close to or equal to the ratio of the high-precision clock frequency to the target calibration frequency of the internal clock of the MCU to be calibrated, the internal clock frequency of the MCU will be adjusted to the target calibration frequency within the allowable error range, which can significantly improve the calibration accuracy. In addition, the binary search method has simple operation steps and can greatly improve the calibration efficiency.

[0060] The embodiment of the present invention provides an MCU internal clock calibration method based on ATE equipment, which is deployed on electronic devices such as computers and servers and is applied to the scenario of calibrating the internal clock of the MCU, and is aimed at the situation of using a timer to capture the high-precision clock signal generated by ATE. The type of the above-mentioned MCU is not limited, and it can be various types of MCUs used in the fields of smart home appliances, medical treatment, automotive electronics, computer networks and communications, smart cards, etc., and the type of the internal clock of the MCU is not limited, including but not limited to the internal high-speed clock (HSI) and the internal low-speed clock (LSI). Specifically, such as Figure 1 and Figure 2 As shown, the steps of the method in this embodiment include:

[0061] Step S1000: starting the internal clock of the MCU and obtaining the target calibration frequency of the internal clock;

[0062] Specifically, the internal clock of the MCU is started and adjusted to the capture function mode, and the counting function is turned on. According to factors such as the frequency of the internal clock, the target calibration frequency is determined, and the target calibration frequency of the internal clock is obtained.

[0063] Step S2000: determining the frequency of the ATE clock based on the target calibration frequency, where the frequency of the ATE clock is the reference frequency;

[0064] Specifically, the timer is initialized, and a high-precision clock matching the target calibration frequency is generated by using ATE, referred to as the ATE clock, as a reference clock to obtain the frequency of the ATE clock. Among them, using ATE to generate a high-precision clock matching the target calibration frequency means using ATE to generate a clock so that the clock can generate a frequency proportional to the target calibration frequency of the internal clock currently being calibrated; and the frequency generated when the ATE clock is initialized is used as the reference frequency for verifying the internal clock of the MCU.

[0065] Step S3000: obtaining a typical value based on a reference frequency and a target calibration frequency;

[0066] Specifically, since the internal clock of the MCU generally uses an RC oscillator, in some cases, the internal oscillation frequency of the RC oscillator may drift. The most common drift is the drift caused by temperature drift and the airtightness of the MCU package, which makes the stability of the internal clock of the MCU not very high. Therefore, when calibrating the internal clock of the MCU, a certain range of calibration error is allowed. That is, as long as the absolute difference between the frequency of the calibrated internal clock and the target calibration frequency is within the specified range, it indicates that the calibration accuracy requirement has been met.

[0067] Based on this, the present invention uses the ratio of the reference frequency to the target calibration frequency as the typical value of the internal clock of the calibrated MCU.

[0068] Step S4000: Use the internal clock to capture the real-time frequency of the ATE clock, initialize the values ​​of each bit of the register of the internal clock, and construct a binary operation rule based on the real-time frequency and the typical value, and adjust the value of the corresponding bit bit by bit from the high bit to the low bit to obtain the calibrated internal clock.

[0069] Specifically, the value of each bit of the register of the internal clock is initialized, and the real-time frequency of the ATE clock is captured based on the internal clock of all bits of the register in the current value state; based on the real-time frequency and the typical value, a binary operation rule is constructed with the principle of the real-time frequency approaching the target calibration frequency; using the binary operation rule, the value of the corresponding bit is adjusted bit by bit from the high bit to the low bit, so that the adjustment amplitude gradually decreases from large to small, which can effectively improve the effectiveness and accuracy of each calibration, thereby facilitating improving the calibration accuracy of the calibrated internal clock.

[0070] In this embodiment, by using the internal clock of the calibrated MCU as the working clock of the timer to capture the high-precision clock generated by the ATE, it is easy for the ATE to provide a low-frequency and high-precision reference clock, and the signal period of this clock can be flexibly adjusted according to demand. By adjusting the clock period, the ratio of the real-time frequency of the ATE clock captured by the timer to the target calibration frequency becomes larger, and the calibration step becomes smaller, thereby improving the accuracy. It can be seen that this solution can reduce the test cost while ensuring the calibration accuracy; it can solve the correction of the internal clock of the MCU without a frequency division circuit, and there is no need to design a frequency division circuit, which can reduce the chip manufacturing cost; the performance requirements for the ATE equipment are relatively low, which increases the scope of application of the ATE equipment, thereby further reducing the test cost.

[0071] Reference Figure 2 In one implementation, the values ​​of each bit of the register of the internal clock initialized in step S4000 are adjusted, based on the real-time frequency and the typical value, by constructing a binary operation rule, and adjusting the values ​​of the corresponding bits bit by bit from the high bit to the low bit in a round-robin manner to obtain the calibrated internal clock, specifically including:

[0072] Step S4100: Initialize the value of each bit of the register of the internal clock to obtain the intermediate value of the register in binary;

[0073] Specifically, according to the number of bits of the register, the standard intermediate value of the register in decimal is determined, and each bit of the register is assigned a value, so that the value of the register is initialized to the integer closest to the standard intermediate value in decimal as the intermediate value of the register in binary. It is easy to understand that when there are two integers closest to the standard intermediate value in decimal, the value with the higher number of bits of the register in binary is taken as the intermediate value.

[0074] Step S4200: Based on the intermediate value, the real-time frequency of the ATE clock is captured using the internal clock, and a captured value is obtained based on the real-time frequency and the target calibration frequency;

[0075] Specifically, due to different bit values ​​in the register, the frequency of the internal clock will also change. The frequency of the internal clock is adjusted by changing the values ​​of each bit of the register, and the signal period of the internal clock after each adjustment is measured, and the real-time frequency of the ATE clock is captured using the internal clock to reflect the current frequency of the internal clock through the captured real-time frequency. In this embodiment, the ratio of the real-time frequency to the target calibration frequency is used as the captured value to indirectly reflect the frequency of the internal clock.

[0076] Step S4300: Compare the captured value with the typical value. According to the comparison result between the captured value and the typical value, use the binary operation rule to adjust the value of the corresponding bit from the high bit to the low bit in turn until the captured value is equal to the typical value, or adjust to the lowest bit of the register, so that the captured value is close to or equal to the typical value.

[0077] Specifically, based on the intermediate value and typical value obtained by the initialization register, the intermediate value is adjusted so that the frequency of the internal clock is closer to the target calibration frequency, and an updated intermediate value is obtained. It is easy to understand that the updated intermediate value obtained by each binary operation will be closer to the value of the register corresponding to the internal clock at the target calibration frequency than the intermediate value obtained by the previous binary operation.

[0078] As the intermediate value changes, the real-time frequency of the ATE clock captured by the internal clock also changes accordingly, so that the captured value is updated once each binary operation is performed.

[0079] Step S4400: If the adjusted bit is the lowest bit, adjust the value of the lowest bit to 0 or 1 respectively, obtain the calibration error corresponding to different values, determine the value of the lowest bit according to the calibration error, and obtain the calibrated internal clock.

[0080] In this embodiment, the binary operation rule is used to adjust the value of the corresponding bit from the high bit to the low bit in a round-robin manner. The number of binary operations is equal to the number of bits of the register at most. In practical applications, the actual calibration number is often less than the number of bits of the register. Compared with the number of exponential powers in the prior art, the number of calibrations is greatly reduced, and the calibration efficiency and accuracy are effectively improved. At the same time, the algorithm complexity is reduced, the test time is reduced, and the production cost is reduced, which has broad application prospects.

[0081] Reference Figure 2 In one implementation, according to the comparison result between the captured value and the typical value, the binary operation rule is used to adjust the value of the corresponding bit from the high bit to the low bit in turn until the captured value is equal to the typical value or adjusted to the lowest bit of the register in step S4300, which specifically includes:

[0082] If the captured value is greater than the typical value, the current bit of the register is assigned to 0 and the next bit of the current bit is assigned to 1; if the captured value is less than the typical value, the next bit of the current bit of the register is assigned to 1, and jump to the next bit, and continue to adjust in a round-robin manner until the captured value is equal to the typical value, or adjusted to the lowest bit of the register.

[0083] Specifically, if the captured value is greater than the typical value, the current bit of the register is assigned to 0, and the next bit of the current bit is assigned to 1. If the adjustment is successful, it shifts to the next bit, that is, N=N-1, returns to measuring the signal period of the internal clock, and uses the internal clock to capture the real-time frequency of the ATE clock, and continues to perform calibration operations bit by bit, and so on; if the adjustment is unsuccessful, a fault prompt message is issued.

[0084] If the captured value is less than the typical value, the next bit of the current bit of the register is assigned a value of 1. If the adjustment is successful, it shifts to the next bit, that is, N=N-1, returns to measuring the signal cycle of the internal clock, and uses the internal clock to capture the real-time frequency of the ATE clock, and continues to perform calibration operations bit by bit, and so on; if the adjustment is unsuccessful, a fault prompt message is issued.

[0085] In this embodiment, during the process of performing round-robin adjustment on the register bits from high bits to low bits in step S4510 and step S4520, a calibration bit identification operation and a fault prompt function are added to ensure that each calibration is strictly performed according to the set rules and the position of each calibration is clearly understood, which can effectively improve the calibration accuracy and fault detection efficiency.

[0086] Reference Figure 2 In one implementation, determining the value of the least significant bit based on the calibration error corresponding to the least significant bit under different values ​​in step S4400 specifically includes:

[0087] Step S4410: adjust the lowest bit to 1, use the internal clock to capture the real-time frequency of the ATE clock, and obtain a first captured value; calculate the absolute value of the difference between the first captured value and the typical value, and obtain a first absolute difference;

[0088] Specifically, the lowest bit is adjusted to 1, the signal cycle of the internal clock is captured by the timer, and the frequency corresponding to the signal cycle is regarded as the current real-time frequency of the ATE clock, and the ratio of the current real-time frequency to the target calibration frequency is used as the first captured value. Then, the absolute value of the difference between the first captured value and the typical value is calculated to obtain the first absolute difference.

[0089] Step S4420: adjust the lowest bit to 0, use the internal clock to capture the real-time frequency of the ATE clock, and obtain a second captured value; calculate the absolute value of the difference between the second captured value and the typical value, and obtain a second absolute difference value;

[0090] Specifically, the principle is the same as step S4410, and there is no order of precedence between step S4410 and step S4420.

[0091] Step S4430: Compare the first absolute difference with the second absolute difference. If the first absolute difference is smaller than the second absolute difference, assign the lowest bit to 1; otherwise, assign the lowest bit to 0.

[0092] In this embodiment, since the next bit does not exist in the lowest bit, the rules of step S4510 and step S4520 are no longer met. Therefore, in order to ensure the highest accuracy of the calibrated internal clock, all possible values ​​of the lowest bit are adjusted and predicted. Then, the calibration errors corresponding to different values ​​of the lowest bit are compared, and the value corresponding to the smaller calibration error is assigned to the lowest bit to minimize the calibration error.

[0093] In one implementation, the values ​​of each bit of the register of the initialization internal clock in step S4100 to obtain the intermediate value of the register in binary system specifically include:

[0094] Step S4110: Obtain all bits of the register of the internal clock and determine the maximum and minimum values ​​of the register in decimal;

[0095] Step S4120: Determine the standard middle value of the register in decimal based on the maximum value and the minimum value;

[0096] Step S4130: Based on the standard intermediate value, determine the binary value of each bit of the register to obtain the binary intermediate value of the register.

[0097] Specifically, in order to improve the calibration efficiency, the present embodiment initializes each bit of the register to obtain an approximate intermediate value, which is beneficial for upward fine-tuning or upward fine-tuning based on the intermediate value during the calibration process to speed up the calibration. For example, it is known that the register has 4 binary bits. It is easy to know that the maximum binary value of the register is 1111, which is 15 after conversion to decimal, and the minimum value is 0000, which is 0 after conversion to decimal. Then the intermediate value in decimal is 7.5, which is not an integer. Therefore, the register is initialized to an integer close to 7.5, 7 or 8, and the 7 or 8 after the initialization assignment is approximated as the intermediate value. Similarly, if the register has N bits, its maximum value is 2 N -1, its lowest bit is 0, and the middle bit is The corresponding approximate binary number is 10...0, where the number of 0s is N-1. From this, we can see that no matter how many bits N the register has, initializing the highest bit to 1 and the rest to 0 is the closest to the standard intermediate value in decimal. This initialization method is generally applicable to various types of internal clocks.

[0098] In this embodiment, the intermediate value of the register obtained by the initialization method in binary is closer to the real frequency of the internal clock and the actual situation, and can be applied to different types of registers and internal clocks, has wide universality and diversified application scenarios.

[0099] In one implementation, the step S4200 uses an internal clock to capture the real-time frequency of the ATE clock based on the intermediate value, and obtains a captured value based on the real-time frequency and the target calibration frequency, specifically including:

[0100] Step S4210: determining a clock period of the internal clock based on the intermediate value, and based on the clock period, capturing the real-time frequency of the ATE clock using the internal clock;

[0101] Step S4220: Calculate the ratio of the real-time frequency to the target calibration frequency to obtain the capture value.

[0102] In this embodiment, the captured value is related to the real-time frequency and the target calibration frequency. Since the typical value is related to the reference frequency and the target calibration frequency, the real-time frequency and the reference frequency of the ATE clock can be linked through the captured value and the typical value, thereby indirectly comparing the real-time frequency and the reference frequency. The implementation is simple, the calculation amount is small, and it is convenient and fast.

[0103] In one implementation, obtaining a typical value based on a reference frequency and a target calibration frequency in step S3000 specifically includes:

[0104] Step S3100: obtaining the stability and fine-tuning step ratio of the internal clock, and obtaining the accuracy of the ATE clock;

[0105] Step S3200: obtaining a typical value based on a ratio of a reference frequency to a target calibration frequency;

[0106] Step S3300: if the typical value is less than the fine-tuning step ratio, then obtaining the typical value based on the stability, the fine-tuning step ratio and the accuracy of the ATE clock;

[0107] Step S3400: If the typical value is greater than or equal to the fine-tuning step ratio, the typical value is obtained based on the stability, the typical value and the accuracy of the ATE clock.

[0108] In this embodiment, in order to calibrate to the highest possible accuracy, the following parameters need to be considered:

[0109] 1) Internal clock stability, expressed in W;

[0110] 2) The accuracy of the calibrated reference clock, expressed as Racc;

[0111] 3) Fine-tune the step ratio of the internal clock, using express;

[0112] 4) The ratio of the reference frequency to the target calibration frequency of the calibrated clock, ie the typical value, is represented by Vtyp = (fref / ftyp), where fref represents the frequency value of the reference clock and ftyp represents the target calibration frequency value of the calibrated clock.

[0113] Combining the above parameters, the simulation formula is obtained:

[0114] like The calibration error

[0115] like The calibration error

[0116] If, under ideal circumstances, the chip's internal clock stability is designed to be high enough and its frequency is required to be stable enough without fluctuations, then The calibrated reference clock source is a low-frequency, high-precision clock provided by the ATE equipment (usually with an accuracy error of about 20ppm), and its deviation can be ignored, that is,

[0117] Therefore, the simulation formula can be simplified to:

[0118] like The calibration error This indicates that the hardware design value limit has been reached and the step value can be used as the minimum deviation;

[0119] like The calibration error This indicates that the ratio of the reference frequency to the target calibration frequency cannot be increased due to the external environment's restrictions on the reference frequency of the ATE clock. Therefore, the reciprocal of the typical value can be used as the minimum deviation.

[0120] The present invention can output a low-frequency and high-precision reference clock by adjusting ATE, so that the ratio of the reference frequency to the target calibration frequency becomes larger, and the error caused by the external environment can be ignored. The calibration error At this point, the accuracy of the internal clock reaches the hardware design limit, and the deviation under the corresponding step value is minimal.

[0121] Furthermore, after obtaining the calibrated internal clock in step S4000, the method further includes: storing the value of each bit of the register of the calibrated internal clock in the non-volatile area of ​​the MCU.

[0122] Specifically, the value of each bit of the calibrated register is stored in a non-volatile area in the internal storage area of ​​the MCU, such as the address corresponding to the FLASH area, to record the optimal value of each bit of the register. At the same time, it can be used as a reference calibration value for the same type of MCU to be shipped, so as to further improve the calibration efficiency, save costs, and improve the economic benefits of the MCU manufacturer.

[0123] Furthermore, the power is repeatedly turned off and then on again, and the periodic signal of the next calibrated MCU internal clock is output through the general purpose input output (GPIO), that is, the IO port. The calibration methods provided in the above-mentioned embodiments are adopted, and the internal clock is calibrated using ATE equipment, and so on, to meet the manufacturer's large-scale calibration needs.

[0124] The feasibility and effectiveness of the calibration method of the present invention are verified by comparative analysis with the prior art, as follows:

[0125] Example 1: Given a calibrated MCU chip that cannot be divided, the output frequency of the internal clock (i.e., the target calibration frequency) is designed to be 10 MHz, and the step ratio is 0.5%, where the step ratio = target calibration frequency / operating frequency of the TIM clock.

[0126] (1) Using the TIM capture solution in the prior art, the TIM clock uses an externally provided high-frequency and high-precision clock. Assuming the clock frequency is XMHz, according to 10:X=0.5%, we get X=2000, which requires an external 2000MHz high-frequency and high-precision clock signal as a reference clock (i.e., ATE clock). In actual mass production, it is difficult for the ATE equipment generally used in the industry to generate a stable 2000MHz clock, and usually requires an external professional crystal oscillator to achieve this. The comparison diagram of the calibrated clock signal, high-precision clock signal and TIM capture count of the TIM capture solution in the prior art is shown in the figure below. Figure 3 As shown in the figure, the horizontal axis represents time in ns, the vertical axis represents voltage in mv, and the time period between the two vertical dashed lines intersecting the horizontal axis represents a clock cycle. It can be seen that the value of the count captured by TIM can reflect the current operating frequency of the internal clock, and the frequency of the high-precision clock signal is much higher than the frequency of the calibrated clock signal, which is not easy to implement and is unstable, and the feasibility is low.

[0127] (2) Using the method of the present invention, the calibrated internal clock output by the MCU is used as the working clock of the timer TIM; ATE provides a low-frequency and high-precision clock. Assuming the clock frequency is YMHz, according to Y:10=0.5%, we get Y=0.05, which requires the ATE device to provide a 50KHz clock. For the ATE devices generally used in the industry, this is relatively easy and does not require external connection of additional circuits. In addition, the clock can be adjusted, which verifies the feasibility of the method of the present invention. The comparison diagram of the calibrated clock signal, high-precision clock signal and TIM capture count of the calibration method of the present invention is shown in FIG. Figure 4As shown in the figure, the horizontal axis represents time in ns, the vertical axis represents voltage in mv, and the time period between the two vertical dotted lines intersecting the horizontal axis represents a clock cycle. It can be seen that the value of the count captured by TIM can reflect the current operating frequency of the internal clock, and the frequency of the high-precision clock signal is much lower than the frequency of the calibrated clock signal, which is easy to implement and has good stability and high feasibility.

[0128] Based on the feasibility analysis of the method of the present invention, it is known that the target calibration frequency of an internal clock is 10MHz (period 100ns) of an MCU. Assuming that the period T1 of the high-precision clock generated by ATE is 1000ns, then the period ratio between it and the target calibration frequency is 10:1. Assuming that the TIM capture value is 900MHz at this time, its ratio to the target calibration frequency is 9:1. When the period T2 of the high-precision clock generated by ATE is 2000ns, its ratio to the target calibration frequency is 20:1. At this time, the TIM capture value is 1800MHz, and its ratio to the target calibration frequency is 18:1. It can be seen that the larger the ratio of the capture value of the internal clock timer TIM to the target calibration frequency, the smaller the step. Therefore, the clock frequency generated by ATE is further controlled so that the ratio of the capture value of the internal clock timer TIM to the target calibration frequency is close to 20:1; the accuracy of calibration can be effectively improved.

[0129] Example 2: Using the binary algorithm, it is known that the register of the internal clock of an MCU to be calibrated has 12 bits. If the prior art method of gradually increasing or decreasing the adjustment method is adopted, the maximum number of adjustments required is 12. 11 = 2047 times, but if the binary division method proposed by the present invention is adopted, the adjustment is made in a round-robin manner from high to low, and at most 12 times of adjustment are required, that is, one adjustment is made for each bit. It can be seen that the binary division method proposed by the present invention can greatly shorten the calibration time, thereby reducing the chip testing cost, and effectively verifies the effectiveness of the method.

[0130] Figure 5 The figure shows the result of the successive correction of the binary division method proposed by the present invention, wherein the horizontal axis represents the register bit, including the coarse adjustment bit and the fine adjustment bit, and the vertical axis represents the frequency of the internal clock to be calibrated. It can be seen that the calibration amplitude gradually decreases from large to small according to the successive calibration from high to low, that is, the internal clock is first coarsely adjusted, and then finely adjusted, so that the frequency of the internal clock is getting closer and closer to the target calibration frequency. Figure 6 The figure shows a schematic diagram of the structure of each bit of the register, where, looking from high to low, coarse adjustment is achieved by calibrating the first six bits (i.e., the 12th to the 7th bit, represented as [11:6]), and fine adjustment is achieved by calibrating the last six bits (i.e., the 6th to the 1st bit, represented as [5:0]), and the value of each bit is the result after calibration.

[0131] like Figure 7 As shown, corresponding to the above-mentioned MCU internal clock calibration method based on ATE equipment, an embodiment of the present invention further provides an MCU internal clock calibration system based on ATE equipment, and the above-mentioned MCU internal clock calibration system based on ATE equipment includes:

[0132] The target calibration frequency acquisition module 710 is used to start the internal clock of the MCU and obtain the target calibration frequency of the internal clock;

[0133] A reference frequency acquisition module 720, configured to determine the frequency of the ATE clock based on the target calibration frequency, the frequency of the ATE clock being the reference frequency;

[0134] A typical value generating module 730, for obtaining a typical value based on a reference frequency and a target calibration frequency;

[0135] The calibration module 740 is used to capture the real-time frequency of the ATE clock using the internal clock, initialize the value of each bit of the register of the internal clock, and construct a binary operation rule based on the real-time frequency and the typical value, and adjust the value of the corresponding bit bit by bit from the high bit to the low bit to obtain the calibrated internal clock.

[0136] Specifically, in this embodiment, the specific functions of the above-mentioned MCU internal clock calibration system based on ATE equipment can also refer to the corresponding description in the above-mentioned MCU internal clock calibration method based on ATE equipment, which will not be repeated here.

[0137] Based on the above embodiments, the present invention further provides a chip, whose principle block diagram can be shown as follows: Figure 8 As shown. The above chip includes a processor, a memory, an internal clock and a correction interface connected through a system bus. Among them, the internal clock includes a timer and a register, the timer is used to capture the real-time frequency of the internal clock, and the register is used to store the clock information of the internal clock. The processor of the chip is used to provide computing and control capabilities. The memory of the chip includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and an MCU internal clock calibration program based on an ATE device. The internal memory provides an environment for the operation of the operating system in the non-volatile storage medium and the MCU internal clock calibration program based on the ATE device. The correction interface of the chip is used to be electrically connected to an external ATE device. When the MCU internal clock calibration program based on the ATE device is executed by the processor, the steps of any one of the above-mentioned MCU internal clock calibration methods based on the ATE device are implemented.

[0138] Those skilled in the art will understand that Figure 8The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the chip to which the scheme of the present invention is applied. The specific chip may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0139] In one embodiment, a chip is provided, comprising a memory, a processor, and an MCU internal clock calibration program based on an ATE device stored in the memory and executable on the processor. When the MCU internal clock calibration program based on an ATE device is executed by the processor, the steps of any one of the MCU internal clock calibration methods based on an ATE device provided in an embodiment of the present invention are implemented.

[0140] An embodiment of the present invention further provides a computer-readable storage medium, on which is stored a MCU internal clock calibration program based on an ATE device. When the MCU internal clock calibration program based on an ATE device is executed by a processor, the steps of any one of the MCU internal clock calibration methods based on an ATE device provided in an embodiment of the present invention are implemented.

[0141] It should be understood that the sequence numbers of the steps in the above embodiments do not imply a sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0142] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0143] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0144] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0145] In the embodiments provided by the present invention, it should be understood that the disclosed apparatus / terminal equipment and method can be implemented in other ways. For example, the apparatus / terminal equipment embodiments described above are only illustrative, for example, the division of the above modules or units is only a logical function division, and in actual implementation, other division methods can be used, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0146] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, it should be understood by those skilled in the art that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features therein may be replaced by equivalents. However, these modifications or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.

Claims

1. A method for calibrating an internal clock of an MCU based on an ATE device, characterized in that: include: Starting an internal clock of the MCU and obtaining a target calibration frequency of the internal clock; Based on the target calibration frequency, determining the frequency of the ATE clock, the frequency of the ATE clock being a reference frequency; Based on the reference frequency and the target calibration frequency, obtaining a typical value; The real-time frequency of the ATE clock is captured by the internal clock, the value of each bit of the register of the internal clock is initialized, and based on the real-time frequency and the typical value, a binary operation rule is constructed to adjust the value of the corresponding bit bit by bit from the high bit to the low bit, so as to obtain a calibrated internal clock; Initializing the values ​​of each bit of the register of the internal clock, and constructing a binary operation rule based on the real-time frequency and the typical value, adjusting the values ​​of the corresponding bits bit by bit from the high bit to the low bit, and obtaining the calibrated internal clock, including: Initialize the value of each bit of the register of the internal clock to obtain the intermediate value of the register in binary; Based on the intermediate value, using the internal clock to capture the real-time frequency of the ATE clock, and obtaining a captured value based on the real-time frequency and the target calibration frequency; Compare the captured value with the typical value, and according to the comparison result between the captured value and the typical value, use the binary operation rule to adjust the value of the corresponding bit from the high bit to the low bit bit by bit, until the captured value is equal to the typical value, or is adjusted to the lowest bit of the register; If the bit to be adjusted is the lowest bit, the value of the lowest bit is adjusted to 0 or 1 respectively, the calibration error corresponding to different values ​​is obtained, the value of the lowest bit is determined according to the calibration error, and the calibrated internal clock is obtained; According to the comparison result between the captured value and the typical value, the binary operation rule is used to adjust the value of the corresponding bit from the high bit to the low bit in turn, until the captured value is equal to the typical value, or is adjusted to the lowest bit of the register, including: If the captured value is greater than the typical value, the current bit of the register is assigned a value of 0, and the next bit of the current bit is assigned a value of 1; if the captured value is less than the typical value, the next bit of the current bit of the register is assigned a value of 1, and jump to the next bit, and continue to adjust in round robin until the captured value is equal to the typical value, or is adjusted to the lowest bit of the register; The determining the value of the least significant bit based on the calibration error corresponding to different values ​​of the least significant bit includes: Adjust the lowest bit to 1, use the internal clock to capture the real-time frequency of the ATE clock, and obtain a first captured value; calculate the absolute value of the difference between the first captured value and the typical value to obtain a first absolute difference; adjust the lowest bit to 0, use the internal clock to capture the real-time frequency of the ATE clock, and obtain a second captured value; calculate the absolute value of the difference between the second captured value and the typical value to obtain a second absolute difference; compare the first absolute difference with the second absolute difference, if the first absolute difference is less than the second absolute difference, assign the lowest bit to 1, otherwise assign the lowest bit to 0; The obtaining of a typical value based on the reference frequency and the target calibration frequency includes: The stability and fine-tuning step ratio of the internal clock are obtained, and the accuracy of the ATE clock is obtained; a typical value is obtained based on the ratio of the reference frequency to the target calibration frequency; if the typical value is less than the fine-tuning step ratio, a typical value is obtained based on the stability, the fine-tuning step ratio and the accuracy of the ATE clock; if the typical value is greater than or equal to the fine-tuning step ratio, a typical value is obtained based on the stability, the typical value and the accuracy of the ATE clock.

2. The MCU internal clock calibration method based on ATE equipment according to claim 1, characterized in that: Initializing the values ​​of each bit of the register of the internal clock to obtain the intermediate value of the register in binary system includes: Obtain all bits of the register of the internal clock, and determine the maximum and minimum values ​​of the register in decimal; Based on the maximum value and the minimum value, determining a standard intermediate value of the register in decimal; Based on the standard intermediate value, the binary value of each bit of the register is determined to obtain the binary intermediate value of the register.

3. The MCU internal clock calibration method based on ATE equipment according to claim 1, characterized in that: The method of capturing the real-time frequency of the ATE clock using the internal clock based on the intermediate value, and obtaining a captured value based on the real-time frequency and the target calibration frequency, comprises: Determining a clock period of the internal clock based on the intermediate value, and capturing a real-time frequency of the ATE clock using the internal clock based on the clock period; The ratio of the real-time frequency to the target calibration frequency is calculated to obtain the captured value.

4. An MCU internal clock calibration system based on ATE equipment, characterized in that: The method for calibrating the internal clock of an MCU based on an ATE device according to any one of claims 1 to 3 is applied to the system, wherein the system comprises: A target calibration frequency acquisition module is used to start the internal clock of the MCU and obtain the target calibration frequency of the internal clock; A reference frequency acquisition module, used to determine the frequency of an ATE clock based on the target calibration frequency, wherein the frequency of the ATE clock is a reference frequency; A typical value generating module, used for obtaining a typical value based on the reference frequency and the target calibration frequency; A calibration module is used to capture the real-time frequency of the ATE clock using the internal clock, initialize the value of each bit of the register of the internal clock, and construct a binary operation rule based on the real-time frequency and the typical value, and adjust the value of the corresponding bit bit by bit from the high bit to the low bit in a round-robin manner to obtain the calibrated internal clock; the value of each bit of the register of the internal clock is initialized, and based on the real-time frequency and the typical value, a binary operation rule is constructed, and the value of the corresponding bit is adjusted bit by bit from the high bit to the low bit in a round-robin manner to obtain the calibrated internal clock, including: Initialize the value of each bit of the register of the internal clock to obtain the intermediate value of the register in binary; Based on the intermediate value, using the internal clock to capture the real-time frequency of the ATE clock, and obtaining a captured value based on the real-time frequency and the target calibration frequency; Compare the captured value with the typical value, and according to the comparison result between the captured value and the typical value, use the binary operation rule to adjust the value of the corresponding bit from the high bit to the low bit bit by bit, until the captured value is equal to the typical value, or is adjusted to the lowest bit of the register; If the adjusted bit is the lowest bit, the value of the lowest bit is adjusted to 0 or 1 respectively, and the calibration error corresponding to different values ​​is obtained. The value of the lowest bit is determined according to the calibration error, and the calibrated internal clock is obtained.

5. A chip, characterized in that: The chip includes a memory, a processor, an internal clock, and an MCU internal clock calibration program based on the ATE device, which is stored in the memory and can be run on the processor. When the MCU internal clock calibration program based on the ATE device is executed by the processor, the steps of the MCU internal clock calibration method based on the ATE device as described in any one of claims 1-3 are implemented.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an MCU internal clock calibration program based on an ATE device, and when the MCU internal clock calibration program based on an ATE device is executed by a processor, the steps of the MCU internal clock calibration method based on an ATE device as described in any one of claims 1-3 are implemented.

Citation Information

Patent Citations

  • Method for calibrating internal clock source of MCU based on ATE

    CN114895745A