A clock detection and control circuit

By introducing a clock detection module and a clock control module into the clock detection and control circuit, the loss of the backup clock is detected in real time and an alarm is issued, which solves the problem of failure to monitor the backup clock in the existing technology and improves the working stability of the chip.

CN118393968BActive Publication Date: 2024-09-13HANGZHOU SEMISTRON MICROELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410815391.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-09-13
Estimated Expiration
2044-06-24

AI Technical Summary

Technical Problem

The existing switching clock circuit fails to effectively detect the loss of the backup clock, resulting in weak chip operation stability, and cannot be directly equipped with the main clock loss detection logic circuit due to area limitations.

Method used

A clock detection and control circuit is designed, including an internal crystal oscillator, clock detection module, clock generation module and clock control module. It detects the backup clock in real time through the sampling clock and issues an alarm when the backup clock is lost to ensure that the main clock is not copied. The clock loss detection circuit realizes the switching and detection of the backup clock.

Benefits of technology

It improves the working stability of the chip and enables real-time detection and switching of the backup clock without increasing the area of ​​the clock control module, ensuring that the system can operate normally when the main clock is lost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118393968B
    Figure CN118393968B
Patent Text Reader

Abstract

The present application belongs to the field of clock detection technology, and discloses a clock detection and control circuit, including: an internal crystal oscillator, a clock detection module, a clock generation module and a clock control module; the internal crystal oscillator is used to generate an internal clock and send it to the clock detection module; the clock detection module is used to receive the internal clock and the main clock, and detect the loss of the main clock based on the internal clock, and send the detection result to the clock control module; the clock generation module is used to generate a backup clock that is the same as the main clock, and send it to the clock control module; when the clock control module receives the detection result of the loss of the main clock, it outputs the backup clock; and, based on the sampling clock, the backup clock is sampled to obtain a sampling value; based on the sampling value, it is judged whether the backup clock is lost, and an alarm is issued when the backup clock is lost. The present application can realize the switching and detection of the backup clock, which not only has a small area requirement for the clock control module, but also improves the stability of the chip operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of clock detection, and in particular to a clock detection and control circuit. Background Art

[0002] The clock is a very important digital reference signal. The accuracy and stability of the clock signal determine whether a chip can work properly. The clock signal can be generated by internal circuits, such as OSC, VCO, etc., or provided by an external crystal oscillator. When the clock signal is missing, it is necessary to detect this state and send an alarm signal to the circuit system. The circuit system responds to the alarm signal to ensure system safety. The response operation usually starts the backup clock generation circuit to generate a backup clock to replace the lost main clock and continue to work.

[0003] However, existing switching clock circuits usually do not take into account the possible loss of the backup clock, resulting in the circuit still malfunctioning due to problems with the backup clock after the backup clock is started; and because the circuit that performs the switching clock operation is usually implemented by a simple digital switching circuit, the area is small and it is impossible to directly carry the logic circuit for detecting the loss of the main clock. Therefore, the existing technology has the problem of lack of monitoring of the backup clock, resulting in weak stability of the chip operation. Summary of the invention

[0004] The present application provides a clock detection and control circuit, which can realize the switching and detection of backup clocks, not only reduces the area requirement of the clock control module, but also improves the stability of chip operation.

[0005] The embodiment of the present application provides a clock detection and control circuit, including:

[0006] Internal crystal oscillator, clock detection module, clock generation module and clock control module;

[0007] The internal crystal oscillator is used to generate the internal clock and send it to the clock detection module;

[0008] The clock detection module is used to receive the internal clock and the main clock, and perform loss detection on the main clock based on the internal clock, and send the detection result to the clock control module;

[0009] The clock generation module is used to generate a backup clock that is the same as the main clock and send it to the clock control module;

[0010] The clock control module outputs a backup clock when receiving the detection result of the main clock being lost;

[0011] And, based on the sampling clock, the backup clock is sampled to obtain a sampling value; based on the sampling value, it is determined whether the backup clock is lost, and an alarm is issued when the backup clock is lost.

[0012] Furthermore, the frequency of the sampling clock is greater than the frequency of the backup clock; the clock control module is used to compare the low-level duration and high-level duration of the backup clock, add the larger level duration and the period of the sampling clock to obtain the target period; if the sampling values ​​obtained in two adjacent target periods are the same, it is judged that the backup clock is lost.

[0013] Furthermore, the circuit also includes a power-off protection chip;

[0014] The power-off protection chip is connected to the clock control module and the target chip respectively;

[0015] The clock control module is also used to send a lock-out signal to the power-off protection chip when it is detected that the backup clock is lost and the detection result of the clock detection module is still that the main clock is lost, so that the power-off protection chip performs a power-off operation.

[0016] Furthermore, the clock control module is also used to switch the output backup clock to the main clock when the detection result of the main clock reset is received after the backup clock is output; and, if the detection result of the main clock reset is received after sending the unlock signal, a power-on signal is sent to the power-off protection chip while switching to the main clock.

[0017] Furthermore, the clock control module is also used to detect whether the main clock and the backup clock are the same before switching the backup clock to the reset main clock; if they are the same, the switching operation is performed, otherwise a main clock reset error prompt message is generated.

[0018] Further, the clock control module includes a first digital-to-analog converter, a second digital-to-analog converter and a comparator;

[0019] The first digital-to-analog converter is used for converting the standby clock into an analog signal and then inputting the analog signal into the comparator;

[0020] The second digital-to-analog converter is used for converting the reset main clock into an analog signal and then inputting the analog signal into the comparator;

[0021] The clock control module determines whether the main clock and the backup clock are the same according to the output result of the comparator.

[0022] Further, the clock generation module is a configuration register, and the configuration register includes a plurality of backup clocks arranged in different priority orders; the clock control module is also used to send a switching signal to the configuration register after detecting that the backup clock is lost;

[0023] The configuration register is used to respond to the switching signal and send the next priority backup clock to the clock control module; and if there is no next priority backup clock, send a no backup signal to the clock control module;

[0024] The clock control module is also used to send a lock-out signal to the power-off protection chip when a no-backup signal is received and the detection result of the clock detection module is still that the main clock is lost.

[0025] Furthermore, the clock detection module includes a frequency divider, a delay reset unit, a first counter, a second counter and a digital detection unit; the frequency divider is used to divide the high frequency signal of the main clock into a low frequency signal and send it to the delay reset unit;

[0026] The delay reset unit is used to sample the received low-frequency signal according to the internal clock to obtain a reset signal, and send the reset signal to the first counter; the first counter is used to count the internal clock, obtain a first count value and send it to the digital detection unit, and clear the first count value after receiving the reset signal;

[0027] The second counter is used for waiting for two cycles of the internal clock after the first counter receives the reset signal, starting to count the internal clock, obtaining a second count value and sending it to the digital detection unit;

[0028] The digital detection unit is used to generate a detection result of master clock loss and send it to the clock control module when the first count value exceeds the first preset threshold; and, after generating the detection result of master clock loss, if the second count value exceeds the second preset threshold, generate a detection result of master clock reset and send it to the clock control module.

[0029] Further, the delay reset unit includes a NOT gate, a NAND gate and five D flip-flops connected in series;

[0030] The input end of the NOT gate is connected to the output end of the fifth D flip-flop; the first input end of the NAND gate is connected to the output end of the NOT gate, the second input end is connected to the output end of the fourth D flip-flop, and the output end is connected to the input end of the first counter.

[0031] Furthermore, the first preset threshold is 7; the second preset threshold is 5.

[0032] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:

[0033] The clock detection and control circuit provided in the embodiment of the present application determines whether the main clock is lost through the clock detection module, switches the backup clock through the clock control module when the main clock is lost, and performs real-time loss detection of the backup clock based on the software program and the sampling clock, and issues an alarm to prompt the user when the backup clock is also lost. The above circuit can realize the switching and detection of the backup clock without duplicating the main clock loss detection circuit, which not only reduces the area requirement of the clock control module, but also improves the stability of the chip operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A structural diagram of a clock detection and control circuit provided for an exemplary embodiment of the present application.

[0035] Figure 2 A structural diagram of a clock detection module provided for an exemplary embodiment of the present application.

[0036] Figure 3 A flowchart of the master clock signal loss detection steps provided for an exemplary embodiment of the present application.

[0037] Figure 4 A structural diagram of a delay reset unit provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0038] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0039] Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. In the description of the present invention, it should be noted that the orientation or position relationship indicated by the terms "upper", "lower", etc. is based on the orientation or position relationship shown in the accompanying drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.

[0040] See also Figure 1 , an embodiment of the present application provides a clock detection and control circuit, including:

[0041] Internal crystal oscillator, clock detection module, clock generation module and clock control module.

[0042] The internal crystal oscillator is used to generate an internal clock and send it to the clock detection module; the clock detection module is used to receive the internal clock and the main clock, and perform loss detection on the main clock based on the internal clock, and send the detection result to the clock control module.

[0043] The clock generation module is used to generate a backup clock that is the same as the main clock and send it to the clock control module; when the clock control module receives the detection result that the main clock is lost, it outputs the backup clock; and, based on the sampling clock, samples the backup clock to obtain a sampling value; based on the sampling value, it determines whether the backup clock is lost, and issues an alarm when the backup clock is lost.

[0044] Among them, the frequency of the sampling clock is greater than the frequency of the backup clock; specifically, the clock control module is used to compare the low-level duration and the high-level duration of the backup clock, add the larger level duration and the period of the sampling clock to obtain the target period; if the sampling values ​​obtained in two adjacent target periods are the same, it is judged that the backup clock is lost.

[0045] In the specific implementation process, when the rising edge of the sampling clock with a duty cycle of 1:1 arrives, the level value of the backup clock at the corresponding moment will be collected as the sampling value; assuming that the high level duration of the backup clock is 3 and the low level duration is 2, the target period is 3+1=4; if the backup clock is not lost, then in two adjacent periods with a duration of 4, the collected level values ​​will not be the same, for example, the sampling value in the first target period is 1110, and the sampling value in the second target period is 0111; therefore, only when the sampling values ​​are the same, it means that the level value of the sampled signal has been fixed, that is, the backup clock is lost.

[0046] The clock detection and control circuit provided by the above embodiment determines whether the main clock is lost through the clock detection module, switches the backup clock through the clock control module when the main clock is lost, and performs real-time loss detection of the backup clock based on the software program and the sampling clock, and issues an alarm to prompt the user when the backup clock is also lost. The above circuit can realize the switching and detection of the backup clock without duplicating the main clock loss detection circuit, which not only reduces the area requirement of the clock control module, but also improves the stability of the chip operation.

[0047] In some embodiments, the circuit further includes a power-off protection chip.

[0048] The power-off protection chip is connected to the clock control module and the target chip respectively.

[0049] The clock control module is also used to send a lock-out signal to the power-off protection chip when it is detected that the backup clock is lost and the detection result of the clock detection module is still that the main clock is lost, so that the power-off protection chip performs a power-off operation.

[0050] Specifically, the power-off protection chip controls the power supply of the target chip that uses the main clock or the backup clock. When the backup clock is lost and the loss of the main clock has not been restored, the power-off protection chip performs a power-off operation by sending an unlock signal to the power-off protection chip, thereby avoiding erroneous operation of the target chip and further improving the stability of the chip.

[0051] In some embodiments, the clock control module is also used to switch the output backup clock to the main clock when the detection result of the main clock reset is received after the backup clock is output; and, if the detection result of the main clock reset is received after sending the unlock signal, a power-on signal is sent to the power-off protection chip while switching to the main clock.

[0052] Specifically, the clock detection module performs real-time detection on the main clock. After detecting the loss, if the main clock is restored, the detection result of the main clock reset is output to the clock control module, so that it switches back to the main clock; if the clock control module sends an unlock signal to the power-off protection chip due to the loss of the backup clock, it will power on again while restoring the main clock.

[0053] Furthermore, the clock control module is also used to detect whether the main clock and the backup clock are the same before switching the backup clock to the reset main clock; if they are the same, the switching operation is performed, otherwise a main clock reset error prompt message is generated.

[0054] During the specific implementation process, it is taken into account that the restored main clock may change, resulting in it being unsuitable for the data sampling work of the chip even after restoration. Therefore, this application compares the restored main clock and the backup clock, where the comparison parameters may include frequency, duty cycle, jitter, etc., to ensure that the chip can work stably after switching.

[0055] Specifically, the clock control module includes a first digital-to-analog converter, a second digital-to-analog converter and a comparator.

[0056] The first digital-to-analog converter is used to convert the standby clock into an analog signal and then input the analog signal into the comparator.

[0057] The second digital-to-analog converter is used to convert the reset main clock into an analog signal and then input the analog signal into the comparator.

[0058] The clock control module determines whether the main clock and the backup clock are the same according to the output result of the comparator.

[0059] If the comparator determines that the two analog signals are consistent, the output result is 1, otherwise it is 0; the present application converts the two clocks into analog signals for comparison by setting a digital-to-analog converter, and the comparison result is fast and accurate.

[0060] In some embodiments, the clock generation module may be a configuration register, which includes multiple backup clocks arranged in different priority orders; the clock control module is also used to send a switching signal to the configuration register after detecting that the backup clock is lost.

[0061] The configuration register is used to respond to the switching signal and send the next priority backup clock to the clock control module; and, if there is no next priority backup clock, send a no backup signal to the clock control module; the clock control module is also used to send an unlock signal to the power-off protection chip when it receives the no backup signal and the detection result of the clock detection module is still that the main clock is lost.

[0062] Specifically, the present application sets up multiple backup clocks in the clock generation module. The parameters of these backup clocks are the same as those of the main clock, but they are arranged in different priority orders. When the backup clock is lost, the clock control module can select the next priority backup clock for output until all the backup clocks are lost, and then send an unlock signal.

[0063] The above embodiment sets a plurality of backup clocks, further ensuring the clock input when the backup clock is lost, reducing the situation where chip operation errors are caused by clock loss, and indirectly improving the operation stability of the target chip.

[0064] See also Figure 2 In some embodiments, the clock detection module includes a frequency divider, a delay reset unit, a first counter, a second counter and a digital detection unit.

[0065] The frequency divider is used to divide the high frequency signal of the main clock into a low frequency signal and send it to the delay reset unit.

[0066] The delay reset unit is used to sample the received low-frequency signal according to the internal clock, obtain a reset signal, and send the reset signal to the first counter; the first counter is used to count the internal clock, obtain a first count value and send it to the digital detection unit, and clear the first count value after receiving the reset signal.

[0067] The second counter is used to wait for two cycles of the internal clock after the first counter receives the reset signal, start counting the internal clock, obtain a second count value and send it to the digital detection unit.

[0068] The digital detection unit is used to generate a detection result of master clock loss and send it to the clock control module when the first count value exceeds the first preset threshold; and, after generating the detection result of master clock loss, if the second count value exceeds the second preset threshold, generate a detection result of master clock reset and send it to the clock control module.

[0069] Specifically, after the main clock (CLK_IN) signal is lost, the first counter no longer counts according to the reset signal, but continues to count to the first preset threshold, so that the digital detection unit determines that the signal is lost and alarms; the second counter is always 0 before the main clock is lost, and does not participate in the loss detection count. The digital detection unit generates an alarm signal, and the alarm signal outputs 1, indicating that the clock is lost; the LOS alarm signal outputs 0, indicating that the clock is recovered.

[0070] See also Figure 3 When the input master clock signal is restored, the first counter will be triggered to restart counting. After the first counter restarts counting, two internal clock cycles will pass and the second counter will start counting. When the second count value of the second counter reaches the second preset threshold configured by the register, the counting will stop and the detection result of master clock recovery will be generated. After the first counter counts the first number, this high level will trigger the second counter to start counting. There is a two-cycle delay in between, so the second counter will start counting after the first counter counts twice.

[0071] Figure 3 The detection process is as follows:

[0072] 1) After the initial register configuration is completed, the second counter starts counting. When the count reaches the second preset threshold (for example, the clear delay is set to 2ms, when the second counter counts to 'h1CB5A), the second counter is reset and the clock detection module is started.

[0073] 2) During the normal input of the master clock signal, due to the periodic reset of the delay reset unit (0 is valid), the first counter cyclically counts in a very small counting range, for example, 1-5 cycle counts, and never reaches the first preset threshold configured by the register. At this time, the output signal of the digital detection unit is 0, and the alarm of the master clock loss will not be activated.

[0074] 3) When the main clock signal disappears, the delay reset unit will not reset periodically, and the first counter will not reset periodically (for example, it will not count cyclically between 1-5). The first counter will count normally. When the count reaches the register configuration value (for example, the first preset threshold is 7), the alarm signal is raised and the detection result of the main clock loss is generated.

[0075] 4) When the main clock signal is restored, the delay reset unit is reset periodically, and the first counter starts counting again. After the first counter counts two numbers, the second counter starts counting. At this time, the alarm signal has not been pulled low and is still in the alarm state.

[0076] Similarly, when the second counter counts to the second preset threshold configured by the register (for example, the second preset threshold is set to 5), the alarm ends. The second counter continues to count in a 1-5 cycle, and the clock detection module outputs the detection result of the master clock reset.

[0077] It should be noted that the second preset threshold value cannot be set lower than the first preset threshold value, otherwise the second counter cannot count, the alarm signal cannot be pulled low, and the detection result of the master clock reset cannot be generated.

[0078] See also Figure 4 In some embodiments, the delay reset unit includes a NOT gate, a NAND gate and 5 D flip-flops connected in series; the input end of the NOT gate is connected to the output end of the fifth D flip-flop; the first input end of the NAND gate is connected to the output end of the NOT gate, the second input end is connected to the output end of the fourth D flip-flop, and the output end is connected to the input end of the first counter.

[0079] Specifically, the master clock is input to the D input of the first D flip-flop, and the internal clock samples the master clock. At the rising edge of the internal clock, D is transmitted to the Q output and maintained; the signal frequency of the internal clock must be greater than the frequency of the master clock in order to sample the master clock signal. The Q output of the fifth flip-flop is sent to one of the inputs of the NAND gate with two inputs through a NOT gate, and the Q output of the fourth flip-flop is sent to the other input of the NAND gate with two inputs. The output of the NAND gate serves as the RST of the first counter. The reason for using five flip-flops in this application is to ensure the input stability of high-frequency signals; in actual applications, it can be reduced to at least two flip-flops to ensure the two signals input to the NAND gate, but the input stability will be reduced.

[0080] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0081] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A clock detection and control circuit, characterized in that: include: Internal crystal oscillator, clock detection module, clock generation module and clock control module; The internal crystal oscillator is used to generate an internal clock and send it to the clock detection module; The clock detection module is used to receive the internal clock and the main clock, and perform loss detection on the main clock based on the internal clock, and send the detection result to the clock control module; Specifically, the clock detection module includes a frequency divider, a delay reset unit, a first counter, a second counter and a digital detection unit; The frequency divider is used to divide the high frequency signal of the master clock into a low frequency signal and send the low frequency signal to the delay reset unit; The delay reset unit is used to sample the received low-frequency signal according to the internal clock to obtain a reset signal, and send the reset signal to the first counter; The first counter is used to count the internal clock, obtain a first count value and send it to the digital detection unit, and clear the first count value after receiving the reset signal; The second counter is used for waiting for two cycles of the internal clock after the first counter receives the reset signal, starting to count the internal clock, obtaining a second count value and sending it to the digital detection unit; The digital detection unit is used to generate a detection result of master clock loss when the first count value exceeds a first preset threshold value, and send the result to the clock control module; And, after generating the detection result of the master clock loss, if the second count value exceeds the second preset threshold, generating the detection result of the master clock reset and sending it to the clock control module; The clock generation module is used to generate a backup clock that is the same as the main clock and send it to the clock control module; The clock control module outputs the backup clock when receiving the detection result that the main clock is lost; And, sampling the standby clock based on the sampling clock to obtain a sampling value; It is determined whether the backup clock is lost based on the sampling value, and an alarm is issued when the backup clock is lost.

2. The clock detection and control circuit according to claim 1, characterized in that: The frequency of the sampling clock is greater than the frequency of the standby clock; the clock control module is used to compare the low level duration and the high level duration of the standby clock, and add the larger level duration to the period of the sampling clock to obtain a target period; If the sampling values ​​obtained in two adjacent target periods are the same, it is determined that the backup clock is lost.

3. The clock detection and control circuit according to claim 2, characterized in that: It also includes a power-off protection chip; The power-off protection chip is connected to the clock control module and the target chip respectively; The clock control module is also used to send a lock-out signal to the power-off protection chip when it is detected that the backup clock is lost and the detection result of the clock detection module is still that the main clock is lost, so that the power-off protection chip performs a power-off operation.

4. The clock detection and control circuit according to claim 3, characterized in that: The clock control module is further configured to switch the outputted backup clock to the main clock upon receiving a detection result of a main clock reset after outputting the backup clock; Furthermore, if a detection result of a master clock reset is received after sending the unlock signal, a power-on signal is sent to the power-off protection chip while switching to the master clock.

5. The clock detection and control circuit according to claim 4, characterized in that: The clock control module is also used to detect whether the main clock and the backup clock are the same before switching the backup clock to the reset main clock; if they are the same, perform the switching operation, otherwise generate a main clock reset error prompt information.

6. The clock detection and control circuit according to claim 5, characterized in that: The clock control module includes a first digital-to-analog converter, a second digital-to-analog converter and a comparator; The first digital-to-analog converter is used to convert the standby clock into an analog signal and then input the analog signal into the comparator; The second digital-to-analog converter is used to convert the reset master clock into an analog signal and input the analog signal into the comparator; The clock control module determines whether the main clock and the backup clock are the same according to the output result of the comparator.

7. The clock detection and control circuit according to claim 6, characterized in that: The clock generation module is a configuration register, and the configuration register includes a plurality of the backup clocks arranged in different priority orders; The clock control module is also used to send a switching signal to the configuration register after detecting that the backup clock is lost; The configuration register is used to respond to the switching signal and send the next priority backup clock to the clock control module; and, if there is no backup clock of the next priority, sending a no backup signal to the clock control module; The clock control module is also used to send the unlock signal to the power-off protection chip when the no-backup signal is received and the detection result of the clock detection module is still that the main clock is lost.

8. The clock detection and control circuit according to claim 1, characterized in that: The delay reset unit includes a NOT gate, a NAND gate and 5 D flip-flops connected in series; The input end of the NOT gate is connected to the output end of the fifth D flip-flop; The first input end of the NAND gate is connected to the output end of the NOT gate, the second input end is connected to the output end of the fourth D flip-flop, and the output end is connected to the input end of the first counter.

9. The clock detection and control circuit according to claim 1, characterized in that: The first preset threshold is 7; the second preset threshold is 5.