Method, device, electronic device and storage medium for calibrating internal clock of chip
By receiving and parsing data frames of the host device, automatically comparing edge times to calibrate the internal clock of the chip, solving the problems of low calibration efficiency and accuracy in the prior art, and achieving efficient automated calibration.
Patent Information
- Application Number
- CN202410341280.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-25
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-03-25
AI Technical Summary
The internal clock calibration efficiency and accuracy of existing chips is low, and manual configuration of program parameters is required for calibration.
By receiving the data frames sent by the host device, the first edge time of the preset position is parsed, the first edge time of the preset edge time is compared with the preset edge time, and the internal clock frequency of the slave device is automatically calibrated.
Improves the calibration efficiency and accuracy of the internal clock of the chip, realizes automatic calibration, and reduces manual intervention.
Smart Images

Figure CN118244093B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of chip technology, and in particular to a method, device, electronic device and storage medium for calibrating a chip internal clock. Background Art
[0002] When writing a chip test program, the chip will output an internal clock signal or a fixed frequency division of the internal clock. Currently, staff are required to use an oscilloscope to view the frequency of the output internal clock signal. If the frequency of the output internal clock signal exceeds the preset value, it is necessary to manually configure the program parameters to calibrate the internal clock. In this way, the efficiency and accuracy of the calibration are low. Summary of the invention
[0003] Some embodiments of the present application aim to provide a method, device, electronic device and storage medium for calibrating the internal clock of a chip. Through the technical solutions of the embodiments of the present application, a data frame sent by a host device is received; the data frame is parsed to obtain a first edge time of a preset position in the data frame; an edge time comparison result is determined based on the first edge time and the preset edge time; the clock set by the slave is calibrated based on the edge time comparison result, by obtaining the first edge time of the preset position in the data frame of the host device, and then comparing it with the preset edge time to obtain an edge time comparison result, and the frequency of the internal clock set by the slave is automatically calibrated based on the edge time comparison result, thereby improving calibration efficiency and accuracy.
[0004] In a first aspect, some embodiments of the present application provide a method for calibrating a chip internal clock, including:
[0005] Receive data frames sent by the host device;
[0006] Parsing the data frame to obtain a first edge time at a preset position in the data frame;
[0007] Determine an edge time comparison result according to the first edge time and the preset edge time;
[0008] The clock set by the slave is calibrated according to the edge time comparison result.
[0009] Some embodiments of the present application obtain the first edge time of a preset position in the data frame of the host device, and then compare it with the preset edge time to obtain an edge time comparison result, and automatically calibrate the frequency of the internal clock set by the slave device according to the edge time comparison result, thereby improving the calibration efficiency and accuracy.
[0010] Optionally, parsing the data frame to obtain a first edge time of a preset position in the data frame includes:
[0011] Parsing the data frame to obtain calibration information of the data frame;
[0012] Determining, according to the calibration information of the data frame, a holding time of a preset level corresponding to the calibration information;
[0013] The first edge time is determined according to the holding time of the preset level.
[0014] Some embodiments of the present application parse the data frame sent by the host to obtain the calibration information of the data frame, and further obtain the holding time of the preset level to obtain the first edge time for comparison with the preset edge time to determine whether the clock needs to be calibrated.
[0015] Optionally, determining an edge time comparison result according to the first edge time and a preset edge time includes:
[0016] If the first edge time is greater than the preset edge time, determining that the clock of the internal clock of the slave device is less than a preset value;
[0017] If the first edge time is less than the preset edge time, it is determined that the clock of the internal clock of the slave device is greater than a preset value.
[0018] Some embodiments of the present application compare the first edge time with the preset edge time to determine whether the internal clock of the slave device needs to be calibrated, thereby improving the calibration efficiency.
[0019] Optionally, calibrating a clock set by the slave according to the edge time comparison result includes:
[0020] If the first edge time is greater than the preset edge time, determining a first edge time difference according to the first edge time and the preset edge time;
[0021] Determining a first calibration value according to the first edge time difference and a preset clock frequency;
[0022] The clock set by the slave is calibrated according to the first calibration value.
[0023] In some embodiments of the present application, a first calibration value is obtained by calculating a first edge time difference and comparing it with a preset clock frequency, and the clock set by the slave is calibrated according to the first calibration value to improve the calibration accuracy.
[0024] Optionally, calibrating a clock set by the slave according to the edge time comparison result includes:
[0025] If the first edge time is less than the preset edge time, determining a second edge time difference according to the first edge time and the preset edge time;
[0026] Determining a second calibration value according to the second edge time difference and a preset clock frequency;
[0027] The clock set by the slave is calibrated according to the second calibration value.
[0028] Some embodiments of the present application calculate the second edge time difference and compare it with a preset clock frequency to obtain a second calibration value, and calibrate the clock set by the slave according to the second calibration value to improve the calibration accuracy.
[0029] Optionally, the method further comprises:
[0030] Determining a third calibration value according to the first calibration value and the preset clock frequency;
[0031] If the third calibration value satisfies the preset calibration range, the clock set by the slave is calibrated.
[0032] Some embodiments of the present application further compare the first calibration value with the preset clock frequency to obtain a third calibration value, and calibrate the clock set on the slave only when the third calibration value satisfies the preset calibration range.
[0033] In a second aspect, some embodiments of the present application provide a device for calibrating a chip internal clock, including:
[0034] A receiving module, used for receiving data frames sent by a host device;
[0035] A parsing module, used for parsing the data frame to obtain a first edge time of a preset position in the data frame;
[0036] A determination module, configured to determine an edge time comparison result according to the first edge time and a preset edge time;
[0037] The calibration module is used to calibrate the clock set by the slave according to the edge time comparison result.
[0038] Some embodiments of the present application obtain the first edge time of a preset position in the data frame of the host device, and then compare it with the preset edge time to obtain an edge time comparison result, and automatically calibrate the frequency of the internal clock set by the slave device according to the edge time comparison result, thereby improving the calibration efficiency and accuracy.
[0039] Optionally, the parsing module is used to:
[0040] Parsing the data frame to obtain calibration information of the data frame;
[0041] Determining, according to the calibration information of the data frame, a holding time of a preset level corresponding to the calibration information;
[0042] The first edge time is determined according to the holding time of the preset level.
[0043] Some embodiments of the present application parse the data frame sent by the host to obtain the calibration information of the data frame, and further obtain the holding time of the preset level to obtain the first edge time for comparison with the preset edge time to determine whether the clock needs to be calibrated.
[0044] Optionally, the determining module is used to:
[0045] If the first edge time is greater than the preset edge time, determining that the clock of the internal clock of the slave device is less than a preset value;
[0046] If the first edge time is less than the preset edge time, it is determined that the clock of the internal clock of the slave device is greater than a preset value.
[0047] Some embodiments of the present application compare the first edge time with the preset edge time to determine whether the internal clock of the slave device needs to be calibrated, thereby improving the calibration efficiency.
[0048] Optionally, the calibration module is used to:
[0049] If the first edge time is greater than the preset edge time, determining a first edge time difference according to the first edge time and the preset edge time;
[0050] Determining a first calibration value according to the first edge time difference and a preset clock frequency;
[0051] The clock set by the slave is calibrated according to the first calibration value.
[0052] In some embodiments of the present application, a first calibration value is obtained by calculating a first edge time difference and comparing it with a preset clock frequency, and the clock set by the slave is calibrated according to the first calibration value to improve the calibration accuracy.
[0053] Optionally, the calibration module is used to:
[0054] If the first edge time is less than the preset edge time, determining a second edge time difference according to the first edge time and the preset edge time;
[0055] Determining a second calibration value according to the second edge time difference and a preset clock frequency;
[0056] The clock set by the slave is calibrated according to the second calibration value.
[0057] Some embodiments of the present application calculate the second edge time difference and compare it with a preset clock frequency to obtain a second calibration value, and calibrate the clock set by the slave according to the second calibration value to improve the calibration accuracy.
[0058] Optionally, the calibration module is used to:
[0059] Determining a third calibration value according to the first calibration value and the preset clock frequency;
[0060] If the third calibration value satisfies the preset calibration range, the clock set by the slave is calibrated.
[0061] Some embodiments of the present application further compare the first calibration value with the preset clock frequency to obtain a third calibration value, and calibrate the clock set on the slave only when the third calibration value satisfies the preset calibration range.
[0062] In a third aspect, some embodiments of the present application provide an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the program, the method for calibrating the internal clock of a chip as described in any embodiment of the first aspect can be implemented.
[0063] In a fourth aspect, some embodiments of the present application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the method for calibrating the internal clock of a chip as described in any embodiment of the first aspect.
[0064] In a fifth aspect, some embodiments of the present application provide a computer program product, comprising a computer program, wherein the computer program, when executed by a processor, can implement the method for calibrating the internal clock of a chip as described in any embodiment of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solutions of some embodiments of the present application, the drawings required for use in some embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0066] Figure 1A schematic diagram of a flow chart of a method for calibrating a chip internal clock provided in an embodiment of the present application;
[0067] Figure 2 A schematic diagram of the structure of a calibration system provided in an embodiment of the present application;
[0068] Figure 3 A timing diagram provided for an embodiment of the present application;
[0069] Figure 4 A schematic diagram of the structure of a device for calibrating a chip internal clock provided in an embodiment of the present application;
[0070] Figure 5 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0071] The technical solutions in some embodiments of the present application will be described below in conjunction with the drawings in some embodiments of the present application.
[0072] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0073] When writing a chip test program, the chip will output an internal clock signal or a fixed frequency division of the internal clock. Currently, staff are required to use an oscilloscope to view the frequency of the output internal clock signal. If the frequency of the output internal clock signal exceeds a preset value, it is necessary to manually configure the program parameters to calibrate the internal clock. In this way, the efficiency and accuracy of the calibration are low. In view of this, some embodiments of the present application provide a method for calibrating the internal clock of a chip, the method comprising receiving a data frame sent by a host device; parsing the data frame to obtain a first edge time at a preset position in the data frame; determining an edge time comparison result based on the first edge time and the preset edge time; calibrating the clock set by the slave according to the edge time comparison result, by obtaining the first edge time at a preset position in the data frame of the host device, and then comparing it with the preset edge time to obtain an edge time comparison result, and automatically calibrating the frequency of the internal clock set by the slave according to the edge time comparison result, thereby improving the calibration efficiency and accuracy.
[0074] like Figure 1 As shown, an embodiment of the present application provides a method for calibrating a chip internal clock, the method comprising:
[0075] S101, receiving a data frame sent by a host device;
[0076] The embodiments of the present application are applied to Figure 2 The calibration system shown includes at least a host device and a slave device, and the host device and the slave device perform data transmission via a UART protocol.
[0077] UART is a universal asynchronous serial communication protocol that uses start bit, data bit, parity bit and stop bit to transmit data. In UART communication, data transmission is carried out at a fixed baud rate, and the sending and receiving ends need to agree on parameters such as baud rate, data bit, parity bit and stop bit in advance. UART is usually used to connect microcontrollers, sensors, peripheral devices, etc., and is also widely used in serial communication in computer systems.
[0078] Start Bit: The start bit indicates the beginning of the data frame. It is always at a logic low level and indicates that the data transmission is about to begin.
[0079] Data Bits: Data bits are the actual data transmission part. It represents the data to be transmitted and can be 5, 6, 7 or 8 bits, depending on the selected data bit length.
[0080] Parity Bit: Parity Bit is optional and is used to detect errors during transmission. Common parity modes include odd parity, even parity, or no parity. The choice of parity bit depends on the parity rules agreed upon by both parties in advance.
[0081] Stop Bit: The stop bit marks the end of the data frame. It is always at a logic high level to inform the receiving end that the data frame has been transmitted.
[0082] UART hardware connection:
[0083] UART usually uses three wires for connection: TX (transmitter), RX (receiver), and ground (GND). The TX line of the transmitter is connected to the RX line of the receiver, and the TX line of the receiver is connected to the RX line of the transmitter. In addition, the ground lines at both ends need to be connected together to ensure that the reference potential of the signal is the same.
[0084] In a single-chip microcomputer or embedded system, the UART is usually connected through pins on the chip, for example, the TX pin of the MCU is connected to the RX pin of the external device, and the RX pin of the MCU is connected to the TX pin of the external device.
[0085] Initialization: First, you need to initialize the UART module, including setting parameters such as baud rate, data bit length, check bit, and stop bit. These parameters need to match the peer device to ensure normal data transmission.
[0086] Sending data: To send data, first write the data to be sent to the UART send buffer. After writing the data to the send buffer programmatically, the UART module will automatically send the data out. Before sending data, you need to check whether the send buffer is empty to ensure that new data can be written safely.
[0087] Receiving data: When receiving data, you need to check whether there is new data in the receive buffer to read. If there is data to read in the receive buffer, you can read the data programmatically and process it.
[0088] Error handling: During UART communication, some errors may occur, such as check errors or frame errors. When receiving data, it is necessary to check the error flag in time to perform corresponding error handling and recovery.
[0089] Interrupt handling: In order to improve the response speed and efficiency of the system, UART interrupts are usually used to handle receiving and sending data. When interrupts are used, the corresponding interrupt service routine (ISR) needs to be written to handle the situation where new data is received or the send buffer is empty.
[0090] Closing and cleaning up: When the program ends or the UART is no longer needed, the UART module needs to be closed and the corresponding resource cleanup work needs to be performed to release related resources and close the corresponding interrupts.
[0091] Host device: It can be an MCU or other device as long as it supports the UART communication interface.
[0092] Slave device: It can be MCU or other devices as long as it supports UART communication interface.
[0093] Wiring method: The TX of the host device is connected to the RX of the slave device, and the RX of the host device is connected to the TX of the slave device. In the specific implementation process, the host device sends a data frame to the slave device, and the data frame includes a frame header, a frame tail, and an intermediate identifier.
[0094] S102, parsing the data frame to obtain a first edge time at a preset position in the data frame;
[0095] Specifically, after receiving the data frame, the slave device parses the data frame, obtains the frame tail data of the data frame, and calculates the first edge time according to the frame tail data, wherein the first edge time can be the holding time of the high level or the holding time of the low level.
[0096] S103, determining an edge time comparison result according to the first edge time and the preset edge time;
[0097] Specifically, a preset edge time is pre-set on the slave device, and then the first edge time is compared with the preset edge time to determine the size of the first edge time and the preset edge time to obtain an edge time comparison result, which at least includes whether calibration, adjustment up or down is required.
[0098] S104: Calibrate the clock set by the slave according to the edge time comparison result.
[0099] Specifically, the slave device calibrates the internal clock set by the slave device according to the edge time comparison result, and can adjust the internal clock up or down to improve the calibration efficiency and accuracy.
[0100] The host device uses a lower UART clock frequency (which needs to be much lower than the slave's main frequency) to communicate with the slave. When the protocol sent by the host contains the content of the calibration clock information (the content can be 0x55 or 0xAA), and the clock error between the host and the slave is less than the maximum error supported by the slave's serial port communication, the slave obtains the time difference between the two edges in the host timing through the timer (the slave device can receive RX data through the IO analog serial port), and calibrates the error of its own internal clock according to the baud rate time difference, and notifies the host in the protocol that the calibration is completed. After completion, it calibrates the correction value of its own internal clock.
[0101] The clock calibration of the embodiment of the present application saves manpower and is also convenient for calibrating the internal clock of the chip on the device (using the main device as the clock reference) when the device is repaired or upgraded.
[0102] Some embodiments of the present application obtain the first edge time of a preset position in the data frame of the host device, and then compare it with the preset edge time to obtain an edge time comparison result, and automatically calibrate the frequency of the internal clock set by the slave device according to the edge time comparison result, thereby improving the calibration efficiency and accuracy.
[0103] Another embodiment of the present application further supplements the chip internal clock calibration method provided in the above embodiment.
[0104] Optionally, parsing the data frame to obtain the first edge time of a preset position in the data frame includes:
[0105] Parse the data frame to obtain calibration information of the data frame;
[0106] Determining, according to the calibration information of the data frame, a holding time of a preset level corresponding to the calibration information;
[0107] The first edge time is determined according to the holding time of the preset level.
[0108] Specifically, the slave device parses the data frame, and the parsed middle content is the clock synchronization command, and the parsed frame end is the calibration information, which can be a preset character string, such as 0055, etc., and obtains the holding time of a preset level in the preset character string, for example, it can be the holding time of a high level or the holding time of a low level, and the obtained holding time of the preset level is determined as the first edge time.
[0109] Exemplarily, if the calibration information parsed at the end of the frame is 0055, the corresponding binary number is 00000000 01010101, and the high level is 4 1s, the holding time of the 4 high levels is determined as the first edge time.
[0110] Some embodiments of the present application parse the data frame sent by the host to obtain the calibration information of the data frame, and further obtain the holding time of the preset level to obtain the first edge time for comparison with the preset edge time to determine whether the clock needs to be calibrated.
[0111] Optionally, determining an edge time comparison result according to the first edge time and the preset edge time includes:
[0112] If the first edge time is greater than the preset edge time, determining that the clock of the internal clock of the slave device is less than a preset value;
[0113] If the first edge time is less than the preset edge time, it is determined that the clock of the internal clock of the slave device is greater than a preset value.
[0114] If the first edge time is equal to the preset edge time, there is no need to calibrate the internal clock of the slave device.
[0115] Some embodiments of the present application compare the first edge time with the preset edge time to determine whether the internal clock of the slave device needs to be calibrated, thereby improving the calibration efficiency.
[0116] Optionally, the clock set by the slave is calibrated according to the edge time comparison result, including:
[0117] If the first edge time is greater than the preset edge time, determining a first edge time difference according to the first edge time and the preset edge time;
[0118] Determining a first calibration value according to the first edge time difference and a preset clock frequency;
[0119] The clock set by the slave is calibrated according to the first calibration value.
[0120] In some embodiments of the present application, a first calibration value is obtained by calculating a first edge time difference and comparing it with a preset clock frequency, and the clock set by the slave is calibrated according to the first calibration value to improve the calibration accuracy.
[0121] Optionally, the clock set by the slave is calibrated according to the edge time comparison result, including:
[0122] If the first edge time is less than the preset edge time, determining a second edge time difference according to the first edge time and the preset edge time;
[0123] Determining a second calibration value according to the second edge time difference and the preset clock frequency;
[0124] The clock set by the slave is calibrated according to the second calibration value.
[0125] Some embodiments of the present application calculate the second edge time difference and compare it with a preset clock frequency to obtain a second calibration value, and calibrate the clock set by the slave according to the second calibration value to improve the calibration accuracy.
[0126] Optionally, the method further comprises:
[0127] Determining a third calibration value according to the first calibration value and a preset clock frequency;
[0128] If the third calibration value satisfies the preset calibration range, the clock set by the slave is calibrated.
[0129] Some embodiments of the present application further compare the first calibration value with the preset clock frequency to obtain a third calibration value, and calibrate the clock set on the slave only when the third calibration value satisfies the preset calibration range.
[0130] like Figure 3 As shown, the frame header of the communication frame can be specified as 0xAA0xAA, the frame tail of the communication frame can be specified as 0x550x55, and the middle content 0x31 is the clock synchronization command, and the baud rate is 1000.
[0131] 2) The host sends 0xAA0xAA 0x31 0x55 0x55. When the slave receives the position 0x31, it can preliminarily determine that clock calibration is required, and then start reading the high and low level time of the IO at RX corresponding to 0x55 at the end of the frame. The high level holding time of more than 4 IOs can be calculated, and then the sum of the high level holding time is calculated. When the entire frame is received and confirmed to be correct, the internal clock can be updated based on the average value of the high level duration.
[0132] The timing of the slave serial port receiving 0x55 is shown in the figure above. In the figure, DATA is the parsed data, CLK is the sending clock inside the host serial port, and RX is the waveform of the receiving end of the slave serial port.
[0133] After receiving the start bit, the slave starts to measure the time difference between the high-level holding time considered by the internal clock and the actual high-level holding time. Each 0x55 can be measured 4 times, and there are 2 0x55s in the protocol in the above embodiment, which can be measured 8 times.
[0134] Assume that the high-level single-hold time considered by the internal clock of the 8 slaves is a1 (9ms), and the high-level hold time tested is b1, b2, b3, b4, b5, b6, b7, b8
[0135] Then set T1=a1×8, T2=b1+b2+b3+b4+b5+b6+b7+b8.
[0136] If T1 is greater than T2, the frequency of the internal oscillator of the slave is too low. If T1 is equal to T2, the internal oscillator of the slave has no error. If T1 is less than T2, the frequency of the internal oscillator of the slave is too high.
[0137] Assuming that the current main frequency is set to A (MHz), that is, the preset clock frequency, if T1 is greater than T2, then ΔT = T1-T2, and the internal clock frequency is corrected to the first calibration value, that is,
[0138] Assuming that the current main frequency is set to A (MHz), if T1 is less than T2, then ΔT = T2-T1, and the internal clock frequency is corrected to the second calibration value, that is,
[0139] During the communication process, the above steps can be repeated for each frame to maintain the accuracy of the internal clock of the slave device.
[0140] The slave device may be a chip or other device that needs to be calibrated.
[0141] It should be noted that each implementable method in this embodiment may be implemented separately, or may be implemented in combination in any combination without conflict, and this application is not limited thereto.
[0142] Another embodiment of the present application provides a device for calibrating a chip internal clock, which is used to execute the method for calibrating a chip internal clock provided in the above embodiment.
[0143] like Figure 4 4 is a schematic diagram of the structure of the chip internal clock calibration device provided in an embodiment of the present application. The chip internal clock calibration device includes a receiving module 401, an analyzing module 402, a determining module 403 and a calibration module 404, wherein:
[0144] The receiving module 401 is used to receive the data frame sent by the host device;
[0145] The parsing module 402 is used to parse the data frame to obtain the first edge time of a preset position in the data frame;
[0146] The determination module 403 is used to determine the edge time comparison result according to the first edge time and the preset edge time;
[0147] The calibration module 404 is used to calibrate the clock set by the slave according to the edge time comparison result.
[0148] Regarding the device in this embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0149] Some embodiments of the present application obtain the first edge time of a preset position in the data frame of the host device, and then compare it with the preset edge time to obtain an edge time comparison result, and automatically calibrate the frequency of the internal clock set by the slave device according to the edge time comparison result, thereby improving the calibration efficiency and accuracy.
[0150] Another embodiment of the present application further supplements the chip internal clock calibration device provided in the above embodiment.
[0151] Optionally, a parsing module for:
[0152] Parse the data frame to obtain calibration information of the data frame;
[0153] Determining, according to the calibration information of the data frame, a holding time of a preset level corresponding to the calibration information;
[0154] The first edge time is determined according to the holding time of the preset level.
[0155] Some embodiments of the present application parse the data frame sent by the host to obtain the calibration information of the data frame, and further obtain the holding time of the preset level to obtain the first edge time for comparison with the preset edge time to determine whether the clock needs to be calibrated.
[0156] Optionally, a module is determined to:
[0157] If the first edge time is greater than the preset edge time, determining that the clock of the internal clock of the slave device is less than a preset value;
[0158] If the first edge time is less than the preset edge time, it is determined that the clock of the internal clock of the slave device is greater than a preset value.
[0159] Some embodiments of the present application compare the first edge time with the preset edge time to determine whether the internal clock of the slave device needs to be calibrated, thereby improving the calibration efficiency.
[0160] Optionally, a calibration module is used to:
[0161] If the first edge time is greater than the preset edge time, determining a first edge time difference according to the first edge time and the preset edge time;
[0162] Determining a first calibration value according to the first edge time difference and a preset clock frequency;
[0163] The clock set by the slave is calibrated according to the first calibration value.
[0164] In some embodiments of the present application, a first calibration value is obtained by calculating a first edge time difference and comparing it with a preset clock frequency, and the clock set by the slave is calibrated according to the first calibration value to improve the calibration accuracy.
[0165] Optionally, a calibration module is used to:
[0166] If the first edge time is less than the preset edge time, determining a second edge time difference according to the first edge time and the preset edge time;
[0167] Determining a second calibration value according to the second edge time difference and the preset clock frequency;
[0168] The clock set by the slave is calibrated according to the second calibration value.
[0169] Some embodiments of the present application calculate the second edge time difference and compare it with a preset clock frequency to obtain a second calibration value, and calibrate the clock set by the slave according to the second calibration value to improve the calibration accuracy.
[0170] Optionally, a calibration module is used to:
[0171] Determining a third calibration value according to the first calibration value and a preset clock frequency;
[0172] If the third calibration value satisfies the preset calibration range, the clock set by the slave is calibrated.
[0173] Some embodiments of the present application further compare the first calibration value with the preset clock frequency to obtain a third calibration value, and calibrate the clock set on the slave only when the third calibration value satisfies the preset calibration range.
[0174] Regarding the device in this embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0175] It should be noted that each implementable method in this embodiment may be implemented separately, or may be implemented in combination in any combination without conflict, and this application is not limited thereto.
[0176] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the operation of the method corresponding to any embodiment of the chip internal clock calibration method provided in the above embodiments can be implemented.
[0177] An embodiment of the present application also provides a computer program product, which includes a computer program, wherein when the computer program is executed by a processor, it can implement the operations corresponding to the method of any embodiment of the chip internal clock calibration method provided in the above embodiments.
[0178] like Figure 5 As shown, some embodiments of the present application provide an electronic device 500, which includes: a memory 510, a processor 520, and a computer program stored in the memory 510 and executable on the processor 520, wherein the processor 520 can implement any embodiment of the method for calibrating the internal clock of the chip as described above when reading the program from the memory 510 through a bus 530 and executing the program.
[0179] Processor 520 can process digital signals and can include various computing structures, such as complex instruction set computer structure, reduced instruction set computer structure, or a structure that implements a combination of multiple instruction sets. In some examples, processor 520 can be a microprocessor.
[0180] The memory 510 may be used to store instructions executed by the processor 520 or data related to the execution of instructions. These instructions and / or data may include codes for implementing some or all functions of one or more modules described in the embodiments of the present application. The processor 520 of the disclosed embodiment may be used to execute instructions in the memory 510 to implement the method shown above. The memory 510 includes a dynamic random access memory, a static random access memory, a flash memory, an optical memory, or other memory known to those skilled in the art.
[0181] The above are only embodiments of the present application and are not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0182] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0183] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for calibrating a chip internal clock, characterized in that: The method comprises: Receive data frames sent by the host device; Parsing the data frame to obtain a first edge time at a preset position in the data frame; Determine an edge time comparison result according to the first edge time and the preset edge time; Calibrate the clock set by the slave according to the edge time comparison result; in: The step of parsing the data frame to obtain a first edge time at a preset position in the data frame includes: Parsing the data frame to obtain calibration information of the data frame; Determining, according to the calibration information of the data frame, a holding time of a preset level corresponding to the calibration information; Determining the first edge time according to the holding time of the preset level; The step of calibrating the clock set by the slave according to the edge time comparison result includes: If the first edge time is greater than the preset edge time, determining a first edge time difference according to the first edge time and the preset edge time; Determining a first calibration value according to the first edge time difference and a preset clock frequency; Calibrate the clock set by the slave according to the first calibration value; If the first edge time is less than the preset edge time, determining a second edge time difference according to the first edge time and the preset edge time; Determining a second calibration value according to the second edge time difference and a preset clock frequency; The clock set by the slave is calibrated according to the second calibration value.
2. The method for calibrating the internal clock of a chip according to claim 1, characterized in that: The determining the edge time comparison result according to the first edge time and the preset edge time includes: If the first edge time is greater than the preset edge time, determining that the clock of the internal clock of the slave device is less than a preset value; If the first edge time is less than the preset edge time, it is determined that the clock of the internal clock of the slave device is greater than a preset value.
3. The method for calibrating the internal clock of a chip according to claim 1, characterized in that: The method further comprises: Determining a third calibration value according to the first calibration value and the preset clock frequency; If the third calibration value satisfies the preset calibration range, the clock set by the slave is calibrated.
4. A device for calibrating a chip internal clock, characterized in that: The device comprises: A receiving module, used for receiving data frames sent by a host device; A parsing module, used for parsing the data frame to obtain a first edge time at a preset position in the data frame; A determination module, configured to determine an edge time comparison result according to the first edge time and a preset edge time; A calibration module is used to calibrate the clock set by the slave according to the edge time comparison result; wherein: The parsing module is used to: Parsing the data frame to obtain calibration information of the data frame; Determining, according to the calibration information of the data frame, a holding time of a preset level corresponding to the calibration information; Determining the first edge time according to the holding time of the preset level; The calibration module is used for: If the first edge time is greater than the preset edge time, determining a first edge time difference according to the first edge time and the preset edge time; Determining a first calibration value according to the first edge time difference and a preset clock frequency; Calibrate the clock set by the slave according to the first calibration value; The calibration module is used for: If the first edge time is less than the preset edge time, determining a second edge time difference according to the first edge time and the preset edge time; Determining a second calibration value according to the second edge time difference and a preset clock frequency; The clock set by the slave is calibrated according to the second calibration value.
5. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor can implement the chip internal clock calibration method as claimed in any one of claims 1 to 3 when executing the program.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the program, when executed by a processor, can implement the chip internal clock calibration method described in any one of claims 1 to 3.
Citation Information
Patent Citations
Method and system for calibrating clock skew inside chip
CN102830748A
Method for correcting original oscillation frequency clock of chip
CN103868416A
Motion control system and method, clock synchronization method and medium
CN108983692A
Clock frequency calibration and frequency measurement method for UART serial port master-slave communication
CN112099568A
Clock precision correction method and device and storage medium
CN112540641A
