1. Field
The present invention relates to an improved clock generator. In particular, the present application relates a clock generator utilizing a ring oscillator with precise frequency control.
2. Related Art
A ring oscillator is generally formed by an odd number of NOT gates, or inverters, connected together in series. The output of the last inverter is connected to the first inverter to form a ring. Since an odd number of inverters are used, the output of the last inverter will be the opposite of the value input to the fist inverter. Since this output is then provided to the first inverter, the output of the last inverter will then change again to the opposite value. Thus, the result is an oscillating output signal which may be used to provide a clock signal, for example. Since each of the inverters has a certain gate delay, the frequency of the output signal can be adjusted by adding, or subtracting pairs of inverters. The more inverters used, the more gate delay introduced to the circuit and the lower the frequency of the oscillator output signal. In addition, the value of the voltage supplied will also affect frequency as well as the heat dissipated by the circuit. The type of silicon used may also affect frequency.
Accordingly, it would be beneficial to provide a clock generator using a ring oscillator that avoids these problems.
It is an object of the present invention to provide a clock generator that provides a desired clock signal, wherein the clock generator includes a ring oscillator.
A clock generator for providing a desired system clock signal in accordance with an embodiment of the present application includes a ring oscillator operable to provide an oscillator output signal having a first frequency, a divider operable to divide the oscillator output signal by a variable divisor and to output the divided signal as the desired system clock signal, a reference device operable to provide a reference signal with a known second frequency and a ratio device operable to provide a ratio value indicative of a relationship between the oscillator output signal and the reference signal, wherein the variable divisor of the divider is determined based on the ratio value such that the desired system clock signal has a desired frequency.
Other features and advantages of the present invention will become apparent from the following description of the invention which refers to the accompanying drawings.
When the generator 100 is selected to be the system clock, via the select signal (elk select), the ring oscillator 10 is enabled by the enabling signal ring enable and a dividing factor is written to the nreg signal. This value is preferably selected as an integer value between 4 and 32 and is based on the desired frequency for the system clock. Thus, the system clock may be set in stepped values between 250 MHz (1 Ghz/4) and 32 MHz (1 GHz/32).
It is noted that the oscillator 10, divider 40 and mux 42 alone could be used to provide the clock signal elk. However, as noted above, ring oscillators, such as oscillator 10 tend to be inaccurate and present a problem for precise frequency control since the frequency is adjusted in steps. For example, the oscillator output signal may have a frequency that varies by as much as 30% from an expected output frequency. Since the divider 40 only divides by integer values, the clock signal elk can only be adjusted in stepped intervals. Thus, setting a precise clock frequency is difficult. In addition, the steps also tend to be irregular in interval, which makes it even more difficult to set the desired clock frequency.
Since it is difficult to predict the output frequency of the ring oscillator 10 with any accuracy, and it is difficult to determine exactly what value should be used to divide this signal to provide the desired clock signal, the clock generator 100 of the present application measures the actual frequency provided by the oscillator and then adjusts other parameters to provide the desired clock signal. In this manner, there is no need to accurately predict the frequency of the oscillator output signal since it can be simply measured.
Thus, the clock generator 100, of the present application includes a ratio calculator 44 used to provide a ratio value that indicates a relationship between the oscillator output signal and a reference signal provided by the reference device 46. This ratio value is then utilize to determine the preferred integer value to be provided to the divider 40 as the divisor to provide a clock signal with the desired frequency. The ratio value is also used in pulse width modulation (PWM) control in the generator 100 as well. In a preferred embodiment, the controller 48 uses the ratio value to calculate a divisor to be provided to the divider 40.
The reference device 46 selects a reference source from one of the signals xtal0 and wdog. In a testing environment, the reference source may be obtained from the signal jtck. In all cases, the frequency of the signal selected from the reference source is known. This reference source signal may be divided by 256 by a third divider 56. This may be useful when the reference source frequency is relatively high such that dividing it by 256 brings it within a more usable range. Either the divided signal from divider 56, or the undivided signal, may be provided as the reference signal refclk to the ratio calculator 44. This selection is preferably made via mux 58, based on the control sign (pll_setup[21]), which is provided from the controller 48, the PLL, or any other control device.
As noted above, the ratio signal (ratio) is preferably used to determine the desired divisor for the divider 40 in
Presuming that the target, or desired, clock frequency is 64 MHz, the controller 48 selects the best divisor for the divider 40 to provide this frequency. In particular, the ratio 2834 is divided by 171 and multiplied by 64/64 to yield the factor of approximately 16. Since this factor is based on the actual output of the ring oscillator 10, the fact that the frequency of the oscillator output signal cannot be accurately predicted is irrelevant. Thus, the value 16 is then provided to the divider 30 via the signal nreg to produce the desired 64 MHz clock signal clk.
In selecting the reference signal, or reference clock signal there are certain limits to keep in mind. In order to get 1% accuracy or better, the ratio value should preferably be above 150. The slowest useful div64 signal has a period of 90 ns. If we multiply the period of the slowest possible useful div64 signal (90 ns) by the minimum ration value (150) the result is 13.5 microseconds. This means that the fastest reference signal, divided by 256 should have a period of 13.5 microseconds. If we divide 13.5 microseconds by 256, the result is 52 ns which corresponds to a frequency of 20 MHz. Thus, the fastest usable reference signal should have a frequency of 20 MHz. The lowest reference signal is preferably in the range of a few hertz.
The ratio value is also used to determine the master cycle used in pulse width modulation (PWM) control. More specifically, as shown in
As illustrated in
Each PWM signal is preferably provided using two register limits (Ton, Toff) stored in the registers 80a, 80b, respectively. The two comparators 82a, 82b compare the respective limits to the phase counter output, and the result is provide to the PWM output node 84 which provided a PWM signal based on these comparisons. The limits Ton and Toff are preferable calculated in the controller 48, or other control circuit. The counter 80 counts through all values and thus Ton and Toff always catch the correct edges. The values Ton and Toff preferably stay constant relative to clock frequency.
Thus, the clock generator of the present application provides a clock signal clk with a frequency that can be suitably controlled despite the inaccuracy common in ring oscillators. Taking a measure of the actual oscillator output signal allows the generator to correct for inaccuracy to provide a suitable clock signal. Thus, the clock generator 100 of the present application provides a suitably accurate clock signal while using an inexpensive ring oscillator.
Although the present invention has been described in relation to particular embodiments thereof, many other variations and modifications and other uses will become apparent to those skilled in the art. It is preferred, therefore, that the present invention be limited not by the specific disclosure herein, but only by the appended claims.
The present application claims benefit of and priority to U.S. Provisional Patent Application No. 60/870,161 entitled DIGITAL TUNABLE CLOCK SCHEME FOR MICROCONTROLLER filed Dec. 15, 2006, the entire contents of which are hereby incorporated by reference herein.
Number | Date | Country | |
---|---|---|---|
60870161 | Dec 2006 | US |