Frequency calibration method of MCU circuit
By presetting the frequency calibration program in the fixed memory of the MCU circuit and executing it after the process, and using the MCU circuit's own memory and processor for frequency calibration, the problems of high cost and poor accuracy in the existing technology are solved, and a low-cost, high-precision frequency calibration effect is achieved.
Patent Information
- Application Number
- CN202410303933.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-15
- Publication Date
- 2025-09-16
AI Technical Summary
Existing frequency calibration solutions for MCU circuits have the problems of high cost and poor frequency calibration accuracy. In particular, frequency changes caused by stress factors during intermediate or final testing affect frequency accuracy and increase the cost of the hard sealing process.
By presetting the frequency calibration program in the fixed memory of the MCU circuit, triggering the frequency calibration program to obtain the target TRIM value, and performing frequency calibration after soft seal dispensing or hard seal welding, the MCU circuit's own memory and central processing unit are used for frequency calibration. No additional test modules and external pins are required, and external conditions are used to trigger or overwrite the frequency calibration program to achieve a balance between accuracy and cost.
Low-cost, high-accuracy frequency calibration is achieved, frequency changes caused by stress factors are avoided, circuit costs are reduced, and the accuracy and convenience of frequency calibration are improved.
Smart Images

Figure CN120652858A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of integrated circuits, and in particular to a frequency calibration method for an MCU circuit. Background Art
[0002] In order to ensure accurate communication or pronunciation, it is usually necessary to calibrate the frequency of an internal oscillator in an MCU (Micro Controller Unit) circuit. Traditional calibration schemes include two types.
[0003] Option 1 involves calibrating the internal oscillator frequency during intermediate or final testing using a test machine. However, during intermediate testing, factors such as stress from soft-seal dispensing can cause frequency variations, resulting in significant overall frequency dispersion. During final testing, factors such as stress from hard-seal welding can also cause frequency variations, affecting frequency accuracy. Furthermore, adding a hard-seal process can increase costs.
[0004] Option 2 involves using a programmer to calibrate the frequency after the soft seal dispensing process or hard seal soldering process. For example, this can be accomplished by placing the MCU into test mode via I2C communication. However, this solution requires designing a dedicated test module within the MCU and an external pin for entering test mode, which increases circuit cost.
[0005] Therefore, how to perform high-accuracy frequency calibration on the internal oscillator in the MCU circuit while ensuring low cost is a technical problem that those skilled in the art are eager to solve.
[0006] It should be noted that the above technical background is merely provided to provide a clear and complete description of the technical solutions of the present invention and to facilitate understanding by those skilled in the art. Simply because these solutions are described in the technical background section of the present invention, it should not be assumed that the above technical solutions are well known to those skilled in the art. Summary of the Invention
[0007] In view of the above-mentioned shortcomings of the prior art, the object of the present invention is to provide a frequency calibration method for an MCU circuit, so as to solve the problems of high cost and poor frequency calibration accuracy in the existing frequency calibration scheme for MCU circuits.
[0008] To achieve the above-mentioned and other related purposes, the present invention provides a frequency calibration method for an MCU circuit, the frequency calibration method comprising:
[0009] Presetting a frequency calibration program in a fixed memory of the MCU circuit;
[0010] triggering the MCU circuit to execute the frequency calibration program to obtain a target TRIM value, and storing the target TRIM value in a TRIM value storage area of the MCU circuit;
[0011] The frequency calibration program in the fixed memory is removed.
[0012] Optionally, the fixed memory includes a MASK type memory; in this case,
[0013] The method for presetting the frequency calibration program includes: burning a normal operation program into the MASK type memory through a mask process, wherein the normal operation program is additionally provided with a first external condition and the frequency calibration program;
[0014] The method for executing the frequency calibration program includes: controlling the MCU circuit to be powered on again and applying the first external condition to the first port of the MCU circuit through an external frequency calibration circuit, so as to trigger the MCU circuit to execute the frequency calibration program through the first external condition;
[0015] The method for removing the frequency calibration program includes removing the frequency calibration program by removing the first external condition applied to the first port.
[0016] Optionally, the first external condition includes a pulse set to 0, set to 1, or a preset rule.
[0017] Optionally, the fixed memory includes an OTP type memory; in this case,
[0018] The method for presetting the frequency calibration program includes: burning the frequency calibration program into the first storage area of the OTP type memory through an external frequency calibration circuit;
[0019] The method for executing the frequency calibration program includes: controlling the MCU circuit to re-power on to trigger it to execute the frequency calibration program;
[0020] The method for removing the frequency calibration program includes: removing the frequency calibration program by overwriting the frequency calibration program in the first storage area with an empty instruction through the external frequency calibration circuit, or removing the frequency calibration program by burning a program skip instruction before the frequency calibration program in the first storage area through the external frequency calibration circuit; or, the method for removing the frequency calibration program also includes: burning a normal operation program in the second storage area of the OTP type memory through the external frequency calibration circuit.
[0021] Optionally, the fixed memory includes an OTP type memory; in this case,
[0022] The method for presetting the frequency calibration program includes: burning a normal operation program into the third storage area of the OTP type memory through an external frequency calibration circuit, wherein the normal operation program is additionally provided with a second external condition and the frequency calibration program;
[0023] The method for executing the frequency calibration program includes: controlling the MCU circuit to power on again and applying the second external condition to the second port of the MCU circuit through the external frequency calibration circuit, so as to trigger the MCU circuit to execute the frequency calibration program through the second external condition;
[0024] The method for removing the frequency calibration program includes removing the frequency calibration program by removing the second external condition applied to the second port.
[0025] Optionally, the second external condition includes a pulse set to 0, set to 1, or a preset rule.
[0026] Optionally, the fixed memory includes a FLASH memory; in this case,
[0027] The method for presetting the frequency calibration program includes: burning the frequency calibration program into the first storage area of the FLASH memory through an external frequency calibration circuit;
[0028] The method for executing the frequency calibration program includes: controlling the MCU circuit to re-power on to trigger it to execute the frequency calibration program;
[0029] The method for removing the frequency calibration program includes: erasing the frequency calibration program in the first storage area through the external frequency calibration circuit; or the method for removing the frequency calibration program also includes: burning a normal operation program in the first storage area through the external frequency calibration circuit.
[0030] Optionally, the method for obtaining the target TRIM value includes:
[0031] The MCU circuit enables its internal oscillator and enables the periodic flipping of its third port through the frequency calibration program, wherein the frequency calibration program traverses each preset TRIM value, and the ratio of the oscillator frequency to the flipping frequency of the third port is m:1, where m is an integer greater than 1;
[0032] The flipping frequencies corresponding to the preset TRIM values are measured and recorded by an external frequency calibration circuit, and the preset TRIM value close to the target frequency is found out through the flipping frequencies as the target TRIM value.
[0033] Optionally, the target TRIM value is stored in the TRIM value storage area through the external frequency calibration circuit;
[0034] When the fixed memory includes a MASK type memory, the MCU circuit is further configured with an auxiliary memory, wherein the TRIM value storage area is provided in the auxiliary memory;
[0035] When the fixed memory includes an OTP memory, the fourth storage area of the OTP memory is used as the TRIM value storage area;
[0036] When the fixed memory includes a FLASH memory, the second storage area of the FLASH memory is used as the TRIM value storage area;
[0037] Wherein, when the fixed memory includes an OTP memory or a FLASH memory, if the MCU circuit is configured with the auxiliary memory, the TRIM value storage area is set in the auxiliary memory.
[0038] Optionally, a normal operation program is burned into the fixed memory, and the frequency calibration method further includes:
[0039] The MCU circuit is controlled to be powered on again to trigger it to execute the normal operation program, and the oscillator frequency of the MCU circuit is set by loading the target TRIM value of the TRIM value storage area.
[0040] As described above, the frequency calibration method for an MCU circuit of the present invention utilizes the MCU circuit's own fixed memory and central processing unit to assist in frequency calibration, eliminating the need for an additional test module and its associated external pins, thereby reducing circuit costs. Furthermore, by performing the frequency calibration procedure after the soft seal dispensing process or the hard seal welding process, frequency calibration accuracy is improved. The frequency calibration method of the present invention is low-cost, highly accurate, easy to use, and has a wide range of applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 Shown is a structural schematic diagram of the MCU circuit of the present invention.
[0042] Figure 2 Shown is a flow chart of the frequency calibration method of the present invention.
[0043] Figure 3 Shown is a specific flow chart of the frequency calibration method in embodiment 1 of the present invention.
[0044] Figure 4 Shown is a specific flow chart of the frequency calibration method in the second embodiment of the present invention.
[0045] Figure 5 Shown is a specific flow chart of the frequency calibration method in embodiment 3 of the present invention.
[0046] Figure 6 Shown is a specific flow chart of the frequency calibration method in the fourth embodiment of the present invention. DETAILED DESCRIPTION
[0047] The following describes the embodiments of the present invention through specific examples. Those skilled in the art will readily understand the other advantages and benefits of the present invention from the disclosure herein. The present invention may also be implemented or applied through various other specific embodiments, and the details in this specification may be modified or altered based on different viewpoints and applications without departing from the spirit of the present invention.
[0048] See also Figures 1 to 6 It should be noted that the illustrations provided in this embodiment are merely schematic illustrations of the basic concept of the present invention. Therefore, the illustrations only show components related to the present invention and are not drawn according to the number, shape, and size of components in actual implementation. In actual implementation, the form, quantity, and proportion of each component may be changed arbitrarily, and the component layout may also be more complex.
[0049] like Figure 1 As shown, the MCU circuit includes at least a central processing unit (CPU) and a fixed memory. The central processing unit serves as the master control unit and includes an internal oscillator for providing an oscillation signal. The fixed memory is used to store various fixed programs and data. Among them, the fixed memory includes a MASK (mask) type memory, an OTP (one-time programming) type memory or a FLASH (fast erase) type memory.
[0050] In the case where the fixed memory includes a MASK type memory, the MCU circuit also includes an auxiliary memory, such as EEPROM (electrically erasable programmable read-only memory); in the case where the fixed memory includes an OTP type memory or a FLASH type memory, the MCU circuit can decide whether to include the auxiliary memory based on actual conditions.
[0051] In the above-mentioned MCU circuit, for different types of fixed memories, the specific implementation methods of each step in the frequency calibration method described in the present invention are different. Below, the frequency calibration method of the MCU circuit including different types of fixed memories is introduced in detail through different embodiments.
[0052] Example 1
[0053] like Figure 2 and Figure 3 As shown, this embodiment provides a frequency calibration method for an MCU circuit, comprising steps S1 to S3, and further comprising step S4. In this embodiment, the fixed memory of the MCU circuit comprises a MASK type memory.
[0054] In step S1, a frequency calibration program is preset in a fixed memory (eg, a MASK type memory) of the MCU circuit.
[0055] In one embodiment, the method for presetting the frequency calibration program includes: burning a normal operation program in a MASK type memory through a mask process, wherein the normal operation program is additionally provided with a first external condition and a frequency calibration program.
[0056] This embodiment adds a first external condition and a frequency calibration program to the normal operation program, and uses the satisfaction of the first external condition to trigger the MCU circuit to execute the frequency calibration program, thereby achieving frequency calibration of the internal oscillator of the MCU circuit, thereby obtaining a more accurate oscillator frequency.
[0057] In actual applications, for the MASK type memory, the normal operation program with the first external condition and the frequency calibration program added can also be called a mask program, which is burned into the MASK type memory through the mask process during the production process of the MCU circuit. It can be seen that step S1 of this embodiment is completed in the production process of the MCU circuit.
[0058] In step S2 , the MCU circuit is triggered to execute a frequency calibration program to obtain a target TRIM value, and the target TRIM value is stored in a TRIM value storage area of the MCU circuit.
[0059] As an optional solution, the MCU circuit is triggered to execute the frequency calibration program after the soft seal dispensing process or the hard seal welding process, that is, step S2 is executed after the soft seal dispensing process or the hard seal welding process, to avoid frequency changes caused by the soft seal dispensing process or the hard seal welding process and improve the frequency calibration accuracy.
[0060] In practical applications, for occasions with high frequency accuracy requirements, step S2 can be selected to be executed after the hard seal welding process to ensure high frequency accuracy; for low-cost occasions, step S2 can be selected to be executed after the soft seal dispensing process. In this way, the hard seal process can be omitted, which is conducive to reducing production costs.
[0061] In one embodiment, the method for executing the frequency calibration program includes: controlling the MCU circuit to power on again and applying a first external condition to the first port of the MCU circuit through an external frequency calibration circuit, so as to trigger the MCU circuit to execute the frequency calibration program through the first external condition.
[0062] Specifically, the first external condition includes a pulse set to 0, set to 1 or a preset rule, wherein the pulse of the preset rule includes a single-cycle pulse or a pulse of two or more cycles; for pulses of two or more cycles, the pulse duration of each cycle can be the same or different, which has no effect on this embodiment.
[0063] In actual applications, after executing the frequency calibration method described in this embodiment, the MCU circuit should avoid applying the first external condition to the first port during normal operation; in order to avoid the first port being triggered by mistake, the first external condition is preferably designed to be relatively complex, so that the first port can be used for other applications instead of being idle.
[0064] In addition, the first port can be a data port or clock port in the MCU circuit connected to the external frequency calibration circuit, or it can be a dedicated port in the MCU circuit connected to the external frequency calibration circuit. Of course, in order to avoid accidentally triggering the frequency calibration program when the MCU circuit is working normally, a dedicated port is usually used as the first port.
[0065] Specifically, the external frequency calibration circuit includes a tester or a programmer. Due to cost and ease of use, a programmer is usually selected as the external frequency calibration circuit.
[0066] In one embodiment, a method for obtaining a target TRIM value includes: an MCU circuit enables its internal oscillator and enables periodic flipping of its third port through a frequency calibration program, and the frequency calibration program traverses each preset TRIM value; an external frequency calibration circuit measures and records the flipping frequency of the third port corresponding to each preset TRIM value, and finds a preset TRIM value close to or even equal to the target frequency through each flipping frequency as the target TRIM value; wherein the ratio of the oscillator frequency to the flipping frequency is m:1, where m is an integer greater than 1.
[0067] For example, when the MCU circuit executes a frequency calibration program, it enables the internal oscillator to generate an oscillation signal as the system clock. It also enables the third port to periodically flip, with the flip frequency and the oscillator frequency having a ratio of 1:m. The external frequency calibration circuit measures and records the flip frequency of the third port. Next, the frequency calibration program changes the preset TRIM value of the internal oscillator. As the oscillator frequency changes, the flip frequency of the third port also changes accordingly. The external frequency calibration circuit continues to measure and record the flip frequency of the third port. During the execution of the frequency calibration program, the preset TRIM value of the internal oscillator is continuously changed until all preset TRIM values are covered. The external frequency calibration circuit measures and records the flip frequencies of the third port corresponding to all preset TRIM values. Finally, the external frequency calibration circuit multiplies all flip frequencies of the third port by m and compares them with the target frequency. It finds the flip frequency closest to the target frequency and uses this to determine the corresponding preset TRIM value as the target TRIM value.
[0068] In practical applications, the third port can be a data port or clock port in the MCU circuit connected to the external frequency calibration circuit, and this embodiment does not impose any restrictions on this. In addition, m is typically selected as an integer much greater than 1. By reducing the frequency, the measurement accuracy of the external frequency calibration circuit is improved, which also helps to reduce the device accuracy of the external frequency calibration circuit.
[0069] It should be noted that the so-called closeness in this embodiment refers to the situation where the absolute value of the difference between the flip frequency multiplied by m and the target frequency is less than the set value. If there are multiple flip frequencies that meet the above situation, the preset TRIM value corresponding to the flip frequency with the smallest absolute value should be selected as the target TRIM value.
[0070] In one embodiment, the target TRIM value is stored in a TRIM value storage area of the MCU circuit via an external frequency calibration circuit. Since the fixed memory of this embodiment includes a MASK type memory, the MCU circuit of this embodiment is also configured with an auxiliary memory. In this case, the TRIM value storage area is set in the auxiliary memory.
[0071] Step S3, removing the frequency calibration program in the fixed memory (eg, MASK type memory).
[0072] It should be noted that step S3 can be completed in the same process as step S2, or in a process after the process corresponding to step S2, which has no impact on this embodiment.
[0073] In one embodiment, the method for removing the frequency calibration program includes: removing the frequency calibration program by removing the first external condition applied to the first port; taking the first external condition including a pulse according to a preset rule as an example, in step S3 or even step S4 after step S2, the pulse according to the preset rule is no longer applied to the first port of the MCU circuit, so that the frequency calibration program cannot be triggered, thereby achieving the purpose of removing the frequency calibration program.
[0074] Step S4: Powering on the MCU circuit again triggers it to execute the normal operating procedure, and sets the MCU circuit's oscillator frequency by loading the target TRIM value from the TRIM value storage area. It should be noted that during step S4, since the first port of the MCU circuit no longer applies the first external condition, the frequency calibration procedure added to the normal operating procedure cannot be triggered. The MCU circuit only executes the remaining procedures in the normal operating procedure, excluding the frequency calibration procedure.
[0075] Example 2
[0076] like Figure 2 and Figure 4 As shown, this embodiment provides a frequency calibration method for an MCU circuit, comprising steps S1 to S3, and further comprising step S4. In this embodiment, the fixed memory of the MCU circuit comprises an OTP type memory.
[0077] In step S1, a frequency calibration program is preset in a fixed memory (eg, an OTP memory) of the MCU circuit.
[0078] In one embodiment, the method for presetting the frequency calibration program includes: burning the frequency calibration program into a first storage area of an OTP memory through an external frequency calibration circuit.
[0079] Specifically, the external frequency calibration circuit includes a tester or a programmer. Due to cost and ease of use, a programmer is usually selected as the external frequency calibration circuit.
[0080] In step S2 , the MCU circuit is triggered to execute a frequency calibration program to obtain a target TRIM value, and the target TRIM value is stored in a TRIM value storage area of the MCU circuit.
[0081] As an optional solution, the MCU circuit is triggered to execute the frequency calibration program after the soft seal dispensing process or the hard seal welding process, that is, step S2 is executed after the soft seal dispensing process or the hard seal welding process, to avoid frequency changes caused by the soft seal dispensing process or the hard seal welding process and improve the frequency calibration accuracy.
[0082] In practical applications, for occasions with high frequency accuracy requirements, step S2 can be selected to be executed after the hard seal welding process to ensure high frequency accuracy; for low-cost occasions, step S2 can be selected to be executed after the soft seal dispensing process. In this way, the hard seal process can be omitted, which is conducive to reducing production costs.
[0083] It should be noted that step S1 can be completed in the same process as step S2, or in a process before the process corresponding to step S2; in addition, step S3 can be completed in the same process as step S2, or in a process after the process corresponding to step S2, which has no effect on this embodiment.
[0084] In one embodiment, the method for executing the frequency calibration program includes: controlling the MCU circuit to re-power on to trigger it to execute the frequency calibration program. It should be noted that since the MCU circuit only has the frequency calibration program, the MCU circuit will automatically trigger the execution of the frequency calibration program after re-powering on.
[0085] The method for obtaining the target TRIM value and the method for storing the target TRIM value in this embodiment are the same as those in the first embodiment. For related contents, please refer to the first embodiment and will not be repeated here.
[0086] In addition, when setting the TRIM value storage area, if the MCU circuit of this embodiment does not include an auxiliary memory, the fourth storage area of the OTP type memory is used as the TRIM value storage area; if the MCU circuit of this embodiment includes an auxiliary memory, the TRIM value storage area is set in the auxiliary memory.
[0087] Step S3, removing the frequency calibration program in the fixed memory (eg, OTP memory).
[0088] In one embodiment, the method for removing the frequency calibration program includes: overwriting the frequency calibration program in the first storage area of the OTP type memory with an empty instruction through an external frequency calibration circuit to achieve the removal of the frequency calibration program; wherein the so-called empty instruction is to burn a NOP instruction of all 0s into the first storage area of the OTP memory through the external frequency calibration circuit, and the purpose of removal is achieved by overwriting the frequency calibration program.
[0089] Of course, in other embodiments, an external frequency calibration circuit may be used to program a skip instruction before the frequency calibration program in the first storage area of an OTP memory. During program execution, the frequency calibration program is skipped to achieve the purpose of removing the frequency calibration program. Since an OTP memory can only be programmed once, when programming the frequency calibration program, a storage address for the program skip instruction may be reserved at the beginning of the first storage area, thereby facilitating subsequent programming of the program skip instruction into the first storage area before the frequency calibration program.
[0090] Furthermore, the method for removing the frequency calibration program further includes: burning a normal operation program into the second storage area of the OTP type memory through the external frequency calibration circuit.
[0091] Step S4: Powering on the MCU circuit again triggers it to execute the normal operating procedure and sets the MCU circuit's oscillator frequency by loading the target TRIM value from the TRIM value storage area. Note that during step S4, the frequency calibration procedure is either overwritten or skipped, so the MCU circuit only executes the normal operating procedure.
[0092] Example 3
[0093] like Figure 2 and Figure 5 As shown, this embodiment provides a frequency calibration method for an MCU circuit, comprising steps S1 to S3, and further comprising step S4. In this embodiment, the fixed memory of the MCU circuit comprises an OTP type memory.
[0094] In step S1, a frequency calibration program is preset in a fixed memory (eg, an OTP memory) of the MCU circuit.
[0095] In one embodiment, the method for presetting the frequency calibration program includes: burning a normal operation program into a third storage area of an OTP type memory through an external frequency calibration circuit, wherein the normal operation program is additionally provided with a second external condition and a frequency calibration program.
[0096] This embodiment adds a second external condition and a frequency calibration program to the normal operation program, and uses the satisfaction of the second external condition to trigger the MCU circuit to execute the frequency calibration program, thereby achieving frequency calibration of the internal oscillator of the MCU circuit, thereby obtaining a more accurate oscillator frequency.
[0097] Specifically, the external frequency calibration circuit includes a tester or a programmer. Due to cost and ease of use, a programmer is usually selected as the external frequency calibration circuit.
[0098] In step S2 , the MCU circuit is triggered to execute a frequency calibration program to obtain a target TRIM value, and the target TRIM value is stored in a TRIM value storage area of the MCU circuit.
[0099] As an optional solution, the MCU circuit is triggered to execute the frequency calibration program after the soft seal dispensing process or the hard seal welding process, that is, step S2 is executed after the soft seal dispensing process or the hard seal welding process, to avoid frequency changes caused by the soft seal dispensing process or the hard seal welding process and improve the frequency calibration accuracy.
[0100] In practical applications, for occasions with high frequency accuracy requirements, step S2 can be selected to be executed after the hard seal welding process to ensure high frequency accuracy; for low-cost occasions, step S2 can be selected to be executed after the soft seal dispensing process. In this way, the hard seal process can be omitted, which is conducive to reducing production costs.
[0101] It should be noted that step S1 can be completed in the same process as step S2, or in a process before the process corresponding to step S2; in addition, step S3 can be completed in the same process as step S2, or in a process after the process corresponding to step S2, which has no effect on this embodiment.
[0102] In one embodiment, the method for executing the frequency calibration program includes: controlling the MCU circuit to power on again and applying a second external condition to the second port of the MCU circuit through an external frequency calibration circuit, so as to trigger the MCU circuit to execute the frequency calibration program through the second external condition.
[0103] Specifically, the second external condition includes a pulse set to 0, set to 1 or a preset rule, wherein the pulse of the preset rule includes a single-cycle pulse or a pulse of two or more cycles; for pulses of two or more cycles, the pulse duration of each cycle can be the same or different, which has no effect on this embodiment.
[0104] In actual applications, after executing the frequency calibration method described in this embodiment, the MCU circuit should avoid applying the second external condition to the second port during normal operation; in order to avoid the second port being triggered by mistake, the second external condition is preferably designed to be relatively complex, so that the second port can be used for other applications instead of being idle.
[0105] In addition, the second port can be a data port or clock port in the MCU circuit connected to the external frequency calibration circuit, or it can be a dedicated port in the MCU circuit connected to the external frequency calibration circuit. Of course, in order to avoid accidentally triggering the frequency calibration program when the MCU circuit is working normally, a dedicated port is usually used as the second port.
[0106] The method for obtaining the target TRIM value, the method for storing the target TRIM value, and the method for setting the TRIM value storage area in this embodiment are the same as those in the second embodiment. For related contents, please refer to the second embodiment and will not be repeated here.
[0107] Step S3, removing the frequency calibration program in the fixed memory (eg, OTP memory).
[0108] In one embodiment, the method for removing the frequency calibration program includes: removing the frequency calibration program by removing the second external condition applied to the second port; taking the second external condition including a pulse according to a preset rule as an example, in step S3 or even step S4 after step S2, the pulse according to the preset rule is no longer applied to the second port of the MCU circuit, so that the frequency calibration program cannot be triggered, thereby achieving the purpose of removing the frequency calibration program.
[0109] Step S4: Powering on the MCU circuit again triggers it to execute the normal operating procedure, and sets the MCU circuit's oscillator frequency by loading the target TRIM value from the TRIM value storage area. Note that during step S4, since the second external condition is no longer applied to the second port of the MCU circuit, the frequency calibration procedure added to the normal operating procedure cannot be triggered. The MCU circuit only executes the remaining procedures in the normal operating procedure, excluding the frequency calibration procedure.
[0110] Example 4
[0111] like Figure 2 and Figure 6 As shown, this embodiment provides a frequency calibration method for an MCU circuit, comprising steps S1 to S3, and further comprising step S4. In this embodiment, the fixed memory of the MCU circuit comprises a FLASH memory.
[0112] In step S1, a frequency calibration program is preset in a fixed memory (eg, a FLASH memory) of the MCU circuit.
[0113] In one embodiment, the method for presetting the frequency calibration program includes: burning the frequency calibration program into a first storage area of a FLASH memory through an external frequency calibration circuit.
[0114] Specifically, the external frequency calibration circuit includes a tester or a programmer. Due to cost and ease of use, a programmer is usually selected as the external frequency calibration circuit.
[0115] In step S2 , the MCU circuit is triggered to execute a frequency calibration program to obtain a target TRIM value, and the target TRIM value is stored in a TRIM value storage area of the MCU circuit.
[0116] As an optional solution, the MCU circuit is triggered to execute the frequency calibration program after the soft seal dispensing process or the hard seal welding process, that is, step S2 is executed after the soft seal dispensing process or the hard seal welding process, to avoid frequency changes caused by the soft seal dispensing process or the hard seal welding process and improve the frequency calibration accuracy.
[0117] In practical applications, for occasions with high frequency accuracy requirements, step S2 can be selected to be executed after the hard seal welding process to ensure high frequency accuracy; for low-cost occasions, step S2 can be selected to be executed after the soft seal dispensing process. In this way, the hard seal process can be omitted, which is conducive to reducing production costs.
[0118] It should be noted that step S1 can be completed in the same process as step S2, or in a process before the process corresponding to step S2; in addition, step S3 can be completed in the same process as step S2, or in a process after the process corresponding to step S2, which has no effect on this embodiment.
[0119] In one embodiment, the method for executing the frequency calibration program includes: controlling the MCU circuit to re-power on to trigger it to execute the frequency calibration program. It should be noted that since the MCU circuit only has the frequency calibration program, the MCU circuit will automatically trigger the execution of the frequency calibration program after re-powering on.
[0120] The method for obtaining the target TRIM value and the method for storing the target TRIM value in this embodiment are the same as those in the first embodiment. For related contents, please refer to the first embodiment and will not be repeated here.
[0121] In addition, when setting the TRIM value storage area, if the MCU circuit of this embodiment does not include an auxiliary memory, the second storage area of the FLASH type memory is used as the TRIM value storage area; if the MCU circuit of this embodiment includes an auxiliary memory, the TRIM value storage area is set in the auxiliary memory.
[0122] Step S3, removing the frequency calibration program in the fixed memory (eg, FLASH memory).
[0123] In one embodiment, the method for removing the frequency calibration program includes: erasing the frequency calibration program in the first storage area through an external frequency calibration circuit.
[0124] Furthermore, the method for removing the frequency calibration program further includes: burning a normal operation program into the first storage area of the FLASH memory through an external frequency calibration circuit.
[0125] Of course, the normal operation program can also be written into the first storage area of the FLASH memory by an external frequency calibration circuit to overwrite the frequency calibration program, thereby removing the frequency calibration program and writing the normal operation program at the same time.
[0126] Step S4: Control the MCU circuit to power on again to trigger it to execute the normal operation program, and set the MCU circuit's oscillator frequency by loading the target TRIM value from the TRIM value storage area. It should be noted that during the execution of step S4, since the frequency calibration program is erased, the MCU circuit only executes the normal operation program.
[0127] In summary, the frequency calibration method of an MCU circuit of the present invention uses the fixed memory and central processing unit of the MCU circuit itself to assist in frequency calibration, without the need for additional test modules and external pins used in conjunction with them, which is conducive to reducing circuit costs; in addition, by executing the frequency calibration program after the soft seal dispensing process or the hard seal welding process, it is conducive to improving the accuracy of frequency calibration. The frequency calibration method of the present invention has low cost, high accuracy, easy use, and a wide range of applications. Therefore, the present invention effectively overcomes the various shortcomings of the prior art and has high industrial utilization value.
[0128] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.
Claims
1. A frequency calibration method for an MCU circuit, characterized in that: The frequency calibration method comprises: Presetting a frequency calibration program in a fixed memory of the MCU circuit; triggering the MCU circuit to execute the frequency calibration program to obtain a target TRIM value, and storing the target TRIM value in a TRIM value storage area of the MCU circuit; The frequency calibration program in the fixed memory is removed.
2. The frequency calibration method of the MCU circuit according to claim 1, wherein The fixed memory includes a MASK type memory; at this time, The method for presetting the frequency calibration program includes: burning a normal operation program into the MASK type memory through a mask process, wherein the normal operation program is additionally provided with a first external condition and the frequency calibration program; The method for executing the frequency calibration program includes: controlling the MCU circuit to be powered on again and applying the first external condition to the first port of the MCU circuit through an external frequency calibration circuit, so as to trigger the MCU circuit to execute the frequency calibration program through the first external condition; The method for removing the frequency calibration program includes removing the frequency calibration program by removing the first external condition applied to the first port.
3. The frequency calibration method of the MCU circuit according to claim 2, wherein: The first external condition includes a pulse set to 0, set to 1, or a preset rule.
4. The frequency calibration method of the MCU circuit according to claim 1, wherein: The fixed memory includes an OTP type memory; at this time, The method for presetting the frequency calibration program includes: burning the frequency calibration program into the first storage area of the OTP type memory through an external frequency calibration circuit; The method for executing the frequency calibration program includes: controlling the MCU circuit to re-power on to trigger it to execute the frequency calibration program; The method for removing the frequency calibration program includes: removing the frequency calibration program by overwriting the frequency calibration program in the first storage area with an empty instruction through the external frequency calibration circuit, or removing the frequency calibration program by burning a program skip instruction before the frequency calibration program in the first storage area through the external frequency calibration circuit; or, the method for removing the frequency calibration program also includes: burning a normal operation program in the second storage area of the OTP type memory through the external frequency calibration circuit.
5. The frequency calibration method of the MCU circuit according to claim 1, wherein: The fixed memory includes an OTP type memory; at this time, The method for presetting the frequency calibration program includes: burning a normal operation program into the third storage area of the OTP type memory through an external frequency calibration circuit, wherein the normal operation program is additionally provided with a second external condition and the frequency calibration program; The method for executing the frequency calibration program includes: controlling the MCU circuit to power on again and applying the second external condition to the second port of the MCU circuit through the external frequency calibration circuit, so as to trigger the MCU circuit to execute the frequency calibration program through the second external condition; The method for removing the frequency calibration program includes removing the frequency calibration program by removing the second external condition applied to the second port.
6. The frequency calibration method of the MCU circuit according to claim 5, characterized in that: The second external condition includes a pulse set to 0, set to 1, or a preset rule.
7. The frequency calibration method of the MCU circuit according to claim 1, wherein: The fixed memory includes a FLASH type memory; at this time, The method for presetting the frequency calibration program includes: burning the frequency calibration program into the first storage area of the FLASH memory through an external frequency calibration circuit; The method for executing the frequency calibration program includes: controlling the MCU circuit to re-power on to trigger it to execute the frequency calibration program; The method for removing the frequency calibration program includes: erasing the frequency calibration program in the first storage area through the external frequency calibration circuit; or the method for removing the frequency calibration program also includes: burning a normal operation program in the first storage area through the external frequency calibration circuit.
8. The frequency calibration method for an MCU circuit according to any one of claims 1 to 7, characterized in that: The method for obtaining the target TRIM value includes: The MCU circuit enables its internal oscillator and enables the periodic flipping of its third port through the frequency calibration program, wherein the frequency calibration program traverses each preset TRIM value, and the ratio of the oscillator frequency to the flipping frequency of the third port is m:1, where m is an integer greater than 1; The flipping frequencies corresponding to the preset TRIM values are measured and recorded by an external frequency calibration circuit, and the preset TRIM value close to the target frequency is found out through the flipping frequencies as the target TRIM value.
9. The frequency calibration method of the MCU circuit according to claim 8, characterized in that: storing the target TRIM value in the TRIM value storage area through the external frequency calibration circuit; When the fixed memory includes a MASK type memory, the MCU circuit is further configured with an auxiliary memory, wherein the TRIM value storage area is provided in the auxiliary memory; When the fixed memory includes an OTP memory, the fourth storage area of the OTP memory is used as the TRIM value storage area; When the fixed memory includes a FLASH memory, the second storage area of the FLASH memory is used as the TRIM value storage area; Wherein, when the fixed memory includes an OTP memory or a FLASH memory, if the MCU circuit is configured with the auxiliary memory, the TRIM value storage area is set in the auxiliary memory.
10. The frequency calibration method of the MCU circuit according to claim 2, 4, 5 or 7, characterized in that: A normal operating program is burned into the fixed memory, and the frequency calibration method further includes: The MCU circuit is controlled to be powered on again to trigger it to execute the normal operation program, and the oscillator frequency of the MCU circuit is set by loading the target TRIM value of the TRIM value storage area.
Citation Information
Patent Citations
Testing method and system of MCU
CN104035023A
MCU (Micro Control Unit) calibration method and system
CN105786662A
Method and circuit for calibrating internal clock of MCU (Microprogrammed Control Unit) chip
CN116185128A
Self-calibration compensation method of analog device
CN117215280A
Integrated circuit with self-correcting function, measuring apparatus therefor and parameter self-recording method
CN1884976A