Analyzing the Behavior of an Oscillator and Ensuring Good Start-up 80C51 MCU’s This application note explains how an oscillator functions and which methods can be used to check if the oscillation conditions are met in order to ensure a good start-up when power is applied. Application Note Oscillator Fundamentals A microcontroller integrates on-chip an oscillator to generate a stable clock used to synchronize the CPU and the peripherals. Figure 1. Basic Oscillator Architecture Noise + Xtal1 Amplifier Xtal2 G(f) Feed-back Loop H(f) The basic architecture of an oscillator (regardless of its structure) is shown in Figure 1 and built around an amplifier, a feed-back and noise applied on Xtal1 input. The role of each elements is explained hereafter: • Amplifier: Used to amplify the signal applied on Xtal1 and to lock the oscillations exhibit Xtal2. The class A structure is the most popular but new ones are currently used in order to optimize the consumption or other criterion, • Feed-back loop: Used to filter the output signal and to send it to the Xtal1 input. The oscillator stability is linked to the bandwidth of the loop. The narrower the filter, the more stable the oscillator. Crystals or ceramic resonators are generally used because they have the narrowest bandwidth and efficiency for the stability of the frequency. Rev. 4363A–80C51–07/04 1 • Noise: Thanks to the noise an oscillator is able to startup. This noise has different origins: – thermal noise due to the transistor junctions and resistors, – RF noise: a wide band noise is present in the air and consequently on all the pins of the chip and in particular on Xtal1 input of the amplifier. The noise origin can be industrial, astronomic, semiconductor, ... – transient noise during the power-up. The noise is coupled to the amplifier from the inside and outside of the chip through the package, the internal power rails, .... Figure 2 shows the typical oscillator structure used in most microcontroller chips. An onchip amplifier connected to an external feed-back consists in a crystal or a resonator and two capacitors (a). Sometimes a resistor is inserted (b) between the amplifier output and the crystal in order to limit the power applied, avoiding the destruction of the crystal. Figure 2. Typical Oscillator Structures Xtal1 Xtal2 a) Xtal2 Xtal1 b) 2 4363A–80C51–07/04 Typical Oscillator Operation The process involved in start-up and locking of oscillator is explained hereafter (see Figure 3): • Biasing process. The power-up is applied and the amplifier output follows the power until it reaches its biasing level where it can amplify the noise signal on its input. • Oscillation. The amplified noise on the output (Xtal2) is filtered by the feed-back loop which has a pass-band frequency corresponding to the nominal oscillator frequency. The filtered output noise is amplified again and starts to increase. The oscillation level continue to grow and reaches the non-linear area. • Lock. In the non-linear area both the gain and the oscillation level starts to reduce. • Steady State. A stabilization point is found where the closed-loop gain is maintained with the unity. Figure 3. Process Needed to Reach a Stable Oscillation VDD Bias Level Vxtal2 t Biasing Start Oscillation Lock Steady State Each element plays a role and their electrical characteristics have to be understood. The next sections explain this matter. Crystal Model and Operation Crystal and ceramic resonators are piezoelectric devices which transform voltage energy to mechanical vibrations and vice-versa. At certain vibrational frequencies, there is a mechanical resonance. Main resonances are called: fundamental, third, fifth, ... overtones. Overtones are not harmonics but different mechanical vibrational modes. This crystal is an efficient pass-band filter which exhibits a good frequency stability. The equivalent model, shown in Figure 4, consists of two resonant circuits: • C1, L1 and R1 is a series resonant circuit (fs), • In addition the series circuit, C0 in parallel forms a parallel circuit which has a parallel resonance frequency (fa) . 3 4363A–80C51–07/04 Figure 4. Crystal Models. C0 R1 L1 C1 Q1 Q2 Figure 5 plots the module and phase of the impedance crystal and shows both the series and parallel resonance frequencies. Figure 5. Phase and Module Versus the Frequency Z(f) dB 96.034 100 Rp 1 := ⋅ 6.28 C1 ) ( f ) fs 75 ⋅ fs 50 L1 fa := fs ⋅ 1 + 25 R1 0 0 9.998 . 10 6 ⋅ 9.998 φ(f) degree 90 ) ) ⋅ 9.999 10 6 6 . 10 1 Series . 10 C0 fa C1 L1 C1 C0 f 7 1.0001 . 10 7 . 10 1.0002 7 1.0003 Parallel . 10 7 1.0004 . 10 7 1.0005 f . 10 1 × 1 90 45 360 6.28 0 45 − 90 90 f 6 6 7 7 7 7 7 7 The behavior of the crystal depends on the frequency and is summarized in Table 1. Table 1. Nature of the Impedance Versus the Frequency Frequency f < fs f=fs fs < f < fa f=fa f>fa Z(f) Capacitive C1 Resistance R1 Inductive L1 Resistance Rp Capacitive C0 Phase(°) -90 0 +90 0 -90 4 4363A–80C51–07/04 The impedance phase is related to the frequency and each elements of the model plays a role in specific frequency ranges. The main electrical characteristics of these elements are summarized hereafter. Series resonance frequency fs 1 := ⋅ Quality factor ⋅ 6.28 Qs := ⋅ ⋅ L1 6.28 fs R1 C1 L1 Parallel resonance fa := fs ⋅ 1 + frequency C1 Quality factor C0 Qp 1 := ⋅ ⋅ ⋅ C0 6.28 fp R1 With External Load, CL frequency fp := fs ⋅ 1 + Quality factor Qp := C1 2⋅ ( C0 + CL) ESR ESR := R1⋅ 1 + C0 CL 2 1 ⋅ ⋅ ⋅ CL 6.28 fp ESR Table 2 gives some typical crystal characteristics. Table 2. Examples of Crystal Characteristics Frequency MHz R1 ohms L1 mH C1 fF C0 pF fs MHz fp MHz Qs Qp 32 35 11.25 2.2 7 32 32.005 646k 3.11 30 (2) 20 11 2.6 6 30 30.0065 102k 6.14 30 (1) 40 33.94 0.83 3.8 30 30.00328 160k 3.48 20 50 20 3.2 10 20 20.0032 497k 2.98 16 80 11.641 8.5 3 16 16.022 146k 3.42 10 20 0.025 10 20 10 10.00025 159.2k 80 8 7 0.0862 4.6 40 8 8.00026 618k 17.4 6 8 0.0848 8.3 40 6 6.000356 533k 37 2 100 520 12 4 2 2.003 66K 198 Note: 1. Fundamental Mode 2. Third Overtone Mode “Series” Versus “Parallel” Crystal There is no such thing as a “series cut” crystal as opposed to a “parallel cut” crystal. Both modes exist in a crystal. Only the oscillator structures (Pierce, Colpitts, ..) will oscillate the crystal close to the fs or between fs and fa resonance frequencies. The first structure is called a series resonant oscillator and the second a parallel resonant oscillator. It should be noted that no oscillator structure is able to oscillate at the exact fa frequency. This is due to the high quality factor at fa and the difficulty to stabilize an oscillator at this frequency. 5 4363A–80C51–07/04 Overtone or Fundamental Mode Vibrational mode is used to reduce the crystal cost. Above 20MHz it is costly to produce such crystals tuned on the fundamental mode. To avoid that, an overtone mode is used to tune the oscillation frequency. To work properly, this vibrational mode needs a specific schematic where a frequency trap is installed on the oscillator output to short-circuit the fundamental mode and force the overtone mode. The trap is an LC filter installed between the Xtal2 and the ground. The frequency on this filter is calculated on the fundamental mode using the Thomson equation (see Figure 6). Figure 6. A LC trap is Used for an Overtone Oscillator Xtal2 Xtal1 Ltrap Ftrap 1 = ----------------------------------------------------------- 2×π× Ltrap × Ctrap X1 C1 C2 Ctrap 0 Drive Level The characteristics of quartz crystals are influenced by the drive level. In particular, when the drive level increases, the frequency and the resistance change through nonlinear effects. In extreme cases an inharmonic mode may replace the main mode as the selective element and cause the frequency of the oscillator jump to a different frequency. With an overdrive level, the crystal substrate itself may be damaged. Typical characteristic of frequency vs. drive levels is shown in Figure 7. Figure 7. Frequency Shift vs. Drive Level Drive level is a measurement of the total power dissipated through the crystal operating in the circuit. Typical drive levels are between 50 uW and 1000 uW (1 mW). Drive levels should be kept at the minimum level that will initiate and maintain oscillation. It should be less than half of the maximum drive level. Excessive drive may cause correlation difficulties, frequency drift, spurious emissions, "ringing" wave forms, excessive ageing, and/or fatal structural damage to the crystal. 6 4363A–80C51–07/04 The maximum drive, PMax, is specified by the crystal manufacturer. The maximum RMS current which can flow in the crystal and it is given by the following expression: PMrms := ESR⋅ IMrms2 IMrms := PMrms ESR where ESR is equivalent resistance at the parallel frequency, fp. For example, 0.1 Watt Maximum power with an ESR of 32 ohms gives a 56mA maximum RMS current. The RMS voltage across the crystal can be evaluated in the same manner: UMrms := PMrms⋅ ESR where UMrms is the maximum RMSvalue. For example, if PMrms is 0.1Watt and ESR =32Ohms, the maximum RMS voltage accross the crystal is 1.8V. In case of overdrive power, a resistor must be connected between the amplifier output and the crystal as shown in Table 2. Class-A Amplifier Figure 8 gives an example of a class-A amplifier. Resistance Rf is used to bias the output stage to VDD/2. Cxtal1 and Cxtal2 are the parasitic capacitors due to input and output amplifier pads plus the parasitic capacitances of the package. Rout is the equivalent output resistance of the amplifier. The equivalent schematic is true only for the linear area of the gain and for small signal conditions. This linear operation occurs during the startup when the power is applied. The transfer function is often first order and low-pass filter type. VDD Xtal1 Xtal1 G0 Rout Xtal2 G(f) Rf Xtal2 G0 vin a) VSS vout Cxtal1 b) VSS f Cxtal2 c) Figure 8. (a) Typical structure of a class-A amplifier. (b) Equivalent schematic. (c) Gain response. Next section explains the two specific amplifier areas needed to startup and lock an oscillator. 7 4363A–80C51–07/04 The Two Operating Areas Figure 9 illustrates the transfer function of a CMOS amplifier. An amplifier such as that shown in Figure 8 has two operating regions. These regions determine the oscillator operation at start-up and during steady state while oscillations are stabilized. Figure 9 shows these two regions: • Region A, is the linear region. The gain is constant, and vout is proportional to vin: vout ( f ) = G ( f ) × vin ( f ) ) The dynamic range of this linear region is typically +/- 1 volt around the quiescent point Q at 5v VDD. • Region B, is the non-linear region. The gain is no longer linear, and becomes dependent on the vout level. The higher the vout, the lower the gain. The amplification is automatically reduced while the output oscillation increases until a stabilization point is found (amplitude limitation). Figure 9. Gain Curve and the Two Amplification Region vs B Non-Linear region A VDD/2 Linear region B Non-Linear Region ve VDD/2 The oscillations start gradually. The noise on its input is amplified until the level reaches VDD. If conditions (gain and phase) as specified above are fulfilled, startup is normally guaranteed at circuit power-on time. Indeed, during power-on, noise over a large spectrum appears and is sufficient to start-up the system. Only a few microvolts or millivolts are needed but the startup time is inversely proportional to this level. Typical waveform of an oscillation is shown in Figure 10. Figure 10. Start and Lock of a Feedback Oscillator Vxtal2 Start and lock Steady State 8 4363A–80C51–07/04 Series and Parallel Oscillators Some oscillator architectures force the crystal to operate around the series frequency and some others to work around the parallel frequency. This section gives information about these working modes. series resonant oscillator This structure used a non inverted amplifier to force oscillation at its the natural series resonant frequency fs. The crystal phase is zero, the resistance is minimum (R1) and the current flow is maximum. Figure 11. Series Resonant Structure Xtal1 Xtal2 Q1 Xtal1 Q2 R1 Q1 Xtal2 Q2 X1 The feedback (X1) filters the oscillation frequency and send this signal in phase to Q1 input. Parallel Resonant Oscillator This structure used an inverted amplifier to force oscillation between fs and fa resonance frequencies where the crystal impedance appears inductive (L1). This structure is called Pierce. To have this frequency resonant, fp, the imaginary part of the crystal impedance must be zero. So only capacitive reactance can cancel the inductive one. This is why the C1 and C2 capacitors are added on Xtal1 and Xtal2 (see Figure 12). Figure 12. Parallel Resonant Structure Xtal2 Xtal1 Q1 L1 Q2 Xtal1 CL Q1 Xtal2 Q2 X1 ESR C1 C2 The resonance frequency is given hereafter: fp := fs ⋅ 1 + C1 2⋅ ( C0 + CL) where CL is the capacitive load equivalent to the C1 in parallel to C2. The equivalent series resistance (ESR) is a little higher than for fs and is given with the next expression: 2 C1 × C2 ESR = R 1 × 1 + C-------0 ,CL = --------------------CL C 1 + C2 Considering the expression of fp, CL plays an important role to have the required oscillation frequency. CL is the loading capacitor used during the crystal calibration by the crystal manufacturer to tune the oscillator frequency. If an accurate frequency is 9 4363A–80C51–07/04 required CL must be respected. Here are some standard values are 13, 20, 24,30, and 32 pF. Analysis Method Two methods of oscillator analysis are considered in this application note. One method involves the open-loop gain and phase response versus frequency. A second method considers the amplifier as a one-port with negative real impedance to which the filter is attached. The second one will be preferred for very low frequency (32KHz). The next sections explains the basics of these two methods and how to use them. Open-loop Gain and Phase This first method analyzes the product of the gain of the amplifier and the feed-back loop. Figure 13. Basic Oscillator Architecture Amplifier Noise + G(f) vn(f) vin(f) vout(f) Feed-back Loop H(f) The general equation to start-up the oscillation process is shown hereafter. Let’s express vout(f): vout ( f ) = G ( f ) × Hf ( f ) × vout ( f ) + G ( f ) × vn ( f ) the transfer function between vout(f) and vn(f) is: vout ( f) G (f ) ------------------ = -------------------------------------1 – G (f ) × H( f) vn ( f ) the start-up condition can now be evaluated with the Barkhausen criteria: G ( f ) × H ( f) >1 Φ ( G ( f ) × H ( f) ) = 0 and lock condition can be expressed: G ( f) × H( f ) = 1 This start-up condition depends on the product of the gain and feed-back but also on the frequency. The lock condition is controlled by the non-linear area of the amplifier output. The gain is automatically reduced while the output oscillation increased until a stabilization point is found. 10 4363A–80C51–07/04 To analyze the oscillation conditions, it is useful to use a Spice simulator. Some freeware are available on the Web and only the basic functions of Spice are required. Figure 14 shows a typical oscillator Spice circuit use to demonstrate the AC small signal analysis. Figure 14. Typical crystal oscillator structure. As seen previously, the open-loop gain is analyzed to check the oscillation conditions. To do that the feed-back loop is broken. The crystal has to be loaded with the same impedance than the input impedance of the amplifier. Figure 15 shows the Spice circuit used to analyses the oscillation conditions. A 16MHz crystal is used for this analysis and CP1 and CP2 are tuned to have the oscillation conditions (G> 0dB, Phase=0). Figure 15. Spice Circuit Used to Analyze the Oscillation Conditions Xtal1 Xtal2 38pF Figure 16 plots the gain and the phase of the open-loop circuit. At 16.001MHZ the gain is greater than unity (38dB) and the phase is zero. The oscillation conditions are met ensuring a good oscillator startup. 11 4363A–80C51–07/04 Figure 16. Gain and Phase response for the open-loop gain. Gain(dB) Phase(°) 180 40 187 30 Phase = 0° Gain = 38dB 144 Phase 20 108 100 Gain 10 72 0 36 0 16.007MHz 16.001MHz 0 -10 -55 This method allows to check the maximum capacitive loads and the maximum electrical characteristics of the crystal. Figure 17 (a) plots the gain and phase when Cp1 and CP2 are too big. The gain is now too small to guarantee a proper startup. The phase begins to shift and is no longer zero. Figure 17 (b) plots the gain and phase when the equivalent resistance of the crystal (R1) is too big. The gain is now negative and the phase is not zero. The oscillation conditions are not met and this oscillator will not start. Figure 17. Gain and phase for two conditions 1.1 8.3 Phase > 0 0 G=-3dB G=0.3dB 0 6.5 .00100MHz V(VXtal1)/V(VXtal10)) a) 16.00188MHz -21.4 b) 15.99503MHz DB(V(VXtal1)/V(VXtal10)) 16.00796MHz a) Cp1 and Cp2 are too big (56pF), b) R1 is too big = 40ohms. Table 3 resumes the case studies analyze with the spice model and tool. 12 4363A–80C51–07/04 Table 3. Oscillation Conditions versus Cp1, Cp2 and R1 Cp1(pF) Cp2(pF) R1(ohms) Oscillation Conditions 33 33 10 Yes 33 33 40 No 56 56 10 No CP1 and CP2 are generally chosen to be equal maintaining a gain in closed loop equal to the unity. Negative feed-back resistance The second method analyzes the real part on the input impedance of the amplifier and compares it with the real part of the pass-band filter. The impedance seen on the input amplifier is negative under certain conditions and cancelled the crystal resistance. In that case there is no more lost of energy and oscillations are stabilized. Figure 18 shows the equivalent model of an oscillator. The crystal is equivalent to a RLC filter corresponding to the motional arm. Z3 in the equivalent impedance accross Xtal1 and Xtal2 pins including the C0 crystal capacitor and Cx3. Z1 and Z2 are the input and output impedances including the two external capacitors Cp1 and Cp2 used to adjust the oscillator operating point. Figure 18. a) Oscillator Equivalent model b) Equivalent model around the resonance. a) b) Crystal R1 L1 Crystal C1 R1 L1 C1 Z3 Rin Xtal1 Cin Xtal2 Amplifier Z1 0 Z2 0 0 Amplifier Figure 18 shows in what conditions the oscillator will oscillate. To have an oscillation stable in steady condition, the lost of energy in the crystal has to be cancelled. This condition occurs when: Rin = – R 1 13 4363A–80C51–07/04 and at the frequency: 1 f = ----------------------------------------------------------C 1 × Cin 6, 28 × L 1 × ----------------------C 1 + Cin Cin is the equivalent capacitor seen between Xtal1 and Xtal2 and is equal to: 1 × Cx 2 --------------------------Cin = C 0 + Cx 3 + Cx C 1 x + Cx 2 where Cx1 and Cx2 are the global capacitors seen on the input and output pins. Cx3 is the capacitor seen between Xtal1 and Xtal2 pins. To ensure a good startup of the oscillator, Cx1 and Cx2 have to be correctly adjusted. In order to define them, the amplifier impedance must respect the conditions on Rin and Cin parameters: • Rin: Cx1 and Cx2 has to be adjusted to have Rin > R1: ( Cx 1 × Cx 2 ) × –gm Rin ( Zc ) = ----------------------------------------------------------------------------------------------------------------------------------------------------------2 2 2 ( gm × Cx 3 ) + ω × ( Cx 1 × Cx 2 + Cx 2 × Cx 3 + Cx 1 × Cx 3 ) • Cin: Cx1 and Cx2 have to be adjusted to obtain a negative imaginary part and finally a input capacitor. gm 2 × Cx 3 + ω 2 × ( Cx 1 + Cx 2 ) × ( Cx 1 × Cx 2 + Cx 1 × Cx 3 + Cx 2 × Cx 3 )2Im ( Zc ) = –-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2 2 2 ω × ( ( gm × Cx 3 ) + ω × ( xC 1 × Cx 2 + Cx 2 × Cx 3 + Cx 1 × Cx 3 ) ) Im ( Zc ) C = -------------------6, 28 × f gm is the amplifier gain. An example is given hereafter. The main characteristics of this case study is: • Amplifier: gm=0.01A/V, Cxtal1=5pf, Cxtal2=8pF, Cxtal3=5pf • Crystal: R1=80, L1=11.64mH, C1=8.5fF, C0=5pF 14 4363A–80C51–07/04 Figure 19. Oscillator Example Crystal R1 L1 C1 C0 5p Cxtal3 5p Xtal1 Xtal2 Cp1 Cxtal1 Cxtal2 gm 5p 8p 0.01A/V 0 Cp2 0 0 Amplifier Table 4 shows two cases: first, there is no external additional capacitors and second two capacitors are adjusted to the oscillation frequency. When there is no capacitor Rin is less than R1 (80 ohms) and no oscillation occurs. With Cp1=Cp2=5pf, Rin is -175 ohms and is greater than R1 and the condition to have oscillations is met. As with the previous method, Cp1 and Cp2 can be tuned and the electrical characteristics can be checked. Table 4 resumes the case studies. Table 4. Cp1 and Cp2 capacitors with R1=80ohms. Conclusions Cp1(pF) Cp2(pF) Rin(ohms) Cin(pF) Oscillation Condition 0 0 -60 8.26 No 5 5 -175 9.2 Yes Two methods have been presented to analyze and to check the oscillation conditions.They have shown the possibility to predict the added capacitors in versus the electrical characteristics of the crystal or resonator devices. It will help to specify the margin of the crystal and resonator devices. 15 4363A–80C51–07/04 Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 e-mail [email protected] Web Site http://www.atmel.com Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard warranty which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel’s products are not authorized for use as critical components in life support devices or systems. © Atmel Corporation 2004. All rights reserved. Atmel® and combinations thereof are the registered trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be the trademarks of others. Printed on recycled paper. 4363A–80C51–07/04 xM