Clock detection circuit, clock detection method, chip and electronic equipment
By designing a clock detection circuit in the chip, and using the counting and capture circuit to detect the frequency and edge jump of the clock signal, the system crash problem caused by abnormal clock signal in the chip is solved, and effective detection and stability guarantee of clock signals are achieved.
Patent Information
- Application Number
- CN202310508459.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-06
- Publication Date
- 2024-11-08
AI Technical Summary
In the chip, abnormal clock signals from internal clock sources and external clock sources may cause system crashes and information loss, and the clock signal needs to be effectively detected to ensure the normal operation of the system.
A clock detection circuit is designed, including a counting circuit, a data capture circuit and a detection circuit. By counting and capturing the target count value of the effective edge of the clock signal, detecting the frequency and edge jump of the clock signal to determine whether the clock signal is abnormal.
It can detect clock signal abnormalities in time, avoid affecting the normal operation of the system, and ensure the stability and accuracy of the clock signal.
Smart Images

Figure CN118921045A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of integrated circuits, and in particular to a clock detection circuit, a clock detection method, a chip and an electronic device. Background Art
[0002] In a chip (Integrated Circuit, IC), such as a system on chip (System on Chip, SOC), there is generally at least one internal clock source and at least one external clock source.
[0003] In the background technology, during the system startup phase and post-startup operation phase of the chip, the internal clock source and / or external clock source will generate multiple clock signals. When a clock signal is abnormal, it may affect the normal operation of the system. In severe cases, it may cause the system to freeze and information loss. Therefore, it is necessary to detect the clock signal and detect the clock signal abnormality in time. Summary of the invention
[0004] In view of the above problems, the embodiments of the present application provide a clock detection circuit, a clock detection method, a chip and an electronic device to solve the above technical problems.
[0005] In a first aspect, an embodiment of the present application provides a clock detection circuit, comprising:
[0006] A counting circuit, used for counting the valid edges of the first clock signal to obtain a count value;
[0007] a data capture circuit, used for capturing at least two target count values obtained by the counting circuit according to a second clock signal;
[0008] The detection circuit is used to detect the first clock signal or the second clock signal according to the at least two target count values to determine whether the first clock signal or the second clock signal is abnormal.
[0009] Optionally, the data capture circuit is further configured to capture the target count value obtained by the counting circuit when an edge transition occurs in the second clock signal.
[0010] Optionally, the frequency of the first clock signal is greater than the frequency of the second clock signal, and the detection circuit is also used to obtain the count difference between each two adjacent target count values of the at least two target count values, and determine whether the first clock signal or the second clock signal is abnormal based on at least one of the count differences.
[0011] Optionally, the detection circuit is further used to obtain a count difference between each two adjacent target count values of the at least two target count values, and if at least one of the count differences does not meet a first preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
[0012] Optionally, the detection circuit is also used to obtain the count difference between each two adjacent target count values among the at least two target count values, and obtain the current signal frequency of the first clock signal or the second clock signal based on at least one of the count differences; if the current signal frequency does not meet the second preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
[0013] Optionally, the data capture circuit includes:
[0014] An effective edge detection circuit, used for detecting an effective edge of the second clock signal;
[0015] A capture register, wherein the first end of the capture register is used to receive the valid edge of the second clock signal; the second end of the capture register is used to connect to the counting circuit to capture the corresponding target count value from the counting circuit when the valid edge of the second clock signal is received.
[0016] Optionally, the clock detection circuit further includes:
[0017] The first signal selection circuit includes a plurality of signal input terminals respectively used to receive different first clock source signals and a signal output terminal for outputting the second clock signal. The first signal selection circuit is used to output the corresponding first clock source signal as the second clock signal according to a first selection signal.
[0018] Optionally, the effective edge detection circuit includes an input terminal for receiving the second clock signal, a first output terminal for outputting a first effective edge of the second clock signal, and a second output terminal for outputting a second effective edge of the second clock signal;
[0019] The data capture circuit also includes a second signal selection circuit, which includes a first input terminal connected to the first output terminal of the effective edge detection circuit, a second input terminal connected to the second output terminal of the effective edge detection circuit, and an output terminal connected to the first terminal of the capture register, and the second signal selection circuit is used to output the first effective edge of the second clock signal or the second effective edge of the second clock signal according to a second selection signal.
[0020] Optionally, the clock detection circuit further includes:
[0021] The third signal selection circuit includes a plurality of signal input terminals respectively used to receive different second clock source signals and a signal output terminal for outputting the first clock signal. The third signal selection circuit is used to output the corresponding second clock source signal as the first clock signal according to a third selection signal.
[0022] Optionally, the detection circuit is further configured to generate a clock abnormality indication signal when the first clock signal or the second clock signal is abnormal.
[0023] In a second aspect, an embodiment of the present application provides a clock detection method, including:
[0024] Counting valid edges of the first clock signal to obtain a count value;
[0025] at least two target count values captured according to the second clock signal;
[0026] The first clock signal or the second clock signal is detected according to the at least two target count values to determine whether the first clock signal or the second clock signal is abnormal.
[0027] Optionally, the at least two target count values captured according to the second clock signal include:
[0028] When the second clock signal has an edge transition, the target count value is captured.
[0029] Optionally, the frequency of the first clock signal is greater than the frequency of the second clock signal;
[0030] The detecting the first clock signal or the second clock signal according to the at least two target count values to determine whether the first clock signal or the second clock signal is abnormal includes:
[0031] A count difference between each two adjacent target count values among the at least two target count values is obtained, and whether the first clock signal or the second clock signal is abnormal is determined according to at least one of the count differences.
[0032] Optionally, obtaining a count difference between each two adjacent target count values of the at least two target count values, and determining whether the first clock signal or the second clock signal is abnormal according to at least one of the count differences, includes:
[0033] A count difference between each two adjacent target count values among the at least two target count values is obtained, and if at least one of the count difference values does not meet a first preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
[0034] Optionally, obtaining a count difference between each two adjacent target count values of the at least two target count values, and determining whether the first clock signal or the second clock signal is abnormal according to at least one of the count differences, includes:
[0035] Obtaining a count difference between each two adjacent target count values among the at least two target count values;
[0036] Acquire a current signal frequency of the first clock signal or the second clock signal according to at least one of the count differences;
[0037] If the current signal frequency does not meet the second preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
[0038] Optionally, the at least two target count values captured according to the second clock signal include:
[0039] detecting a first effective edge and a second effective edge of the second clock signal respectively;
[0040] According to a second selection signal, outputting the first effective edge of the second clock signal or the second effective edge of the second clock signal as a capture effective edge;
[0041] According to the output capture valid edge, the corresponding target count value is captured from the obtained count value.
[0042] Optionally, before counting the valid edges of the first clock signal to obtain the count value, the method further includes:
[0043] The corresponding first clock source signal is output as the second clock signal according to the first selection signal.
[0044] Optionally, before counting the valid edges of the first clock signal to obtain the count value, the method further includes:
[0045] The corresponding second clock source signal is output as the first clock signal according to the third selection signal.
[0046] In a third aspect, an embodiment of the present application provides a chip, comprising the above-mentioned clock detection circuit.
[0047] In a fourth aspect, an embodiment of the present application provides an electronic device comprising the above-mentioned chip.
[0048] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a processor, and a memory coupled to the processor, wherein the memory stores program instructions executable by the processor; when the processor executes the program instructions stored in the memory, the above-mentioned clock detection method is implemented.
[0049] The clock detection circuit, clock detection method, chip and electronic device provided by the embodiments of the present application, in which a counting circuit counts the valid edges of a first clock signal; a data capture circuit captures at least two target count values obtained by the counting circuit according to a second clock signal; the detection circuit is used to detect the first clock signal or the second clock signal according to the at least two target count values; through the above method, one of the first clock signal and the second clock signal is used as a reference clock signal and the other is used as a clock signal to be tested, and the count value of the valid edge of the corresponding first clock signal is captured according to the second clock signal, and the cross detection of the first clock signal and the second clock signal is implemented according to the captured count value, so that abnormalities of the first clock signal or the second clock signal can be discovered in time to avoid affecting the normal operation of the system.
[0050] These and other aspects of the present application will become more clearly understood in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 An application scenario diagram of the clock detection circuit provided in an embodiment of the present application is shown.
[0052] Figure 2 A schematic diagram of the structure of a clock detection circuit provided in an embodiment of the present application is shown.
[0053] Figure 3 An example diagram of the counting timing of the counting circuit in the embodiment of the present application is shown.
[0054] Figure 4 A schematic diagram of the structure of a clock detection circuit provided in an embodiment of the present application is shown.
[0055] Figure 5 A flow chart of a clock detection method provided in an embodiment of the present application is shown.
[0056] Figure 6 A schematic diagram of the structure of a chip provided in an embodiment of the present application is shown.
[0057] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown.
[0058] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0059] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.
[0060] In order to enable those skilled in the art to better understand the solutions of the present application, 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. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0061] In the embodiments of the present application, it should be noted that, in this article, relational terms such as first and second, etc. are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.
[0062] Moreover, the terms "comprises," "comprising," or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0063] In the description of the embodiments of the present application, words such as "example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "example" or "for example" in the embodiments of the present application is not to be interpreted as being more preferred or having more advantages than another embodiment or design. The use of words such as "example" or "for example" is intended to present relative concepts in a clear manner.
[0064] In addition, the "plurality" in the embodiments of the present application refers to two or more than two. In view of this, in the embodiments of the present application, "plurality" can also be understood as "at least two". "At least one" can be understood as one or more, for example, one, two or more. For example, including at least one means including one, two or more, and there is no limit on which ones are included. For example, including at least one of A, B and C, then A, B, C, A and B, A and C, B and C, or A, B and C can be included.
[0065] It should be noted that, in the embodiments of the present application, "and / or" describes the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / ", unless otherwise specified, generally indicates that the associated objects before and after are in an "or" relationship.
[0066] The clock detection circuit provided in this application can be applied to Figure 1 In the chip 200 shown, the chip 200 includes an RC (Resistance and Capacitance) oscillator circuit 201 and a clock detection circuit 100 . The RC oscillator circuit 201 is integrated inside the chip 200 , and the chip 200 is connected to an external crystal oscillator 202 .
[0067] An embodiment of the present application provides a clock detection circuit 100, see Figure 2 As shown, the clock detection circuit includes: a counting circuit 10 , a data capture circuit 20 and a detection circuit 30 .
[0068] The counting circuit 10 counts the valid edges of the first clock signal to obtain a count value.
[0069] In this embodiment, each count value may correspond to a count moment, and the count moment is the moment when a valid edge occurs.
[0070] The data capture circuit 20 captures at least two target count values obtained by the counting circuit 10 according to the second clock signal.
[0071] In this embodiment, the at least two target count values obtained by the data capture circuit 20 are count values corresponding to the second clock signal.
[0072] The detection circuit 30 detects the first clock signal or the second clock signal according to the at least two target count values obtained by the data capture circuit 20 to determine whether the first clock signal or the second clock signal is abnormal.
[0073] In this embodiment, the first clock signal and the second clock signal can be respectively selected from a plurality of clock signals in the chip startup process or the operation process, one of the first clock signal and the second clock signal is used as the reference clock signal and the other is used as the clock signal to be tested. The detection circuit 30 can detect whether the frequency of the first clock signal and the frequency of the second clock signal match according to the at least two target count values obtained by the data capture circuit 20. When the first clock signal and the second clock signal are both normal, the frequencies of the two are respectively preset, and the matching conditions of the frequencies of the two can also be preset. The detection circuit 30 can determine whether the at least two target count values meet the preset matching conditions, and when they match, determine that one of the first clock signal and the second clock signal as the clock signal to be tested is normal, and when they do not match, determine that one of the first clock signal and the second clock signal as the clock signal to be tested is abnormal.
[0074] The clock detection circuit provided in the embodiment of the present application captures the count value of the valid edge of the corresponding first clock signal according to the second clock signal, and implements cross detection of the first clock signal and the second clock signal according to the captured count value, so as to promptly detect abnormalities in the first clock signal or the second clock signal to avoid affecting the normal operation of the system.
[0075] As an implementation method, the clock detection circuit of the embodiment of the present application can also be applied to the following scenarios. In a system-level chip, the external clock source can generally be a crystal oscillator arranged outside the chip, which has high precision. However, it takes a certain amount of time for the crystal oscillator to stabilize after startup; the internal clock source can generally be an LC oscillation circuit or an RC oscillation circuit arranged inside the chip, which has a short startup time, but has poorer precision than the external clock source. When the system-level chip is started, the internal clock source is used to generate the clock signal; during the system operation after the chip is started, the external clock source is used to generate the clock signal. In order to avoid the risk caused by the abnormality of the external clock source during the operation of the system, it is necessary to detect the clock signal generated by the external clock source.
[0076] In some implementations, the first clock signal may be selected from clock signals generated by an external clock source, and the first clock signal is a clock signal to be tested; the second clock signal may be selected from clock signals generated by an internal clock source, and the second clock signal is a standard clock signal.
[0077] In some embodiments, the first clock signal can be selected from clock signals generated by internal and external clock sources, and the first clock signal is a standard clock signal; the second clock signal can be selected from clock signals generated by an external clock source, and the second clock signal is a clock signal to be tested.
[0078] As an implementation mode, the effective edge of the first clock signal can be the first effective edge, which is used to characterize that the first clock circuit changes from the first logic level to the second logic level. The counting circuit 10 is used to count the first effective edge of the first clock signal, and the count value is the number of the first effective edges.
[0079] As an implementation mode, the effective edge of the first clock signal may be the second effective edge, and the first effective edge is used to characterize that the first clock circuit changes from the second logic level to the first logic level. The counting circuit 10 is used to count the second effective edges of the first clock signal, and the count value is the number of second effective edges.
[0080] As an implementation method, the effective edge of the first clock signal may include the first effective edge and the second effective edge at the same time. The counting circuit 10 is used to count the edge transitions of the first clock signal, and the count value is the sum of the number of the first effective edges and the number of the second effective edges.
[0081] In some implementations, the first logic level may be a low level, and the second logic level may be a high level. In this case, the first valid edge is a rising edge, and the second valid edge is a falling edge.
[0082] In some other implementations, the first logic level may be a high level, and the second logic level may be a low level. In this case, the first valid edge is a falling edge, and the second valid edge is a rising edge.
[0083] The following is a detailed description using the rising edge as a specific example of the effective edge of the first clock signal. Figure 3 As shown, in Figure 3 In the counting sequence shown, the count value increases by 1 each time the first clock signal passes through one of its own clock cycles.
[0084] As an implementation manner, the data capture circuit 20 is further configured to capture the target count value obtained by the counting circuit 10 when the second clock signal has an edge transition.
[0085] In this embodiment, the edge jump can be from the first logic level to the second logic level, in which case the target count value corresponding to the moment of the first effective edge of the second clock signal is captured; the edge jump can also be from the second logic level to the first logic level, in which case the target count value corresponding to the moment of the second effective edge of the second clock signal is captured; the edge jump can also include both the change from the first logic level to the second logic level and the change from the second logic level to the first logic level, in which case the target count value corresponding to the moment of the first effective edge of the second clock signal and the target count value corresponding to the moment of the second effective edge of the second clock signal are captured. In this embodiment, the corresponding target count value is captured at the moment of the effective edge of the second clock signal, and at least two target count values can better match the clock cycle of the second clock signal, thereby improving the accuracy of detection.
[0086] The following is a detailed description of the target count value obtained by the data capture circuit 10 when the second clock signal changes from the second logic level to the first logic level. Please continue to refer to Figure 3 As shown, at the moment of the first second effective edge of the second clock signal, the captured target count value is 0; at the moment of the second second effective edge of the second clock signal, the captured target count value is 12.
[0087] As an implementation mode, the frequency of the first clock signal is greater than the frequency of the second clock signal, and the detection circuit 30 obtains the count difference between each two adjacent target count values of at least two target count values, and determines whether the first clock signal or the second clock signal is abnormal based on at least one of the count differences.
[0088] In some embodiments, the detection circuit 30 obtains a count difference between each two adjacent target count values of at least two target count values, and determines that the first clock signal or the second clock signal is abnormal if at least one count difference does not meet a first preset condition.
[0089] In this embodiment, the object detected by the detection circuit 30 is the count difference, and two adjacent target count values are count values corresponding to two consecutive edge transitions of the second clock signal, and the time difference between the two consecutive edge transitions of the second clock signal is one clock cycle of the second clock signal or half a clock cycle of the second clock signal, wherein the time difference between the continuous first effective edge and the second effective edge of the second clock signal and the time difference between the continuous second effective edge and the first effective edge correspond to half a clock cycle of the second clock signal respectively, and the time difference between the two consecutive first effective edges of the second clock signal or the two consecutive second effective edges of the second clock signal is one clock cycle of the second clock signal. The count difference of two adjacent target count values corresponds to a positive integer multiple of the clock cycle of the first clock signal or a positive integer multiple of half a clock cycle of the first clock signal. Therefore, the count difference can indirectly characterize the matching relationship between the first clock signal and the second clock signal.
[0090] In some implementations, the first preset condition may be that the count difference is greater than or equal to a first preset number of times and less than or equal to a second preset number of times, and the first preset number of times is less than the second preset number of times.
[0091] In some implementations, the first preset condition may be that the count difference is equal to a third preset number of times.
[0092] For example, Figure 3 Taking the example shown, the difference between two adjacent target counts is 12, corresponding to 12 clock cycles of the first clock signal and 1 clock cycle of the second clock signal respectively. At this time, the first preset condition can be that the count difference is equal to 12, or the first preset condition can be that the count difference is greater than or equal to 11 and less than or equal to 13.
[0093] In some embodiments, the detection circuit 30 obtains the count difference between each two adjacent target count values among at least two target count values, obtains the current signal frequency of the first clock signal or the second clock signal based on at least one count difference, and if the current signal frequency does not meet the second preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
[0094] In this embodiment, the object detected by the detection circuit 30 is the current signal frequency, and the current signal frequency of the clock signal to be detected can be calculated based on at least one count difference and the clock frequency of the standard clock signal. Figure 3 As shown in the figure, the difference between two adjacent target counts is 12, which corresponds to 12 clock cycles of the first clock signal and 1 clock cycle of the second clock signal, respectively, and 12f is satisfied. 2 =f 1 , where f 1 is the frequency of the first clock signal, f 2 is the frequency of the second clock signal.
[0095] In some implementations, the second preset condition may be that the current signal frequency is greater than or equal to the first preset frequency and less than or equal to the second preset frequency, and the first preset frequency is less than the second preset frequency.
[0096] In some implementations, the second preset condition may be that the current signal frequency is equal to a third preset frequency.
[0097] As an embodiment, the data capture circuit 20 includes an effective edge detection circuit 21 and a capture register 22, wherein the effective edge detection circuit 21 detects the effective edge of the second clock signal, and the effective edge of the second clock signal may include a first effective edge and / or a second effective edge; the capture register includes a first end 221 and a second end 222, and the first end 221 of the capture register 22 is used to receive the effective edge of the second clock signal; the second end 222 of the capture register 22 is connected to the counting circuit 10 to capture the corresponding target count value from the counting circuit 10 when the effective edge of the second clock signal is received.
[0098] In this embodiment, the target count value is captured and stored by the capture register 22, and the detection circuit 30 can perform detection according to the target count value in a timely manner.
[0099] Those skilled in the art should understand that the method in which the data capture circuit 20 captures the target count value according to the second clock signal is not limited to the above-mentioned capturing at the time of the valid edge of the second clock signal, and other methods may also be used.
[0100] As an implementation, see Figure 4 As shown, the clock detection circuit 100 also includes a first signal selection circuit 40, which includes multiple signal input terminals 41 and a signal output terminal 42. The multiple signal input terminals 41 are respectively used to receive different first clock source signals, and the signal output terminal 42 is used to output the second clock signal. The first signal selection circuit 40 is used to output the corresponding first clock source signal as the second clock signal according to the first selection signal.
[0101] In this embodiment, different signal input terminals 41 correspond to different signal transmission channels, and different signal transmission channels correspond to different first selection signals. For example, when the first selection signal is 100, the first clock source signal CLK11 is selected; when the first selection signal is 101, the first clock source signal CLK12 is selected; when the first selection signal is 110, the first clock source signal CLK13 is selected; when the first selection signal is 111, the first clock source signal CLK14 is selected; when the first selection signal is 000 or 001 or 010, no clock signal is output.
[0102] In this embodiment, different first clock source signals can be used as second clock signals respectively through the first signal selection circuit 40, so as to meet more application scenarios and increase the flexibility of detection.
[0103] In some embodiments, the plurality of first clock source signals may include a system clock SYSCLK, an internal high-speed clock HRC, an external high-speed clock HXT, and a phase-locked loop clock PLLCLK.
[0104] In some embodiments, the effective edge detection circuit 21 is used to detect the first effective edge and the second effective edge of the second clock signal, and the effective edge detection circuit 21 includes an input terminal 211 for receiving the second clock signal, a first output terminal 212 for outputting the first effective edge of the second clock signal, and a second output terminal 213 for outputting the second effective edge of the second clock signal.
[0105] The data capture circuit 20 also includes a second signal selection circuit 23, which includes a first input terminal 231 connected to the first output terminal 212 of the effective edge detection circuit 21, a second input terminal 232 connected to the second output terminal 213 of the effective edge detection circuit 21, and an output terminal 233 connected to the first terminal 221 of the capture register 22. The second signal selection circuit 23 outputs the first effective edge of the second clock signal or the second effective edge of the second clock signal according to the second selection signal.
[0106] In this embodiment, the first input terminal 231 and the second input terminal 232 of the second signal selection circuit 23 correspond to different signal transmission channels, respectively, and different signal transmission channels correspond to different second selection signals. For example, when the second selection signal is 0, the first valid edge of the second clock signal is selected; when the second selection signal is 1, the second valid edge of the second clock signal is selected.
[0107] In this embodiment, the second signal selection circuit 23 can switch the capture mode between capturing at the first valid edge of the second clock signal and capturing at the second valid edge of the second clock signal, thereby increasing the flexibility of detection.
[0108] As an implementation mode, the clock detection circuit 100 of this embodiment also includes a third signal selection circuit 50, which includes a plurality of signal input terminals 51 respectively used to receive different second clock source signals and a signal output terminal 52 for outputting a first clock signal. The third signal selection circuit 50 is used to output the corresponding second clock source signal as the first clock signal according to the third selection signal.
[0109] In this embodiment, different signal input terminals 51 correspond to different signal transmission channels, and different signal transmission channels correspond to different third selection signals. For example, when the third selection signal is 00, the second clock source signal CLK21 is selected; when the third selection signal is 01, the second clock source signal CLK22 is selected; when the third selection signal is 10, the second clock source signal CLK23 is selected.
[0110] In this embodiment, different second clock source signals can be used as first clock signals respectively through the third signal selection circuit 50, so as to meet more application scenarios and increase the flexibility of detection.
[0111] As an implementation manner, the detection circuit 30 is further configured to generate a clock abnormality indication signal when the first clock signal or the second clock signal is abnormal.
[0112] As an implementation method, the detection circuit 30 may be the core of a chip.
[0113] As an implementation, see Figure 4 As shown, the clock detection circuit 100 of this embodiment also includes a filter circuit 60, the input end of the filter circuit 60 is connected to the signal output end 42 of the first signal selection circuit 40, the output end of the filter circuit 60 is connected to the input end 211 of the effective edge detection circuit 21, and the filter circuit 60 is used to filter the second clock signal to improve the detection accuracy.
[0114] This application embodiment provides a clock detection method, see Figure 5 As shown, the clock detection method includes the following steps:
[0115] S11, counting valid edges of the first clock signal to obtain a count value;
[0116] S12, capturing at least two target count values according to the second clock signal;
[0117] S13: Detect the first clock signal or the second clock signal according to the at least two target count values to determine whether the first clock signal or the second clock signal is abnormal.
[0118] As an implementation manner, in step S12, when an edge transition occurs in the second clock signal, the target count value is captured.
[0119] In some implementations, in step S13, a count difference between every two adjacent target count values of at least two target count values is obtained, and whether the first clock signal or the second clock signal is abnormal is determined based on at least one of the count differences.
[0120] A count difference between each two adjacent target count values of at least two target count values is obtained, and if at least one count difference does not meet a first preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
[0121] In some embodiments, in step S13, a count difference between each two adjacent target count values of at least two target count values is obtained, and a current signal frequency of the first clock signal or the second clock signal is obtained based on at least one count difference. If the current signal frequency does not meet a second preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
[0122] As an implementation manner, the following steps are also included before step S11:
[0123] S10a, outputting the corresponding first clock source signal as the second clock signal according to the first selection signal.
[0124] As an implementation manner, step S12 specifically includes the following steps:
[0125] S121, detecting a first valid edge and a second valid edge of a second clock signal respectively;
[0126] S122, according to the second selection signal, outputting the first valid edge of the second clock signal or the second valid edge of the second clock signal as a capture valid edge;
[0127] S123, capturing a corresponding target count value from the obtained count value according to the output capture valid edge.
[0128] As an implementation manner, the following steps are also included before step S11:
[0129] S10b, outputting the corresponding second clock source signal as the first clock signal according to the third selection signal.
[0130] As an implementation manner, after step S13, the following steps are also included:
[0131] S14, when the first clock signal or the second clock signal is abnormal, generating a clock abnormality indication signal.
[0132] In this embodiment, one of the first clock signal and the second clock signal is used as a reference clock signal, and the other is used as a clock signal to be tested. The count value of the valid edge of the corresponding first clock signal is captured according to the second clock signal, and the cross detection of the first clock signal and the second clock signal is implemented according to the captured count value. The abnormality of the first clock signal or the second clock signal can be discovered in time to avoid affecting the normal operation of the system.
[0133] The present application embodiment provides a chip 300, see Figure 6 As shown, the chip 300 includes a clock detection circuit 100 .
[0134] In this embodiment, one of the first clock signal and the second clock signal is used as a reference clock signal, and the other is used as a clock signal to be tested. The count value of the valid edge of the corresponding first clock signal is captured according to the second clock signal, and the cross detection of the first clock signal and the second clock signal is implemented according to the captured count value. The abnormality of the first clock signal or the second clock signal can be discovered in time to avoid affecting the normal operation of the system.
[0135] The present application embodiment provides an electronic device 400, see Figure 7 As shown, the electronic device 40 includes the above-mentioned chip 300 .
[0136] In this embodiment, the electronic device may be, but is not limited to, an intelligent sports device, a body fat scale, a nutrition scale, an infrared electronic thermometer, a pulse oximeter, a human body composition analyzer, an intelligent wearable device, a mobile terminal, and a smart home device. The intelligent sports device may be an intelligent skipping rope. Intelligent wearable devices include, but are not limited to, smart watches, smart bracelets, and cervical massagers. Mobile terminals include, but are not limited to, smart phones, laptops, tablet computers, and POS (point of sales terminal). In the electronic device, the count value of the valid edge of the corresponding first clock signal is captured according to the second clock signal, and the cross detection of the first clock signal and the second clock signal is realized according to the captured count value, so that the abnormality of the first clock signal or the second clock signal can be discovered in time to avoid affecting the normal operation of the system.
[0137] Figure 8 Schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 8 As shown, the electronic device 600 includes a processor 61 and a memory 62 coupled to the processor 61 .
[0138] The memory 62 stores program instructions for implementing the clock detection method of any of the above embodiments.
[0139] The processor 61 is used to execute program instructions stored in the memory 62 to perform clock detection.
[0140] The processor 61 may also be referred to as a CPU (Central Processing Unit). The processor 61 may be an integrated circuit chip having the ability to process signals. The processor 61 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0141] In this embodiment, the electronic device may be, but is not limited to, an intelligent sports device, a body fat scale, a nutrition scale, an infrared electronic thermometer, a pulse oximeter, a human body composition analyzer, an intelligent wearable device, a mobile terminal, and a smart home device. The intelligent sports device may be an intelligent skipping rope. Intelligent wearable devices include, but are not limited to, smart watches, smart bracelets, and cervical massagers. Mobile terminals include, but are not limited to, smart phones, laptops, tablet computers, and POS (point of sales terminal). In the electronic device, the count value of the valid edge of the corresponding first clock signal is captured according to the second clock signal, and the cross detection of the first clock signal and the second clock signal is realized according to the captured count value, so that the abnormality of the first clock signal or the second clock signal can be discovered in time to avoid affecting the normal operation of the system.
[0142] The above is only an implementation method of the present application. It should be pointed out that a person skilled in the art can make improvements without departing from the inventive concept of the present application, but these improvements are within the scope of protection of the present application.
Claims
1. A clock detection circuit, characterized in that: include: A counting circuit, used for counting the valid edges of the first clock signal to obtain a count value; a data capture circuit, used for capturing at least two target count values obtained by the counting circuit according to a second clock signal; The detection circuit is used to detect the first clock signal or the second clock signal according to the at least two target count values to determine whether the first clock signal or the second clock signal is abnormal.
2. The clock detection circuit according to claim 1, characterized in that: The data capture circuit is further configured to capture the target count value obtained by the counting circuit when an edge transition occurs on the second clock signal.
3. The clock detection circuit according to claim 2, characterized in that: The frequency of the first clock signal is greater than the frequency of the second clock signal. The detection circuit is also used to obtain the count difference between each two adjacent target count values among the at least two target count values, and determine whether the first clock signal or the second clock signal is abnormal based on at least one of the count differences.
4. The clock detection circuit according to claim 3, characterized in that: The detection circuit is further configured to obtain a count difference between each two adjacent target count values of the at least two target count values, and determine that the first clock signal or the second clock signal is abnormal if at least one of the count differences does not meet a first preset condition.
5. The clock detection circuit according to claim 3, characterized in that: The detection circuit is also used to obtain the count difference between each two adjacent target count values among the at least two target count values, and obtain the current signal frequency of the first clock signal or the second clock signal based on at least one of the count differences; if the current signal frequency does not meet the second preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
6. The clock detection circuit according to claim 2, characterized in that: The data capture circuit comprises: An effective edge detection circuit, used for detecting an effective edge of the second clock signal; A capture register, wherein the first end of the capture register is used to receive the valid edge of the second clock signal; the second end of the capture register is used to connect to the counting circuit to capture the corresponding target count value from the counting circuit when the valid edge of the second clock signal is received.
7. The clock detection circuit according to claim 6, characterized in that: The clock detection circuit also includes: The first signal selection circuit includes a plurality of signal input terminals respectively used to receive different first clock source signals and a signal output terminal for outputting the second clock signal. The first signal selection circuit is used to output the corresponding first clock source signal as the second clock signal according to a first selection signal.
8. The clock detection circuit according to claim 7, characterized in that: The effective edge detection circuit comprises an input terminal for receiving the second clock signal, a first output terminal for outputting a first effective edge of the second clock signal, and a second output terminal for outputting a second effective edge of the second clock signal; The data capture circuit also includes a second signal selection circuit, which includes a first input terminal connected to the first output terminal of the effective edge detection circuit, a second input terminal connected to the second output terminal of the effective edge detection circuit, and an output terminal connected to the first terminal of the capture register, and the second signal selection circuit is used to output the first effective edge of the second clock signal or the second effective edge of the second clock signal according to a second selection signal.
9. The clock detection circuit according to claim 1, characterized in that: The clock detection circuit also includes: The third signal selection circuit includes a plurality of signal input terminals respectively used to receive different second clock source signals and a signal output terminal for outputting the first clock signal. The third signal selection circuit is used to output the corresponding second clock source signal as the first clock signal according to a third selection signal.
10. The clock detection circuit according to claim 1, characterized in that: The detection circuit is further configured to generate a clock abnormality indication signal when the first clock signal or the second clock signal is abnormal.
11. A clock detection method, characterized in that: include: Counting valid edges of the first clock signal to obtain a count value; at least two target count values captured according to the second clock signal; The first clock signal or the second clock signal is detected according to the at least two target count values to determine whether the first clock signal or the second clock signal is abnormal.
12. The clock detection circuit according to claim 11, characterized in that: The at least two target count values captured according to the second clock signal include: When the second clock signal has an edge transition, the target count value is captured.
13. The clock detection circuit according to claim 12, characterized in that: The frequency of the first clock signal is greater than the frequency of the second clock signal; The detecting the first clock signal or the second clock signal according to the at least two target count values to determine whether the first clock signal or the second clock signal is abnormal includes: A count difference between each two adjacent target count values among the at least two target count values is obtained, and whether the first clock signal or the second clock signal is abnormal is determined according to at least one of the count differences.
14. The clock detection circuit according to claim 13, characterized in that: The obtaining a count difference between each two adjacent target count values of the at least two target count values, and determining whether the first clock signal or the second clock signal is abnormal according to at least one of the count differences, includes: A count difference between each two adjacent target count values among the at least two target count values is obtained, and if at least one of the count difference values does not meet a first preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
15. The clock detection circuit according to claim 13, characterized in that: The obtaining a count difference between each two adjacent target count values of the at least two target count values, and determining whether the first clock signal or the second clock signal is abnormal according to at least one of the count differences, includes: Obtaining a count difference between each two adjacent target count values among the at least two target count values; Acquire a current signal frequency of the first clock signal or the second clock signal according to at least one of the count differences; If the current signal frequency does not meet the second preset condition, it is determined that the first clock signal or the second clock signal is abnormal.
16. The clock detection circuit according to claim 11, characterized in that: The at least two target count values captured according to the second clock signal include: detecting a first effective edge and a second effective edge of the second clock signal respectively; According to a second selection signal, outputting the first effective edge of the second clock signal or the second effective edge of the second clock signal as a capture effective edge; According to the output capture valid edge, the corresponding target count value is captured from the obtained count value.
17. The clock detection circuit according to claim 11, characterized in that: Before counting the valid edges of the first clock signal to obtain the count value, the method further includes: The corresponding first clock source signal is output as the second clock signal according to the first selection signal.
18. The clock detection circuit according to claim 11, characterized in that: Before counting the valid edges of the first clock signal to obtain the count value, the method further includes: The corresponding second clock source signal is output as the first clock signal according to the third selection signal.
19. A chip, characterized in that: The method comprises a clock detection circuit as claimed in any one of claims 1 to 10.
20. An electronic device, characterized in that: Comprising the chip as claimed in claim 19.
21. An electronic device, characterized in that: It comprises a processor and a memory coupled to the processor, wherein the memory stores program instructions executable by the processor; when the processor executes the program instructions stored in the memory, the clock detection method according to any one of claims 11 to 18 is implemented.
