Calibration device for internal clock source frequency of chip
By designing the internal clock source frequency calibration device of the chip, the internal clock frequency is automatically acquired and calibrated, and the problem of chip clock frequency deviation is solved, and automatic calibration without manual intervention and external hardware support is achieved, reducing costs and improving production efficiency.
Patent Information
- Application Number
- CN202420316624.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-20
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2034-02-20
AI Technical Summary
There is a large deviation in the internal clock frequency of existing chips, which leads to the chip requiring external hardware support or manual intervention for clock frequency calibration during the production process, which is cumbersome and expensive.
A chip internal clock source frequency calibration device is designed. By configuring modules, obtaining modules, computing modules and calibration modules, the internal clock frequency of the chip is automatically obtained and calibrated. Without external hardware support or manual intervention, the calibration value is directly stored in the pre-pre- Read the information area to ensure that the clock frequency is within the preset range when the next power-on is powered on.
Automatic calibration of chip clock frequency is realized, reducing labor and time costs, reducing external wiring requirements, and improving production efficiency.
Smart Images

Figure CN221978930U_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of chip technology, and in particular to a device for calibrating the frequency of a clock source inside a chip. Background Art
[0002] Generally, there are two types of working clock frequencies for chips: one is the frequency generated by the quartz crystal oscillator outside the chip, which is a stable and accurate clock signal; the other is generated by the clock oscillator inside the chip, but due to the limitations of the existing integrated circuit manufacturing process, this clock signal usually has a large deviation, which depends on the production process. Due to the large deviation of the internal clock frequency, various functions inside the chip that rely on the clock communication module cannot be used normally. For this reason, when the chip packaging production is completed and enters the testing phase, the chip clock frequency needs to be calibrated; most of the existing solutions require external input of the standard clock frequency for calibration, but this requires hardware support such as the signal generator output frequency and external wiring; or the clock calibration register value of the chip is modified by manually downloading the program continuously, but the manual operation is more cumbersome. Summary of the invention
[0003] The present application provides a device for calibrating the frequency of a chip's internal clock source, which can enable the chip clock calibration process to occur without the need for manual intervention or other external hardware support, thereby greatly saving manpower and time costs.
[0004] In a first aspect, an embodiment of the present application provides a device for calibrating a frequency of a clock source inside a chip, comprising:
[0005] The first configuration module is used to configure the main frequency clock of the chip to an external high-speed crystal oscillator clock;
[0006] A first acquisition module is used to acquire the count value of a TIM timer in a chip;
[0007] A first calculation module, used for obtaining an internal low-speed clock frequency of the chip based on the count value;
[0008] A first calibration module, configured to determine a first calibration value based on the internal low-speed clock frequency when the internal low-speed clock frequency is not within a first preset expected range, and return to execute the first acquisition module;
[0009] The first input module is used to input a first calibration value into a pre-read information storage area of the chip when the internal low-speed clock frequency is within a first preset expected range.
[0010] Furthermore, the first calibration module is used to reduce the first calibration value by 1 when the internal low-speed clock frequency is greater than the maximum value of the first preset expected range; and increase the first calibration value by 1 when the internal low-speed clock frequency is less than the minimum value of the first preset expected range.
[0011] Furthermore, the count value includes a first count value corresponding to the first rising edge and a second count value corresponding to the second rising edge.
[0012] Furthermore, the first calculation module is used to calculate a first difference between the second count value and the first count value when the second count value is greater than the first count value, and divide the current clock frequency of the chip by the first difference to obtain an internal low-speed clock frequency; and, when the second count value is less than the first count value, subtract the first count value from the initial default value of the first calibration value, and then add the second count value to obtain a second difference, and divide the current clock frequency of the chip by the second difference to obtain the internal low-speed clock frequency.
[0013] Furthermore, the device also includes:
[0014] The second configuration module is used to configure the main frequency clock of the chip to the internal high-speed crystal oscillator clock;
[0015] A third configuration module is used to configure the clock source of the low power consumption timer of the chip to be an external low speed crystal oscillator clock;
[0016] A second acquisition module is used to acquire the standard frequency of the low power consumption timer through the TIM timer;
[0017] A second calculation module, used for calculating the capture clock frequency of the chip according to the standard frequency;
[0018] A second calibration module, configured to determine a second calibration value based on the capture clock frequency when the capture clock frequency is not within a second preset expected range, and return to execute the second acquisition module;
[0019] The second input module is used to input the second calibration value into the pre-read information storage area of the chip when the capture clock frequency is within a second preset expected range.
[0020] Furthermore, the second calculation module includes:
[0021] A first rising edge unit, used for obtaining a third count value according to a first rising edge in the standard frequency;
[0022] A second rising edge unit, used for obtaining a fourth count value according to a second rising edge in the standard frequency;
[0023] The capture calculation unit is used to obtain a capture clock frequency based on the third count value and the fourth count value.
[0024] Further, the capture calculation unit is used to calculate a third difference between the fourth count value and the third count value when the fourth count value is greater than the third count value, and divide the target clock frequency of the chip by the third difference to obtain the capture clock frequency;
[0025] And, when the fourth count value is less than the third count value, the third count value is subtracted from the initial default value of the second calibration value, and then added to the fourth count value to obtain a fourth difference, and the target clock frequency of the chip is divided by the fourth difference to obtain the capture clock frequency.
[0026] Furthermore, the second calibration module is used to reduce the second calibration value by 1 when the capture clock frequency is greater than the maximum value of the second preset expected range; and increase the second calibration value by 1 when the capture clock frequency is less than the minimum value of the second preset expected range.
[0027] Furthermore, the target clock frequency of the chip is 32M.
[0028] Furthermore, the external low speed crystal oscillator clock is 32.768KHz.
[0029] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:
[0030] The calibration device for the chip internal clock source frequency provided in the embodiment of the present application determines the first calibration value through the first preset expected range and the current internal low-speed clock frequency of the chip, and puts the first calibration value into the pre-read information storage area of the chip, thereby ensuring that the chip can pre-read the first calibration value the next time it is powered on, so that the internal low-speed clock frequency is the expected value; the device of the present application realizes full automatic calibration after connecting to the chip to be calibrated, without the need for human intervention, and does not need to generate a standard frequency such as a signal generator and then input it into the chip, thereby reducing the external wiring of the board-level system and greatly saving manpower and time costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A structural diagram of a device for calibrating the frequency of a chip internal clock source provided as an exemplary embodiment of the present application.
[0032] Figure 2 A structural diagram of an internal high-speed clock frequency calibration device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0033] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0034] Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative work shall fall within the scope of protection of this application.
[0035] See also Figure 1 , the embodiment of the present application provides a device for calibrating the frequency of a chip internal clock source, comprising:
[0036] The first configuration module 101 is used to configure the main frequency clock of the chip to be an external high-speed crystal oscillator clock.
[0037] In the specific implementation process, the hardware chip is connected to an external crystal oscillator, so the present application uses the first configuration module 101 to make the main clock frequency of the chip the clock frequency generated by the external crystal oscillator.
[0038] The first acquisition module 102 is used to acquire the count value of the TIM timer in the chip.
[0039] The count value includes a first count value corresponding to the first rising edge and a second count value corresponding to the second rising edge.
[0040] Specifically, the TIM timer of the chip is configured for rising edge capture, and the timer will collect two rising edge count values, the first rising edge count value is the timer capture value N1, and the second rising edge count value is the timer capture value N2.
[0041] The first calculation module 103 is used to obtain the internal low-speed clock frequency of the chip based on the count value.
[0042] The first calibration module 104 is configured to determine a first calibration value based on the internal low-speed clock frequency when the internal low-speed clock frequency is not within a first preset expected range, and return to execute the first acquisition module 102 .
[0043] Specifically, the first preset expected range is set according to the expected value of the internal low-speed clock frequency. When the low-speed clock frequency of the chip is to be calibrated to 32.768KHz, the first preset expected range may be 37.6KHz to 38KHz.
[0044] The first input module 105 is used to input a first calibration value into a pre-read information storage area of the chip when the internal low-speed clock frequency is within a first preset expected range.
[0045] Before calibration, the first calibration value may be an initial default value of 0xFF; the count value of the capture timer is then used to calculate and determine whether the first calibration value is to be increased by 1 or decreased by 1. Specifically, the first calibration module 104 is used to decrease the first calibration value by 1 when the internal low-speed clock frequency is greater than the maximum value of the first preset expected range; and increase the first calibration value by 1 when the internal low-speed clock frequency is less than the minimum value of the first preset expected range.
[0046] In the specific implementation process, only by writing the first calibration value into the power-on pre-read area of the chip, it can be ensured that when the chip is powered on next time, the chip can pre-read the first calibration value, so that the internal low-speed clock frequency of the chip is the expected value corresponding to the first preset expected range; therefore, after the device for calibrating the clock of the present application is connected to the chip, automatic calibration of the clock source can be realized, and the internal low-speed clock calibration value can be quickly traversed without manual intervention. In the process of mass production of small batches of chips, compared with manually modifying and writing the calibration value, the present application can greatly save time and labor costs.
[0047] A calibration device for the internal clock source frequency of a chip provided by the above embodiment determines the first calibration value through the first preset expected range and the current internal low-speed clock frequency of the chip, and places it in the pre-read information storage area of the chip, ensuring that when the chip is powered on next time, the chip can pre-read the first calibration value, so that the internal low-speed clock frequency is the expected value; the device of the present application realizes full-automatic calibration after being connected to the chip to be calibrated, without manual intervention, and does not require a signal generator to generate a standard frequency and then input it to the chip, reducing the external wiring of the board-level system, and greatly saving labor and time costs.
[0048] In some embodiments, the first calculation module 103 is configured to calculate the first difference between the second count value and the first count value when the second count value is greater than the first count value, and divide the current clock frequency of the chip by the first difference to obtain the internal low-speed clock frequency; and, when the second count value is less than the first count value, subtract the first count value from the initial default value of the first calibration value, then add the second count value to obtain the second difference, and divide the current clock frequency of the chip by the second difference to obtain the internal low-speed clock frequency.
[0049] Specifically, assume that the first count value of the first rising edge is the capture value N1 of the timer, and the second count value of the second rising edge is the capture value N2 of the timer. Then, the magnitudes of N1 and N2 will be judged first. When N2 > N1, the calculated internal low-speed clock frequency output by the current chip = (the current clock frequency of the chip) / (N2 - N1). When N2 < N1, the calculated internal low-speed clock frequency output by the current chip = (the current clock frequency of the chip) / ((0xFFFF - N1) + N2).
[0050] In some embodiments, the device further includes:
[0051] A second configuration module 201 for configuring the main clock of the chip as the internal high-speed crystal oscillator clock.
[0052] A third configuration module 202 for configuring the clock source of the low-power timer of the chip as the external low-speed crystal oscillator clock.
[0053] Among them, the external low-speed crystal oscillator is determined by the type of crystal oscillator used by the external hardware, which is generally 32.768KHz. The internal high-speed clock frequency is the calibration target at this time, and the calibrated internal high-speed clock frequency can be adjusted as needed.
[0054] The second acquisition module 203 is configured to acquire the standard frequency of the low power consumption timer through the TIM timer.
[0055] In the specific implementation process, there are two timers inside the chip: low-power timer G1 and TIM timer G2. The internal low-speed clock is configured to be an external low-speed crystal oscillator clock frequency of 32.768KHz. At this time, the high-speed clock used by the chip is an inaccurate internal clock frequency, and the internal low-speed clock is an accurate 32.768Hz frequency. This application configures the counting clock of the low-power timer G1 to a low-speed clock through the third configuration module 202, and then outputs a PWM signal with a duty cycle of 1024Hz through the low-power timer G1. At this time, the clock frequency used by the TIM timer G2 is an inaccurate internal high-speed clock, and then the TIM timer G2 is used to capture the 1024Hz PWM signal generated by the low-power timer G1.
[0056] The second calculation module 204 is used to calculate the capture clock frequency of the chip according to the standard frequency.
[0057] Specifically, after acquiring the standard frequency, i.e., the PWM signal, the second calculation module 204 obtains a third count value according to the first rising edge in the standard frequency through the first rising edge unit; obtains a fourth count value according to the second rising edge in the standard frequency through the second rising edge unit; and obtains a capture clock frequency based on the third count value and the fourth count value through the capture calculation unit.
[0058] Specifically, the capture calculation unit is used to calculate the third difference between the fourth count value and the third count value when the fourth count value is greater than the third count value, and divide the target clock frequency of the chip by the third difference to obtain the capture clock frequency; and when the fourth count value is less than the third count value, subtract the third count value from the initial default value of the second calibration value, and add the fourth count value to obtain the fourth difference, and divide the target clock frequency of the chip by the fourth difference to obtain the capture clock frequency.
[0059] The target clock frequency is the expected value of the internal high-speed clock frequency that needs to be calibrated, which may be 32M.
[0060] Similarly, assume that the third count value at the first rising edge is the capture value N3 of the timer, and the fourth count value at the second rising edge is the capture value N4 of the timer. Then, the sizes of N3 and N4 will be judged first. When N4 > N3, the current capture clock frequency is calculated as = (the target clock frequency of the chip, e.g., 32M) / (N4 - N3). When N4 < N3, the current capture clock frequency is calculated as = (the target clock frequency of the chip, e.g., 32M) / ((0xFFFF - N3) + N4).
[0061] The second calibration module 205 is used to determine a second calibration value based on the capture clock frequency when the capture clock frequency is not within the second preset expected range, and then return to execute the second acquisition module 203.
[0062] The second calibration module 205 is used to decrement the second calibration value by 1 when the capture clock frequency is greater than the maximum value of the second preset expected range; and increment the second calibration value by 1 when the capture clock frequency is less than the minimum value of the second preset expected range. A margin can be left to set the second preset expected range between 1022 and 1025. Theoretically, if the target clock frequency of the chip is about the set 32M, the calculated capture clock frequency will also be about 1024Hz.
[0063] Among them, the initial default value of the second calibration value before calibration can also be set to 0xFF, and the second preset expected range is also set according to the expected value of the internal high-speed clock frequency; if you want to calibrate the internal high-speed clock frequency of the chip to 32M, and the known input frequency is 1024Hz, the obtained capture clock frequency can be calculated by the above calculation method as = 32M / (the difference between the timer capture values N4 and N3). Then theoretically, when the calculated capture clock frequency is 1024Hz, the current internal high-speed clock frequency of the chip is 32M. Therefore, the second preset expected range can be 1023 - 1025Hz.
[0064] The second input module 206 is used to input the second calibration value into the pre-read information storage area of the chip when the capture clock frequency is within the second preset expected range. Specifically, only by writing the second calibration value into the power-on pre-read area of the chip can it be ensured that when the chip is powered on next time, the chip can pre-read the second calibration value, so that the internal high-speed clock frequency of the chip is the target clock frequency.
[0065] It can be understood that this application uses the external high-speed crystal oscillator clock as the working clock of the chip timer to self-calibrate the internal low-speed clock frequency of the chip; and then uses the external low-speed crystal oscillator clock as the working clock of the chip low-power timer to self-calibrate the internal high-speed clock frequency of the chip. During the calibration process, there is no need to generate a standard frequency by a signal generator and then input it to the chip, reducing the external wiring of the board-level system, thereby reducing the hardware requirements for chip clock calibration.
[0066] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0067] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A device for calibrating the frequency of a chip internal clock source, characterized in that: include: The first configuration module is used to configure the main frequency clock of the chip to an external high-speed crystal oscillator clock; A first acquisition module, used to acquire a count value of a TIM timer in the chip; A first calculation module, used for obtaining an internal low-speed clock frequency of the chip based on the count value; A first calibration module, configured to determine a first calibration value based on the internal low-speed clock frequency when the internal low-speed clock frequency is not within a first preset expected range, and return to execute the first acquisition module; The first input module is used to input the first calibration value into the pre-read information storage area of the chip when the internal low-speed clock frequency is within the first preset expected range.
2. The device for calibrating the frequency of the internal clock source of a chip according to claim 1, characterized in that: The first calibration module is used to reduce the first calibration value by 1 when the internal low-speed clock frequency is greater than the maximum value of the first preset expected range; and increase the first calibration value by 1 when the internal low-speed clock frequency is less than the minimum value of the first preset expected range.
3. The device for calibrating the frequency of the internal clock source of a chip according to claim 1, characterized in that: The count value includes a first count value corresponding to the first rising edge and a second count value corresponding to the second rising edge.
4. The device for calibrating the frequency of the internal clock source of a chip according to claim 3, characterized in that: The first calculation module is used for calculating a first difference between the second count value and the first count value when the second count value is greater than the first count value, and dividing the current clock frequency of the chip by the first difference to obtain the internal low-speed clock frequency; Furthermore, when the second count value is less than the first count value, the initial default value of the first calibration value is subtracted from the first count value and then added to the second count value to obtain a second difference, and the current clock frequency of the chip is divided by the second difference to obtain the internal low-speed clock frequency.
5. The device for calibrating the frequency of the internal clock source of a chip according to claim 1, characterized in that: Also includes: A second configuration module, used to configure the main frequency clock of the chip to be an internal high-speed crystal oscillator clock; A third configuration module, configured to configure the clock source of the low power consumption timer of the chip to be an external low speed crystal oscillator clock; A second acquisition module, used for acquiring the standard frequency of the low power consumption timer through the TIM timer; A second calculation module, used for calculating the capture clock frequency of the chip according to the standard frequency; A second calibration module, configured to determine a second calibration value based on the capture clock frequency when the capture clock frequency is not within a second preset expected range, and return to execute the second acquisition module; The second input module is used to input the second calibration value into the pre-read information storage area of the chip when the capture clock frequency is within the second preset expected range.
6. The device for calibrating the frequency of the internal clock source of a chip according to claim 5, characterized in that: The second calculation module includes: A first rising edge unit, used for obtaining a third count value according to a first rising edge in the standard frequency; A second rising edge unit, used for obtaining a fourth count value according to a second rising edge in the standard frequency; A capture calculation unit is used to obtain the capture clock frequency based on the third count value and the fourth count value.
7. The device for calibrating the frequency of the internal clock source of a chip according to claim 6, characterized in that: The capture calculation unit is used for calculating a third difference between the fourth count value and the third count value when the fourth count value is greater than the third count value, and dividing the target clock frequency of the chip by the third difference to obtain the capture clock frequency; And, when the fourth count value is less than the third count value, the initial default value of the second calibration value is subtracted from the third count value and then added to the fourth count value to obtain a fourth difference, and the target clock frequency of the chip is divided by the fourth difference to obtain the capture clock frequency.
8. The device for calibrating the frequency of the internal clock source of a chip according to claim 5, characterized in that: The second calibration module is used to reduce the second calibration value by 1 when the capture clock frequency is greater than the maximum value of the second preset expected range; and increase the second calibration value by 1 when the capture clock frequency is less than the minimum value of the second preset expected range.
9. The device for calibrating the frequency of the internal clock source of a chip according to claim 7, characterized in that: The target clock frequency of the chip is 32M.
10. The device for calibrating the frequency of the internal clock source of a chip according to claim 5, characterized in that: The external low-speed crystal oscillator clock is 32.768KHz.
