Almost all products using MCU, the peripheral circuit is inseparable from the crystal oscillator circuit design, most electronic designers will be exposed to the crystal oscillator circuit from the beginning, but in fact, few people really understand how the crystal oscillator circuit works, when the crystal oscillator appears Before the problem, most people will not pay too much attention to whether the oscillator circuit design is reasonable. They usually wait until the product is mass-produced and the crystal oscillator causes a large area of ​​downtime before they start to notice whether the crystal oscillator circuit design is reasonable.

The full name of the crystal oscillator is:Quartz crystal oscillator. It is an electronic component that uses the piezoelectric effect of quartz crystal to produce high-precision oscillation frequency. Looking at Wikipedia, the specific explanation for this magical material is:

Quartz crystal equivalent model:

Cp: ​​The capacitance connected in parallel with the series arm in the equivalent circuit (annotation: also called parallel capacitance, electrostatic capacitance, its value is generally only related to the size of the crystal oscillator).

Ls: (dynamic equivalent inductance) represents the inertia of the mechanical vibration of the crystal oscillator.

Cs: (dynamic equivalent capacitance) represents the elasticity of the crystal oscillator.

Rs: (dynamic equivalent resistance) represents the loss of the circuit

To understand the design of crystal oscillator circuits, you must first be familiar withPierce (Pierce) oscillator circuit. The model circuit is simple, effective and stable, so almost all crystal oscillator circuit designs today use this model. As follows, the design consists of an inverter, a resistor, a quartz crystal, and two small capacitors. A quartz crystal acts here as a highly selective filter element:

Inv: Internal inverter, the role is equivalent to the amplifier.

Q: Quartz or ceramic crystal oscillator.

Rf: Internal feedback resistance (Annotation: Its existence makes the inverter work in the linear region, so that it can gain gain, and its effect is equivalent to that of an amplifier).

RExt: External current limiting resistor.

CL1 and CL2: Two external load capacitors.

Cs: Equivalent stray capacitance caused by parasitic effects such as PCB wiring and connections (on OSC_IN and OSC_OUT pins)

Next, we focus on the internal feedback resistor Rf, load capacitor Cl, and external current limiting resistor Rext——

Feedback resistance Rf

In the Pierce oscillator, the inside of the chip connected to the crystal oscillator is a linear operational amplifier. Since the voltage gain of the operational amplifier is very large, ranging from hundreds to tens of thousands of times, it is usually used to connect the output terminal to the reverse input. terminal connection to form a negative feedback configuration (that is, a closed-loop amplifier). The feedback resistor Rf in the Pierce oscillator can be regarded as the bias resistor of the inverter, which can make the inverter work in the linear region without working in a fully on or off state due to excessive gain.

In most cases, Rf is embedded in the chip, but it is not ruled out that some chip designs do not have this resistor embedded, so in this case, you will see that some crystal oscillator circuits are connected in parallel with a resistor outside. Reference values ​​of feedback resistors corresponding to different frequencies:

The load capacitance refers to the terminal capacitance connected to the crystal oscillator, which includes: external capacitance CL1 and CL2, and stray capacitance (Cs) on the printed circuit board. The value of CL is determined by the crystal oscillator itself, and the supplier will give it in the specification. When the external equivalent capacitance of the crystal oscillator is equal to the load capacitance CL, the frequency output by the passive crystal oscillator is the most accurate.

CL=（CL1//CL2）+CS

It should be noted that the capacitor has the function of charging and discharging. The larger the capacitor value, the slower the discharge, and the smaller the capacitor value, the faster the discharge. Therefore, in actual debugging, if the measured actual frequency is smaller than the theoretical value, it means that the oscillation frequency of the oscillator is too slow, the discharge of the capacitor is too slow, and the equivalent capacitance is greater than the load capacitance, so the external matching capacitance needs to be reduced.

External resistance Rext

Before we start to explain the external resistors, we need to understand two more concepts: oscillator gain margin gain, drive level DL——

Gain margin gain:Characterizing the Amplification Capability of Oscillating Circuits

Driver level DL:Characterizing the Drive Power Consumption of a Crystal Oscillator

As early as 1988, Eric Vittoz published the relevant theoretical research on the dynamic equivalent circuit of the crystal oscillator RLC. Based on previous theories, the transconductance gm of the inverter must be greater than gmcrit to meet the start-up condition. To ensure reliability, at least 5-fold relationship; ie: gmargin = gm / gmcrit

Among them, gmcrit = 4 x ESR x (2πF)² x (C0 + CL)², ESR, C0, and CL can be obtained from the crystal oscillator specification, and gm can be obtained from the chip specification;

The drive level DL describes the power consumption of the crystal oscillator, the power consumption of the crystal oscillator must be limited within a certain range, otherwise the quartz crystal may not work properly due to excessive mechanical vibration.

DL = ESR x I², where ESR is the equivalent series resistance of the crystal and I is the rms value of the current flowing through the crystal

You must make the DL value smaller than the DL value defined in the crystal oscillator specification. If the actual DL value is higher, you need the Rext resistor to limit the driving power.

For the measurement of I, a current probe is required for measurement, and because the driving current is generally relatively small, it requires a 1mA/mV range. In actual operation, you may not have a current probe with such a high resolution, so you can observe the output of the crystal oscillator pin The shape of the waveform is confirmed, and the specific method is described below.

When you can see this patiently, you have already understood the basic concepts and calculations of crystal oscillator design. Next, you can move on to our final crystal oscillator design steps:

Step 1: Calculation of Gain Margin

gmcrit = 4 x ESR x (2πF)² x (C0 + CL)², ESR, C0, CL can be obtained from the crystal specification, gm can be obtained from the chip specification; gmargin = gm / gmcrit,

If gmargin<>, indicating that this is not a qualified crystal oscillator, you should choose a crystal oscillator with a lower ESR or CL value;

If gmargin>5, proceed to the second step;

Step 2: External Load Capacitance Calculation

CL=（CL1//CL2）+CS

CL is the load capacitance given in the crystal oscillator specification, CL1 and CL2 are the external capacitance to be calculated, and CS is the stray capacitance (which can be roughly calculated using 4pf)

Step 3: Calculation of Drive Level and External Resistors

Use an oscilloscope to test the OSC output pin,

If a very clear sine wave is detected, and the upper limit and lower limit of the sine wave meet the clock input requirements, then the crystal oscillator is not overdriven; then congratulations, you have found a suitable crystal oscillator;

If the peaks and troughs of a sinusoidal waveform are flattened, the waveform becomes square, the crystal oscillator is overdriven. At this time, a resistor Rext is needed to prevent the crystal oscillator from being overdriven. The easiest way to judge the size of the resistor RD is to connect a fine-tuning resistor in series, and slowly increase it from 0 until the sine wave is no longer flattened. At this time, the resistance value is the Rext value. At this time, due to the need to connect Rext in series, the ESR of the crystal oscillator model has changed, so you need to go back to the first step to calculate gmarin. If gmarin>5, then you have found a suitable crystal oscillator. If gmarin<>

Reviewing editor: Liu Qing