Clock switching method and apparatus, electronic device, and readable storage medium

By determining the average control word and compensating for the phase difference in a wireless communication system, the problems of chip resource waste and phase error caused by different clock switching are solved, achieving accuracy and seamlessness in clock switching and reducing frequency jitter and storage resource waste.

CN115580298BActive Publication Date: 2026-11-20SANECHIPS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110685669.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-21
Publication Date
2026-11-20
Estimated Expiration
2041-06-21

AI Technical Summary

Technical Problem

In wireless communication systems, switching between different clocks leads to wasted chip resources and errors in phase compensation data. Existing technologies struggle to effectively control frequency jitter and accuracy during clock switching.

Method used

By determining that the first reference clock is in a locked state, the average control word is determined according to the preset duration and frequency tuning word, and in the invalid state, it is used as the frequency control word of the digital phase-locked loop to calculate the compensation phase difference, thereby realizing phase compensation for the second reference clock and finally seamlessly switching to the updated second reference clock.

Benefits of technology

It reduces reference clock jitter, saves chip storage resources, ensures accurate and seamless clock switching, and simplifies the implementation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115580298B_ABST
    Figure CN115580298B_ABST
Patent Text Reader

Abstract

The application provides a clock switching method and device, electronic equipment and a readable storage medium. The method comprises the following steps: in the case that the first reference clock is in a locked state, determining an average control word according to a preset time length and an actual frequency tuning word obtained; in the case that the first reference clock is in an invalid state, taking the average control word as a frequency control word of a digital phase-locked loop, and determining a compensation phase difference; performing phase compensation on a second reference clock according to the compensation phase difference to obtain an updated second reference clock; and switching the first reference clock to the updated second reference clock. By taking the average control word as the frequency control word of the digital phase-locked loop, the jitter of the reference clock can be reduced, and the compensation phase difference obtained is more accurate; the compensation phase difference does not need to be stored, thereby saving the storage resources of the chip; and the phase-shifting function of the clock is realized by using a digital circuit, thereby ensuring the accuracy of the updated second reference clock.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, specifically to a clock switching method, apparatus, electronic device, and readable storage medium. Background Technology

[0002] With the development of wireless communication systems, the number of channels in baseband and radio frequency devices is increasing, which in turn places greater demands on the operating clock of each channel. To effectively control the power consumption and performance of wireless communication systems, these systems typically adjust their operating clocks according to different applications. For example, wireless communication systems frequently switch between two different clocks to ensure the accuracy of the operating clock.

[0003] However, switching between different clocks requires too much chip resources, which can easily lead to a waste of chip resources. Furthermore, the existing technology that uses analog circuits to compensate for the phase between different clocks is not only difficult to implement, but also prone to errors in the operating clock due to incorrect phase compensation data. Summary of the Invention

[0004] This application provides a clock switching method, apparatus, electronic device, and readable storage medium.

[0005] This application provides a clock switching method, which includes: when a first reference clock is determined to be in a locked state, determining an average control word based on a preset duration and the actual frequency tuning word obtained; when the first reference clock is determined to be in an invalid state, using the average control word as the frequency control word of a digital phase-locked loop to determine a compensation phase difference; performing phase compensation on a second reference clock based on the compensation phase difference to obtain an updated second reference clock; and switching the first reference clock to the updated second reference clock.

[0006] This application provides a clock switching device, including: a control word determination module configured to determine an average control word based on a preset duration and an acquired actual frequency tuning word when a first reference clock is determined to be in a locked state; a compensation phase determination module configured to determine a compensation phase difference by using the average control word as the frequency control word of a digital phase-locked loop when the first reference clock is determined to be in an invalid state; a phase compensation module configured to perform phase compensation on a second reference clock based on the compensation phase difference to obtain an updated second reference clock; and a switching module configured to switch the first reference clock to the updated second reference clock.

[0007] This application provides an electronic device, including: one or more processors; and a memory storing one or more programs thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any clock switching method in this application.

[0008] This application provides a readable storage medium storing a computer program that, when executed by a processor, implements any of the clock switching methods described in this application.

[0009] According to the clock switching method, apparatus, electronic device, and readable storage medium of this application embodiments, by determining an average control word based on a preset duration and the actual frequency tuning word when the first reference clock is determined to be in a locked state, the damped oscillation of the frequency cycle of the reference clock during the adjustment process can be reduced, thereby reducing reference clock jitter. When the first reference clock is determined to be in an invalid state, the average control word is used as the frequency control word of the digital phase-locked loop to determine the compensation phase difference, which ensures that the obtained compensation phase difference is more accurate, and there is no need to store the compensation phase difference, saving chip storage resources. The second reference clock is phase-compensated based on the compensation phase difference to obtain an updated second reference clock. This updated second reference clock is the reference clock used by the digital phase-locked loop after clock switching. The phase shift function of the clock is implemented using digital circuits, which is simple to implement and can ensure the accuracy of the updated second reference clock, so that the first reference clock can be seamlessly switched to the updated second reference clock.

[0010] Further details regarding the above embodiments and other aspects of this application, as well as their implementations, are provided in the accompanying drawings, detailed description, and claims. Attached Figure Description

[0011] Figure 1 This diagram illustrates the structural composition of a conventional digital phase-locked loop in an embodiment of this application.

[0012] Figure 2 The diagram shows a flowchart of a clock switching method according to an embodiment of this application.

[0013] Figure 3 A flowchart illustrating a clock switching method in yet another embodiment of this application is shown.

[0014] Figure 4 A schematic diagram of the composition structure of the clock switching device in an embodiment of this application is shown.

[0015] Figure 5 This diagram illustrates the composition of the digital phase-locked loop in the seamless switching of an embodiment of this application.

[0016] Figure 6 This diagram illustrates the composition of the phase detection module of the digital phase-locked loop in seamless switching in an embodiment of this application.

[0017] Figure 7 This diagram illustrates the state transition of the control module during seamless switching in an embodiment of this application.

[0018] Figure 8 This diagram illustrates the seamless switching effect between reference clocks of the same frequency in an embodiment of this application.

[0019] Figure 9 This diagram illustrates the seamless switching between frequency multiplication reference clocks in the embodiments of this application.

[0020] Figure 10 A structural diagram of an exemplary hardware architecture of a computing device capable of implementing the clock switching method and apparatus according to embodiments of the present invention is shown. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in detail below with reference to the accompanying drawings. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be arbitrarily combined with each other.

[0022] To ensure the reliability of communication systems and prevent performance degradation due to reference clock failure or frequency drift, two or more reference clocks are required as backup clocks. The communication system can switch between reference clocks according to actual needs, as well as the priority and reliability of each backup reference clock, to ensure that the bit error rate of the service links in the communication system remains within a preset range. Furthermore, in telecommunications networks, timing applications and Ethernet synchronization scenarios require the clock generator's output clock to track the input reference clock with high precision.

[0023] Therefore, the clock generation chip needs to have the function of automatically selecting a suitable input reference clock to ensure that the switching between primary and backup operating clocks in the communication system is as smooth as possible, thereby avoiding transient jumps in the operating clock caused by clock switching. At the same time, the clock generation chip also needs to meet the clock jitter requirements under various operating modes.

[0024] Figure 1 This diagram illustrates the structural composition of a conventional digital phase-locked loop (PLL) in an embodiment of this application. Figure 1As shown, the digital phase-locked loop includes the following modules: a first phase detection module 101, a second phase detection module 102, a phase error calculation module 103, a phase shift module 104, a loop filter 105, a control word generation module 106, a digitally controlled oscillator 107, and a multi-mode frequency divider 108.

[0025] The first phase detection module 101 is used to measure the reference clock f. ref The first phase and second phase detection module 102 are used to measure the feedback clock f. fb The second phase is then input into the phase error calculation module 103 to determine the reference clock f. ref and feedback clock f fb The phase difference. Then, through a closed-loop feedback mechanism, the feedback clock f is made... fb The second phase and the reference clock f ref The first phase alignment is then performed. The control word generation module 106 then controls the numerically controlled oscillator 107 to maintain the phase between the input and output clocks of the digital phase-locked loop in a tracking-locked state. The phase shift module 104 is used to adjust the phase difference between the feedback clock and the reference clock, making the phase of the clock output by the numerically controlled oscillator 107 adjustable.

[0026] use Figure 1 The digital phase-locked loop shown requires a phase measurement module for each reference clock, and also requires a storage module to store the measured first or second phase, and a central processing unit (CPU) to calculate the phase difference between the first and second phases, resulting in a waste of chip resources. In addition, each reference clock is required to have a phase shifting module 104. If the function of the phase shifting module 104 is implemented using analog circuits (e.g., using an analog phase-locked loop (APLL)), it is not only difficult to implement, but also prone to errors in the operating clock due to phase compensation data errors.

[0027] Figure 2 This diagram illustrates a clock switching method according to an embodiment of the present application. This clock switching method can be applied to a clock switching device, which can be configured in a seamlessly switching digital phase-locked loop. Figure 2 As shown, the clock switching method in this application embodiment may include the following steps.

[0028] Step S201: When it is determined that the first reference clock is in a locked state, the average control word is determined based on the preset duration and the actual frequency tuning word obtained.

[0029] The Frequency Tuning Word (FTW) is a control word used to adjust the frequency of an oscillating circuit so that it resonates with another oscillating circuit. During the adjustment process, the frequency corresponding to the reference clock will experience damped oscillations. The average control word obtained through long-term statistical analysis can reduce the occurrence of these damped oscillations.

[0030] It should be noted that the stability of the average control word is directly proportional to the preset duration. For example, the longer the preset duration (e.g., 200ns or 300ns), the better the stability of the average control word.

[0031] In some specific implementations, the average control word is determined based on a preset duration and the actual frequency tuning words obtained, including: obtaining multiple actual frequency tuning words within a preset duration range; and performing a long-term averaging operation on the multiple actual frequency tuning words based on the preset duration to obtain the average control word.

[0032] Each moment corresponds to an actual frequency tuning word. By performing a long-term averaging operation on multiple actual frequency tuning words (for example, summing and averaging multiple actual frequency tuning words), an average control word is obtained, which can ensure the accuracy and stability of the average control word.

[0033] In step S202, if it is determined that the first reference clock is invalid, the average control word is used as the frequency control word of the digital phase-locked loop to determine the compensation phase difference.

[0034] The input signal of a digital phase-locked loop (PLL) is a digital signal converted from an analog device (e.g., a time-to-digital converter). The output signal of the PLL can be a periodic pulse sequence, the period of which is adjustable and controlled by the output signal of a digital filter.

[0035] By using the average control word as the frequency control word of the digital phase-locked loop, the damped oscillation of the frequency cycle of the reference clock during the adjustment process can be reduced, thereby reducing the jitter of the output clock. Furthermore, the compensated phase difference obtained based on this average control word can be more accurate.

[0036] Step S203: Perform phase compensation on the second reference clock based on the compensated phase difference to obtain the updated second reference clock.

[0037] Phase compensation is based on a second reference clock. The phase of the second reference clock is increased or decreased using the compensated phase difference to make the updated second reference clock more accurate.

[0038] It should be noted that, because there is a phase difference between the second reference clock and the first reference clock, in order to make the second reference clock more accurate, it is necessary to perform phase compensation on the second parameter clock according to the phase difference compensation, so that the updated second parameter clock is phase aligned with the first reference clock.

[0039] Step S204: Switch the first reference clock to the updated second reference clock.

[0040] Since the first reference clock is invalid and can no longer be used as the working clock, the above steps seamlessly switch the first reference clock to the updated second reference clock so that the updated second reference clock can take over from the first reference clock and serve as the working clock, thus ensuring the stability of the communication system's working clock.

[0041] In this embodiment, by determining the average control word based on a preset duration and the actual frequency tuning word when the first reference clock is in a locked state, the damped oscillation of the frequency cycle during the adjustment process of the reference clock can be reduced, thereby reducing reference clock jitter. When the first reference clock is in an invalid state, the average control word is used as the frequency control word of the digital phase-locked loop to determine the compensation phase difference, which ensures that the obtained compensation phase difference is more accurate, and there is no need to store the compensation phase difference, saving chip storage resources. The second reference clock is phase-compensated based on the compensation phase difference to obtain an updated second reference clock. This updated second reference clock is the reference clock used by the digital phase-locked loop after clock switching. The phase shift function of the clock is implemented using digital circuits, which is simple to implement and can ensure the accuracy of the updated second reference clock, so that the first reference clock can be seamlessly switched to the updated second reference clock.

[0042] Figure 3 This diagram illustrates a clock switching method according to another embodiment of the present application. This clock switching method can be applied to a clock switching device, which can be configured in a seamlessly switching digital phase-locked loop. For example... Figure 3 As shown, the clock switching method in this application embodiment may include the following steps.

[0043] Step S301: When it is determined that the first reference clock is in a locked state, the average control word is determined based on the preset duration and the actual frequency tuning word obtained.

[0044] Step S301 in this embodiment is the same as step S201 in the previous embodiment, and will not be described again here.

[0045] Step S302: If it is determined that the first reference clock is invalid, the digital phase-locked loop is set to an open-loop state.

[0046] It should be noted that when the first reference clock is determined to be invalid, the clock output by the digital phase-locked loop is incorrect. In order to avoid communication chaos caused by the use of an incorrect working clock, the digital phase-locked loop needs to be set to an open-loop state so that the first reference clock can temporarily stop working and the calculation of the average control word can be stopped. Step S303 is then executed to ensure that the output frequency of the digital oscillator is stable.

[0047] Step S303: Use the average control word as the frequency control word of the digital phase-locked loop.

[0048] The frequency control word of the digital phase-locked loop (PLL) is used to control the PLL, enabling it to output different clock frequencies.

[0049] Using the average control word as the frequency control word of the digital phase-locked loop enables different reference clocks to be synchronized to the same starting point, facilitating further calculation of the frequency of each reference clock, reducing the damped oscillation of the frequency cycle during the adjustment process of the reference clock, and thus reducing the jitter of the output clock.

[0050] Step S304: Determine the switching frequency division ratio based on the relationship between the frequency of the second reference clock and the frequency of the first reference clock.

[0051] The frequency of the second reference clock can be the same as or different from that of the first reference clock (for example, the frequency of the second reference clock is an integer multiple of the frequency of the first reference clock). When the desired output frequency remains unchanged, the frequency division ratio is switched to be inversely proportional to the frequency of the reference clock, making clock adjustment easier to achieve and reducing power loss.

[0052] Step S305: Based on the switching frequency division ratio and the second reference clock, perform open-loop measurement on the digital phase-locked loop to obtain the compensated phase difference.

[0053] The second reference clock is a newly added reference clock. However, since there is a gap between the second reference clock and the first reference clock (for example, there is a phase difference between the two clocks or the two clocks have different frequencies), it is necessary to perform open-loop measurement on the digital phase-locked loop based on the switching division ratio and the second reference clock to obtain the compensated phase difference. This compensated phase difference is used to compensate the second reference clock so that the compensated second reference clock is more suitable for the communication system.

[0054] Step S306: Perform phase compensation on the second reference clock based on the compensated phase difference to obtain the updated second reference clock.

[0055] Step S307: Switch the first reference clock to the updated second reference clock.

[0056] It should be noted that steps S306 to S307 in this embodiment are the same as steps S203 to S204 in the previous embodiment, and will not be described again here.

[0057] In this embodiment, when the first reference clock is determined to be invalid, the digital phase-locked loop (PLL) is set to an open-loop state, allowing the first reference clock to temporarily stop operating and preventing communication disruptions caused by using an incorrect operating clock. The average control word is used as the frequency control word of the PLL to reduce damped oscillations of the frequency cycle during the reference clock adjustment process, thereby reducing reference clock jitter. Based on the relationship between the frequencies of the second and first reference clocks, a switching division ratio is determined, making clock adjustment easier and reducing power loss. Based on the switching division ratio and the second reference clock, an open-loop measurement is performed on the PLL to obtain a compensated phase difference. This compensated phase difference is then used to compensate the phase of the second reference clock, resulting in an updated second reference clock. This ensures the accuracy of the updated second reference clock, allowing the first reference clock to seamlessly switch to the updated second reference clock.

[0058] In some specific implementations, open-loop measurements are performed on the digital phase-locked loop (PLL) based on the switching division ratio and the second reference clock to obtain the compensated phase difference. This includes: dividing the second reference clock according to the switching division ratio to obtain the feedback clock of the loop to be switched; synchronizing and processing the second reference clock and the feedback clock of the loop to be switched to obtain a reference phase difference; obtaining the loop phase error corresponding to the first reference clock, where the loop phase error corresponding to the first reference clock is the phase difference between the first reference clock and the feedback clock of the PLL before clock switching; and determining the compensated phase difference based on the loop phase error and the reference phase difference.

[0059] The feedback clock of the loop to be switched is the feedback clock in the loop determined after the second reference clock is connected to the digital phase-locked loop.

[0060] By synchronizing the second reference clock and the feedback clock of the loop to be switched, and calculating the difference between the second reference clock and the feedback clock of the loop to be switched, a reference phase difference can be obtained. This reference phase difference reflects the degree of influence of the second reference clock on the phase in the digital phase-locked loop. The loop phase error corresponding to the first reference clock is the phase difference between the first reference clock and the feedback clock of the digital phase-locked loop before clock switching. It reflects the degree of influence of the first reference clock on the phase in the digital phase-locked loop. Through the loop phase error and the reference phase difference, the difference between the first reference clock and the second reference clock can be comprehensively determined. That is, if the first reference clock is switched to the second reference clock, how much difference value needs to be compensated (e.g., phase difference compensation) to ensure a seamless switch from the first reference clock to the compensated reference clock and to avoid output clock jitter and reduce the impact on the communication system.

[0061] In some specific implementations, the compensation phase difference is determined based on the loop phase error and the reference phase difference, including: when the reference phase difference is determined to be stable, performing a difference calculation on the reference phase difference and the loop phase error to obtain the compensation phase difference.

[0062] It should be noted that the calculation of the reference phase difference requires a period of stabilization before the stabilized reference phase difference can accurately reflect the influence of the second reference clock on the phase in the digital phase-locked loop, ensuring the accuracy of the difference between the reference phase difference and the loop phase error, thereby ensuring the accuracy of the compensated phase difference.

[0063] In some specific implementations, the switching division ratio is determined based on the relationship between the frequency of the second reference clock and the first reference clock. This includes: when the frequency corresponding to the first reference clock and the frequency corresponding to the second reference clock are the same, determining the switching division ratio based on the frequency corresponding to the second reference clock; when the frequency corresponding to the first reference clock and the frequency corresponding to the second reference clock are multiples of each other, obtaining the multiple between the frequency corresponding to the first reference clock and the frequency corresponding to the second reference clock, and determining the switching division ratio based on the multiple and the frequency corresponding to the second reference clock.

[0064] When the frequencies corresponding to the first and second reference clocks are determined to be the same, the switching division ratio can be determined based on actual testing needs and the frequency corresponding to the second reference clock. For example, if the frequency corresponding to the second reference clock is 10MHz, and during the simulation, in order to lock the frequency of the digital phase-locked loop's output clock at 8.0125GHz, the switching division ratio can be set to 8.0125GHz / 10MHz = 801.25, that is, setting the integer division ratio to 801 and the fractional division ratio to 0.25, to ensure that the simulation effect better matches the actual requirements.

[0065] When the frequencies corresponding to the first reference clock and the second reference clock are determined to be multiples of each other, for example, the frequency of the first reference clock is 10MHz, and the frequency of the second reference clock is f... ref2 Since the frequency of the second reference clock is twice that of the first reference clock, in order to lock the output clock frequency of the digital phase-locked loop at 8.0125GHz, the frequency division ratio for this switching can be set to 8.0125GHz / 20MHz = 400.625, that is, the integer frequency division ratio is set to 400 and the fractional frequency division ratio is set to 0.625, so as to ensure that the simulation effect is more in line with the actual requirements.

[0066] In some specific implementations, before performing phase compensation on the second reference clock based on the compensated phase difference to obtain the updated second reference clock, the process further includes: obtaining the system clock; and determining the phase corresponding to the second reference clock based on the rising edge of the second reference clock and the system clock.

[0067] The system clock is a high-precision, high-frequency output clock provided by another analog phase-locked loop.

[0068] For example, by obtaining the phase value corresponding to a rising edge of the second reference clock, and then resetting the system clock (e.g., clearing the system clock to zero), the starting phase value of the system clock after resetting is obtained. Then, the difference between the phase value corresponding to a rising edge of the second reference clock and the starting phase value of the system clock after resetting is calculated, the phase of the second reference clock relative to the system clock can be accurately obtained, that is, the phase value corresponding to the second reference clock.

[0069] By relying on the rising edge of the second reference clock and the system clock, the accuracy of the phase value corresponding to the obtained second reference clock can be guaranteed, avoiding the difference in phase between different reference clocks.

[0070] In some specific implementations, phase compensation is performed on the second reference clock based on the compensated phase difference to obtain the updated second reference clock, including: performing a difference operation on the phase corresponding to the second reference clock and the compensated phase difference to determine the updated second reference clock.

[0071] By performing a difference calculation on the phase corresponding to the second reference clock and the compensated phase difference, the specific phase difference that the second reference clock needs to be adjusted can be determined, so that the updated second reference clock is more accurate and more suitable for communication systems.

[0072] In some specific implementations, before determining the average control word based on a preset duration and the actual frequency tuning word obtained when the first reference clock is determined to be in a locked state, the method further includes: detecting the first reference clock and obtaining a detection result, the detection result including the period of the first reference clock; determining the state of the first reference clock based on the period of the first reference clock and a preset period threshold, the state of the first reference clock including an active state or an inactive state.

[0073] The detection is based on the system clock, whose frequency is higher than that of the reference clock (e.g., the system clock frequency is 10 times that of the reference clock). Within one or more reference clock cycles, the reference clock is counted. If the count value is within a preset threshold (e.g., a preset cycle threshold), the reference clock is considered valid; otherwise, it is considered invalid. The preset cycle threshold can be a counting range, for example, starting from 1 and counting up to 10.

[0074] By detecting the period of the first reference clock, the state of the first reference clock can be determined, ensuring that if a problem occurs with the first reference clock, it can be dealt with in a timely manner (e.g., clock switching), so as to ensure the effectiveness of the working clock of the communication system.

[0075] In some specific implementations, after determining the state of the first reference clock based on its period and a preset period threshold, the method further includes: if the first reference clock is determined to be in a valid state, detecting whether the first reference clock is in a locked state.

[0076] When the first reference clock is in an active state, it is also necessary to detect whether the first reference clock is in a locked state. If the first reference clock is in a locked state, it means that the first reference clock is used as the working clock of the communication system. If the first reference clock is in an unlocked state, it means that the first reference clock has not yet been used as the working clock of the communication system.

[0077] By further detecting the first reference clock, it is determined whether the first reference clock is in a locked state, so as to determine whether the first reference clock is used as the working clock of the communication system, thereby determining the current state of the first reference clock, which facilitates subsequent processing of the first reference clock.

[0078] In some specific implementations, detecting whether the first reference clock is in a locked state includes: performing phase synchronization and processing on the first reference clock and the feedback clock corresponding to the digital phase-locked loop before clock switching to obtain the loop phase error corresponding to the first reference clock; obtaining the transition speed of the loop phase error corresponding to the first reference clock; if the transition speed of the loop phase error is determined to be within the range of a preset speed threshold, the first reference clock is determined to be in a locked state; otherwise, the first reference clock is determined to be in an unlocked state.

[0079] The jump rate of the loop phase error reflects the oscillation in the loop. When the oscillation in the loop tends to stabilize, that is, when the jump rate of the loop phase error is within a preset speed threshold (e.g., the jump size per clock cycle, such as 0.001 degrees per clock cycle), the first reference clock can be determined to be in a locked state.

[0080] By detecting whether the jump rate of the loop phase error is within the range of the preset speed threshold, the oscillation situation in the loop is reflected, thereby determining whether the first reference clock is in a locked state, which facilitates further processing of the first reference clock.

[0081] In some specific implementations, after switching the first reference clock to the updated second reference clock, the following steps are also included: setting the digital phase-locked loop to a closed-loop state; and using the actual frequency tuning word as the frequency control word of the digital phase-locked loop.

[0082] After switching the first reference clock to the updated second reference clock, the digital phase-locked loop (PLL) needs to be set to a closed-loop state so that the updated second reference clock can be output as the operating clock of the communication system, ensuring its normal operation. Using the actual frequency tuning word as the frequency control word of the PLL facilitates the processing of the updated second reference clock in the next cycle, enabling the PLL to operate cyclically and automatically detect and switch the operating clock of the communication system, ensuring its validity and thus improving the efficiency of the communication system.

[0083] In some specific implementations, before determining the average control word based on a preset duration and the actual frequency tuning word obtained, after determining that the first reference clock is in a locked state, the process further includes: obtaining multiple reference clocks and their priorities; filtering the multiple reference clocks according to their priorities to obtain the first reference clock, where the first reference clock has a higher priority than the other reference clocks.

[0084] The digital phase-locked loop can acquire multiple reference clocks simultaneously, but it does not process each reference clock. Instead, it sorts the multiple reference clocks according to their priorities and selects the reference clock with the highest priority as the first reference clock. This ensures that the reference clock with the highest priority is processed first, thus guaranteeing the validity of the reference clock.

[0085] The clock switching device according to an embodiment of the present invention will now be described in detail with reference to the accompanying drawings. Figure 4 A schematic diagram of the composition structure of the clock switching device in an embodiment of this application is shown. Figure 4 As shown, the clock switching device may include the following modules.

[0086] The control word determination module 401 is configured to determine an average control word based on a preset duration and the actual frequency tuning word obtained when the first reference clock is determined to be in a locked state; the compensation phase determination module 402 is configured to determine a compensation phase difference by using the average control word as the frequency control word of the digital phase-locked loop when the first reference clock is determined to be in an invalid state; the phase compensation module 403 is configured to perform phase compensation on the second reference clock based on the compensation phase difference to obtain an updated second reference clock; and the switching module 404 is configured to switch the first reference clock to the updated second reference clock.

[0087] In this embodiment, when the control word determination module determines that the first reference clock is in a locked state, it determines the average control word based on a preset duration and the actual frequency tuning word obtained. This reduces the damped oscillation of the frequency cycle during the adjustment process of the reference clock, thereby reducing reference clock jitter. When the compensation phase determination module determines that the first reference clock is in an invalid state, it uses the average control word as the frequency control word of the digital phase-locked loop to determine the compensation phase difference. This ensures that the obtained compensation phase difference is more accurate, and there is no need to store the compensation phase difference, saving chip storage resources. The phase compensation module performs phase compensation on the second reference clock based on the compensation phase difference to obtain an updated second reference clock. This updated second reference clock is the reference clock used by the digital phase-locked loop after clock switching. The phase shift function of the clock is implemented using digital circuits, which is simple to implement and can ensure the accuracy of the updated second reference clock, allowing the first reference clock to seamlessly switch to the updated second reference clock.

[0088] Figure 5 This diagram illustrates the composition of the digital phase-locked loop (PLL) in a seamless switching embodiment of this application. For example... Figure 5 As shown, the digital phase-locked loop in seamless switching includes the following modules:

[0089] The module includes a reference switching module 501, a first phase detection module 502, a second phase detection module 503, a phase error (PHE) calculation module 504, a phase compensation module 505, an infinite impulse response (IIR) filter 506, a loop switch 507, a proportional-integral (PI) filter 508, a first control word selection module 509, a long-term averaging calculation unit 510, a control module 511, a lock detection module 512, a second control word selection module 513, a numerically controlled oscillator 514, and a multi-mode frequency divider 515.

[0090] The reference switching module 501 is used to select one of two or more input reference clocks to input to the first phase detection module 502 and obtain the control signal from the control module 511.

[0091] The first phase detection module 502 is used to measure the first reference clock f. ref1 The first output phase relative to the system clock fs; the second phase detection module 503 is used to measure the feedback clock f. fb The second output phase relative to the system clock fs.

[0092] The system clock can be an externally acquired reference clock, such as a high-precision, high-frequency output clock provided by another analog phase-locked loop, which can be used as the reference clock.

[0093] Figure 6 This diagram illustrates the structural composition of the phase detection module of the digital phase-locked loop in seamless switching, as shown in an embodiment of this application. Figure 6 As shown, either the first phase detection module 502 or the second phase detection module 503 may include a time-to-digital converter 601 and a digital decoding module 602.

[0094] The time-to-digital converter 601 is used to convert the input reference clock or system clock from time to digital, that is, to convert the input time information into digital information. The digital decoding module 602 is used to decode the digital information output by the time-to-digital converter 601.

[0095] For example, the digital decoding module 602 counts the digital information output by the time-to-digital converter 601 corresponding to the system clock, and counts the phase of the rising edge of each reference clock relative to the starting point after de-reset relative to the system clock. The digital decoding module 602 can also be used to calculate the phase of the rising edge of each feedback clock relative to the starting point after de-reset relative to the system clock. De-reset involves clearing the system clock to avoid confusion between system clocks at different times.

[0096] Phase error calculation module 504 is used to calculate the first reference clock f output by the first phase detection module 502. ref1 The feedback clock output by the second phase detection module 503 is synchronized with the first output phase relative to the system clock fs, and the difference between the first and second output phases is calculated to obtain the loop phase error corresponding to the first reference clock. By synchronizing the first and second output phases, the calculated loop phase error can be ensured to be more accurate.

[0097] Determine the first reference clock f ref1 In the invalid state, the digital phase-locked loop (PLL) is in an open-loop state. The feedback clock input to the second phase detection module 503 is the feedback clock corresponding to the PLL before the clock switching, and the loop phase error corresponding to the first reference clock is the first reference clock f. ref1 The phase difference between the feedback clock and the digital phase-locked loop before the clock switch.

[0098] It should be noted that since the first output phase output by the first phase detection module 502 and the second output phase output by the second phase detection module 503 are both calculated relative to the system clock fs, the difference between the first output phase and the second output phase is the first reference clock fs. ref1 The phase difference between the feedback clock and the digital phase-locked loop before the clock switch.

[0099] Phase compensation module 505 is used to adjust the second reference clock f during seamless clock switching. ref2 Perform phase compensation.

[0100] For example, when switching to the second reference clock f ref2 Then, the second reference clock f is compared with the frequency division ratio by the multi-mode divider 515. ref2 Frequency division is performed to obtain the feedback clock of the loop to be switched; then, the feedback clock of the loop to be switched is output to the second phase detection module 503, so that the second phase detection module 503 adjusts the second reference clock f. ref2 The feedback clock of the loop to be switched is synchronized with the phase of the loop and the difference is calculated to obtain the reference phase difference. Then, the reference phase difference is compared with the loop phase error corresponding to the first reference clock to obtain the compensation phase difference. This compensation phase difference can be used to adjust the second reference clock f. ref2 Phase compensation is performed to ensure that the updated second reference clock is more accurate, making the first reference clock f... ref1 It can seamlessly switch to the updated second reference clock.

[0101] Loop switch 507 is used to determine the first reference clock f ref1 In an invalid state, disconnect the loop; determine the first reference clock f. ref1 When locked, or, switch to the second reference clock f ref2 And the second reference clock f ref2 When in a locked state, the loop is closed.

[0102] When it is determined that the loop switch 507 is closed, that is, when the digital phase-locked loop is in a closed-loop state, the loop filter of the digital phase-locked loop can be obtained by cascading the IIR filter 506 and the PI filter 508.

[0103] The IIR filter 506 is used to filter the input phase difference. The PI filter 508 is used to adjust the loop bandwidth of the digital phase-locked loop according to its parameter configuration.

[0104] Even when the loop switch 507 is open, i.e., when the digital phase-locked loop is in an open-loop state, the IIR filter 506 can still be reused as a phase difference filter. However, in this case, the historical data in the IIR filter 506 needs to be cleared first, and then the IIR filter 506 needs to be restarted to make the phase difference output by the IIR filter 506 more stable. Then, the phase difference output by the IIR filter 506 is input to the phase compensation module 505 to make the compensated phase difference calculated by the phase compensation module 505 more accurate.

[0105] The first control word selection module 509 is used to determine the first reference clock f. ref1 In the invalid state, the average control word output by the long-term averaging calculation unit 510 is selected as the actual control word of the digital phase-locked loop; when determining the first reference clock f ref1 When in a locked state, the actual frequency tuning word is selected as the actual control word of the digital phase-locked loop.

[0106] Long-term averaging calculation unit 510 is used to determine the first reference clock f ref1 When the device is locked, the acquired actual frequency tuning words are summed and averaged over a long period of time to obtain the average control word.

[0107] For example, multiple actual frequency tuning words within a preset duration (e.g., 10 seconds or 20 seconds) can be acquired. Then, these multiple actual frequency tuning words are summed and averaged over a long period according to the preset duration to obtain an average control word. The stability of this average control word is directly proportional to the preset duration; that is, the longer the preset duration, the more stable the obtained average control word. This average control word can be used as a first reference clock f. ref1From the point of failure to the second reference clock f ref2 Open-loop control words that are in a locked state, i.e., open-loop control words in a switching waiting state of a digital phase-locked loop.

[0108] Control module 511 is used to control the state during seamless switching of the reference clock via a state machine, in order to select a suitable reference clock; control module 511 is also used to control loop switch 507, after determining the first reference clock f ref1 In an invalid state, the control loop switch 507 disconnects the loop; when the first reference clock f is determined... ref1 When locked, or, switch to the second reference clock f ref2 And the second reference clock f ref2 When in the locked state, the control loop switch 507 closes the loop. The control module 511 also controls the first control word selection module 509 to select a suitable control word for the digital phase-locked loop. The lock detection module 512 is used to acquire the first reference clock f. ref1 The corresponding loop phase error transition rate; and if the transition rate of the loop phase error is determined to be within a preset speed threshold (e.g., the transition size per clock cycle, such as 0.001 degrees per clock cycle), the first reference clock f is determined. ref1 In a locked state; otherwise, determine the first reference clock f. ref1 In an unlocked state

[0109] The multi-mode divider 515 is used to divide the output clock to obtain the feedback clock. This is done while determining the second reference clock f. ref2 It is the first reference clock f ref1 When the division ratio is an integer multiple of the given value, the division ratio of the multimode divider 515 needs to be switched accordingly.

[0110] For example, obtain the first reference clock f ref1 The corresponding frequency and the second reference clock f ref2 The corresponding frequency multiple (e.g., the second reference clock f) ref2 The corresponding frequency is the first reference clock f. ref1 When the corresponding frequency is twice that of the clock, based on that multiple and the second reference clock f ref2 The corresponding frequency determines the switching division ratio of the multimode divider 515.

[0111] Lock detection module 512 is used to lock the first reference clock f ref1 The indicator of whether it is in a locked state is output to the state machine in the control module 511 to facilitate the state transition of the digital phase-locked loop in the control module 511.

[0112] The seamless switching digital phase-locked loop (PLL) in this embodiment enables seamless switching between reference clocks. When the first reference clock is locked, a long-term averaging operation is performed on multiple actual frequency tuning words within a preset time range to obtain an average control word. This reduces damped oscillations in the frequency cycle of the reference clock during adjustment, resulting in good stability and reduced jitter. When the first reference clock is invalid, the averaging operation stops, the loop is disconnected, and the average control word is used as the frequency control word of the PLL. Then, based on the division ratio determined by the multi-mode divider 515, the second reference clock is divided to obtain the feedback clock for the loop to be switched. A compensation phase difference is then calculated based on this feedback clock and the first reference clock to make the compensation phase difference more accurate. Furthermore, there is no need to store the compensation phase difference, saving chip storage resources and eliminating reliance on an external CPU. Phase compensation is then performed on the second reference clock based on the compensation phase difference to obtain an updated second reference clock. This updated second reference clock is used by the PLL after clock switching, ensuring the PLL returns to a stable state. Because a fully digital phase-locked loop is used to achieve seamless clock switching, it avoids multiple calculations and storage operations on the phases of two reference clocks simultaneously. This simplifies the implementation and ensures the accuracy of the updated second reference clock, allowing the first reference clock to seamlessly switch to the updated second reference clock.

[0113] Figure 7 This diagram illustrates the state transition of the control module during seamless switching in an embodiment of this application. Figure 7 As shown, the state machine of the control module 511 includes the following states: lock-wait state 701, reference lock state 702, open-loop state 703, switch-wait state 704, and closed-loop state 705.

[0114] The control module 511 first selects from the multiple reference clocks based on their priority levels to obtain the reference clock with the highest priority (e.g., the first reference clock f). ref1 Then the first reference clock f ref1 The input is fed into the digital phase-locked loop (PLL), at which point the PLL is in a locked-wait state 701, i.e., waiting for the first reference clock to be locked.

[0115] Determine the first reference clock f ref1 When in the locked state, the digital phase-locked loop enters the reference locked state 702. At this time, the control module 511 controls the loop switch 507 to be closed, and performs a long-term summation and averaging operation on the actual frequency tuning word obtained by the long-time averaging calculation unit 510 to obtain the average control word.

[0116] Determine the first reference clock f ref1 When in an invalid state, the digital phase-locked loop enters open-loop state 703. At this time, the control module 511 controls the loop switch 507 to be in the open state and stops the operation of the long-time averaging calculation unit 510. At the same time, it enables the first control word selection module 509, so that the first control word selection module 509 selects the average control word output by the long-time averaging calculation unit 510 as the control word of the digital phase-locked loop.

[0117] When the digital phase-locked loop (PLL) enters open-loop state 703, the control module 511 controls the IIR filter 506 to clear its historical data and puts the PLL into switching wait state 704. Upon entering switching wait state 704, the PLL waits for a preset time (e.g., configurable as 500ns) to ensure a more accurate loop phase error corresponding to the first reference clock output by the IIR filter 506. Then, the loop phase error corresponding to the first reference clock output by the IIR filter 506 is output to the phase compensation module 505, allowing the phase compensation module 505 to calculate the compensated phase difference and use this compensated phase difference to adjust the second reference clock f. ref2 Phase compensation is performed to obtain an updated second reference clock.

[0118] The control module 511 switches the reference clock of the digital phase-locked loop from the first reference clock to the updated second reference clock, so that the updated second reference clock is locked, thereby entering the locked state 705 of the digital phase-locked loop.

[0119] Determining the second reference clock f ref2 When in a locked state, the historical data in the IIR filter 506 needs to be cleared again, and the loop switch 507 needs to be closed. At the same time, the control word of the digital phase-locked loop is switched to the actual frequency tuning word, and the locked waiting state 701 is re-entered.

[0120] In this embodiment, the state machine of the control module controls the digital phase-locked loop (PLL) to be in different states, so that the various modules of the PLL can work together to ensure that the obtained compensation phase difference is more accurate; and when determining the first reference clock f ref1 In the case of an invalid state, it can automatically switch to the updated second reference clock, so that the reference clock in the digital phase-locked loop is locked again, ensuring a stable output of the reference clock, and is not dependent on an external CPU.

[0121] Figure 8 This diagram illustrates the seamless switching effect between reference clocks at the same frequency in an embodiment of this application. Based on Figure 5The seamless switching digital phase-locked loop shown in the figure, wherein the first reference clock f ref1 The frequency is 10MHz, and the second reference clock is f. ref2 The frequency is 10MHz, the integer division ratio is set to 801, and the fractional division ratio is set to 0.25, which means that the output clock frequency of the seamlessly switching digital phase-locked loop is locked at 801.25*10MHz=8.0125GHz.

[0122] like Figure 8 As shown, when the current state of the seamlessly switching digital phase-locked loop (PLL) is determined to be locked, the waveform output by the PLL exhibits slight oscillations. Using the average control word as the frequency control word for the PLL during clock switching, the waveform output by the PLL remains relatively stable at 8.0125 GHz, without any slight oscillations. This is achieved when the first reference clock f is determined. ref1 When in a locked state, the first reference clock f ref1 The phase difference fluctuates around 0 degrees, while switching to the second reference clock f ref2 After the corresponding updated second reference clock, it enters a switching wait state, during which it needs to wait for a period of time (e.g., 568ns) to ensure that the first reference clock f output by the IIR filter 506 is maintained. ref1 The corresponding loop phase error is more accurate, thus obtaining a more accurate compensated phase difference, and this compensated phase difference is used to adjust the second reference clock f. ref2 Phase compensation is performed to obtain the updated second reference clock; if the updated second reference clock is determined to be in a locked state, then the locked updated second reference clock and the first reference clock f are... ref1 The phase difference between them remains at 180 degrees.

[0123] In this embodiment, by switching between the first and second reference clocks of the same frequency, the compensation phase difference can be accurately calculated, enabling the first reference clock to seamlessly switch to the second reference clock, reducing the damped oscillation of the frequency cycle of the reference clock during the adjustment process, thereby reducing the jitter of the reference clock.

[0124] Figure 9 This diagram illustrates the seamless switching between frequency multiplication reference clocks in an embodiment of this application. Based on Figure 5 The seamless switching digital phase-locked loop shown in the figure, wherein the first reference clock f ref1 The frequency is 10MHz, and the second reference clock is f. ref2 The frequency is 20MHz, due to the second reference clock f ref2 The frequency is the first reference clock f ref1Therefore, based on the preset division ratio of 801.25, the current division ratio can be set to 801.25 / 2 = 400.625. Similarly, the output clock frequency of the seamlessly switching digital phase-locked loop can be locked at 400.625 * 20MHz = 8.0125GHz.

[0125] like Figure 9 As shown, when the current state of the seamlessly switching digital phase-locked loop (PLL) is determined to be locked, the waveform output by the PLL exhibits slight oscillations. Using the average control word as the frequency control word for the PLL during clock switching, the waveform output by the PLL remains relatively stable at 8.0125 GHz, without any slight oscillations. This is achieved when the first reference clock f is determined. ref1 When in a locked state, the first reference clock f ref1 The corresponding loop phase difference fluctuates around 1 degree, while switching to the second reference clock f ref2 Following the corresponding updated second reference clock, the second reference clock f ref2 The corresponding loop phase difference fluctuates around -1 degree, entering a switching wait state. At this time, it is necessary to wait for a period of time (e.g., 8µs) to ensure that the first reference clock f output by the IIR filter 506 is maintained. ref1 The corresponding loop phase error is more accurate, thus obtaining a more accurate compensated phase difference (e.g., 2 degrees), and this compensated phase difference is used to adjust the second reference clock f. ref2 Phase compensation is performed to obtain the updated second reference clock; if the updated second reference clock is determined to be in a locked state, then the locked updated second reference clock and the first reference clock f are... ref1 The phase difference between them is maintained at 2 degrees.

[0126] In this embodiment, by switching between the first and second reference clocks for frequency multiplication, the compensation phase difference can be accurately calculated, enabling the first reference clock to seamlessly switch to the second reference clock, reducing the damped oscillation of the frequency cycle during the adjustment process of the reference clock, thereby reducing the jitter of the reference clock.

[0127] It should be clarified that the present invention is not limited to the specific configurations and processes described in the above embodiments and shown in the figures. For the sake of convenience and brevity, detailed descriptions of known methods are omitted here, and the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, which will not be repeated here.

[0128] Figure 10 A structural diagram of an exemplary hardware architecture of a computing device capable of implementing the clock switching method and apparatus according to embodiments of the present invention is shown.

[0129] like Figure 10 As shown, the computing device 1000 includes an input device 1001, an input interface 1002, a central processing unit 1003, a memory 1004, an output interface 1005, and an output device 1006. The input interface 1002, central processing unit 1003, memory 1004, and output interface 1005 are interconnected via a bus 1007. The input device 1001 and output device 1006 are connected to the bus 1007 via the input interface 1002 and output interface 1005, respectively, and are thus connected to other components of the computing device 1000.

[0130] Specifically, input device 1001 receives input information from the outside and transmits the input information to central processing unit 1003 through input interface 1002; central processing unit 1003 processes the input information based on computer-executable instructions stored in memory 1004 to generate output information, temporarily or permanently stores the output information in memory 1004, and then transmits the output information to output device 1006 through output interface 1005; output device 1006 outputs the output information to the outside of computing device 1000 for user use.

[0131] In one embodiment, Figure 10 The computing device shown can be implemented as an electronic device, which may include: a memory configured to store a program; and a processor configured to run the program stored in the memory to perform the clock switching method described in the above embodiments.

[0132] In one embodiment, Figure 10 The computing device shown can be implemented as a clock switching system, which may include: a memory configured to store a program; and a processor configured to run the program stored in the memory to execute the clock switching method described in the above embodiments.

[0133] The above description is merely an exemplary embodiment of this application and is not intended to limit the scope of protection of this application. Generally, various embodiments of this application can be implemented in hardware or dedicated circuitry, software, logic, or any combination thereof. For example, some aspects can be implemented in hardware, while others can be implemented in firmware or software that can be executed by a controller, microprocessor, or other computing device, although this application is not limited thereto.

[0134] Embodiments of this application can be implemented by executing computer program instructions through the data processor of a mobile device, for example, in a processor entity, or through hardware, or through a combination of software and hardware. The computer program instructions can be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages.

[0135] Any block diagram of logical flow in the accompanying drawings of this application may represent program steps, or may represent interconnected logic circuits, modules, and functions, or may represent a combination of program steps and logic circuits, modules, and functions. The computer program may be stored in memory. The memory may be of any type suitable to the local technical environment and may be implemented using any suitable data storage technology, such as, but not limited to, read-only memory (ROM), random access memory (RAM), optical storage devices and systems (Digital Multifunction Discs, DVDs, or CDs), etc. Computer-readable media may include non-transitory storage media. The data processor may be of any type suitable to the local technical environment, such as, but not limited to, general-purpose computers, special-purpose computers, microprocessors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), programmable logic devices (FGPAs), and processors based on multi-core processor architectures.

[0136] A detailed description of exemplary embodiments of this application has been provided above through exemplary and non-limiting examples. However, various modifications and adjustments to the above embodiments will be apparent to those skilled in the art when considered in conjunction with the accompanying drawings and claims, without departing from the scope of the invention. Therefore, the proper scope of the invention will be determined by the claims.

Claims

1. A clock switching method, characterized in that, The method includes: When it is determined that the first reference clock is in a locked state, the average control word is determined based on the preset duration and the actual frequency tuning word obtained; the first reference clock being in a locked state indicates that the digital phase-locked loop is in a locked state when the first reference clock is used. If the first reference clock is determined to be invalid, the average control word is used as the frequency control word of the digital phase-locked loop to determine the compensation phase difference; The second reference clock is phase-compensated based on the compensated phase difference to obtain an updated second reference clock; Switch the first reference clock to the updated second reference clock; The step of determining the phase difference compensation by using the average control word as the frequency control word of the digital phase-locked loop when the first reference clock is determined to be invalid includes: If it is determined that the first reference clock is invalid, the digital phase-locked loop is set to an open-loop state; The average control word is used as the frequency control word of the digital phase-locked loop; The switching division ratio is determined based on the relationship between the frequency of the second reference clock and the frequency of the first reference clock; Based on the switching frequency division ratio and the second reference clock, an open-loop measurement is performed on the digital phase-locked loop to obtain the compensated phase difference; The step of performing open-loop measurements on the digital phase-locked loop based on the switching frequency division ratio and the second reference clock to obtain the compensated phase difference includes: The second reference clock is divided according to the switching division ratio to obtain the feedback clock of the loop to be switched; The second reference clock and the feedback clock of the loop to be switched are phase synchronized and processed to obtain the reference phase difference; Obtain the loop phase error corresponding to the first reference clock, wherein the loop phase error corresponding to the first reference clock is the phase difference between the first reference clock and the feedback clock corresponding to the digital phase-locked loop before clock switching; The compensated phase difference is determined based on the loop phase error and the reference phase difference.

2. The method according to claim 1, characterized in that, The step of determining the average control word based on a preset duration and the obtained actual frequency tuning word includes: Obtain multiple actual frequency tuning words within a preset duration range; The average control word is obtained by performing a long-term averaging operation on multiple actual frequency tuning words according to the preset duration, and the stability of the average control word is proportional to the preset duration.

3. The method according to claim 1, characterized in that, Determining the compensated phase difference based on the loop phase error and the reference phase difference includes: If the reference phase difference is determined to be stable, the difference between the reference phase difference and the loop phase error is calculated to obtain the compensated phase difference.

4. The method according to claim 1, characterized in that, Determining the switching frequency division ratio based on the relationship between the frequency of the second reference clock and the first reference clock includes: If it is determined that the frequency corresponding to the first reference clock and the frequency corresponding to the second reference clock are the same, the switching frequency division ratio is determined based on the frequency corresponding to the second reference clock. If the frequencies corresponding to the first reference clock and the second reference clock are determined to be multiples of each other, the multiples of the frequencies corresponding to the first reference clock and the second reference clock are obtained, and the switching frequency division ratio is determined based on the multiples and the frequencies corresponding to the second reference clock.

5. The method according to claim 1, characterized in that, Before performing phase compensation on the second reference clock based on the compensated phase difference to obtain the updated second reference clock, the method further includes: Get the system clock; The phase corresponding to the second reference clock is determined based on the rising edge of the second reference clock and the system clock.

6. The method according to claim 5, characterized in that, The step of performing phase compensation on the second reference clock based on the compensated phase difference to obtain the updated second reference clock includes: The updated second reference clock is determined by performing a difference calculation on the phase corresponding to the second reference clock and the compensated phase difference.

7. The method according to claim 1, characterized in that, Before determining the average control word based on a preset duration and the acquired actual frequency tuning word when the first reference clock is determined to be in a locked state, the process further includes: The first reference clock is detected to obtain a detection result, the detection result including the period of the first reference clock; Based on the period of the first reference clock and a preset period threshold, the state of the first reference clock is determined, and the state of the first reference clock includes a valid state or an invalid state.

8. The method according to claim 7, characterized in that, After determining the state of the first reference clock based on its period and a preset period threshold, the method further includes: If it is determined that the first reference clock is in the valid state, it is then detected whether the first reference clock is in a locked state.

9. The method according to claim 8, characterized in that, The step of detecting whether the first reference clock is in a locked state includes: The first reference clock and the feedback clock corresponding to the digital phase-locked loop before clock switching are phase-synchronized and processed to obtain the loop phase error corresponding to the first reference clock. Obtain the transition rate of the loop phase error corresponding to the first reference clock; If the jump rate of the loop phase error is determined to be within a preset speed threshold range, the first reference clock is determined to be in a locked state; otherwise, the first reference clock is determined to be in an unlocked state.

10. The method according to claim 1, characterized in that, After switching the first reference clock to the updated second reference clock, the method further includes: Set the digital phase-locked loop to a closed-loop state; The actual frequency tuning word is used as the frequency control word of the digital phase-locked loop.

11. The method according to claim 1, characterized in that, Before determining the average control word based on a preset duration and the acquired actual frequency tuning word when the first reference clock is determined to be in a locked state, the process further includes: Obtain multiple reference clocks and their priorities; Based on the priority of each of the reference clocks, the plurality of reference clocks are filtered to obtain the first reference clock, wherein the first reference clock has a higher priority than the other reference clocks.

12. A clock switching device, comprising: The control word determination module is configured to determine the average control word based on a preset duration and the actual frequency tuning word obtained when the first reference clock is determined to be in a locked state. The first reference clock is in a locked state, indicating that the digital phase-locked loop is in a locked state when the first reference clock is used; The compensation phase determination module is configured to use the average control word as the frequency control word of the digital phase-locked loop to determine the compensation phase difference when it is determined that the first reference clock is invalid. The phase compensation module is configured to perform phase compensation on the second reference clock based on the compensated phase difference to obtain an updated second reference clock; The switching module is configured to switch the first reference clock to the updated second reference clock; The step of determining the phase difference compensation by using the average control word as the frequency control word of the digital phase-locked loop when the first reference clock is determined to be invalid includes: If it is determined that the first reference clock is invalid, the digital phase-locked loop is set to an open-loop state; The average control word is used as the frequency control word of the digital phase-locked loop; The switching division ratio is determined based on the relationship between the frequency of the second reference clock and the frequency of the first reference clock; Based on the switching frequency division ratio and the second reference clock, an open-loop measurement is performed on the digital phase-locked loop to obtain the compensated phase difference; The step of performing open-loop measurements on the digital phase-locked loop based on the switching frequency division ratio and the second reference clock to obtain the compensated phase difference includes: The second reference clock is divided according to the switching division ratio to obtain the feedback clock of the loop to be switched; The second reference clock and the feedback clock of the loop to be switched are phase synchronized and processed to obtain the reference phase difference; Obtain the loop phase error corresponding to the first reference clock, wherein the loop phase error corresponding to the first reference clock is the phase difference between the first reference clock and the feedback clock corresponding to the digital phase-locked loop before clock switching; The compensated phase difference is determined based on the loop phase error and the reference phase difference.

13. An electronic device, comprising: One or more processors; A memory having stored one or more programs that, when executed by one or more processors, cause the one or more processors to implement the clock switching method as described in any one of claims 1-11.

14. A readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed by a processor, implements the clock switching method as described in any one of claims 1-11.

Citation Information

Patent Citations

  • Synchronous clock generation circuit and clock switch device using the same

    JP2000286702A

  • Hold-over control circuit, and hold-over control method

    JP2017183958A