March 2011 Doc ID 15287 Rev 5 1/24
AN2867
Application note
Oscillator design guide
for ST microcontrollers
Introduction
Most designers are familiar with oscillators (Pierce-Gate topology), but few really
understand how they operate, let alone how to properly design an oscillator. In practice,
most designers do not even really pay attention to the oscillator design until they realize the
oscillator does not operate properly (usually when it is already being produced). This should
not happen. Many systems or projects are delayed in their deployment because of a crystal
not working as intended. The oscillator should receive its proper amount of attention during
the design phase, well before the manufacturing phase. The designer would then avoid the
nightmare scenario of products being returned.
This application note introduces the Pierce oscillator basics and provides some guidelines
for a good oscillator design. It also shows how to determine the different external
components and provides guidelines for a good PCB for the oscillator.
This document finally contains an easy guideline to select suitable crystals and external
components, and it lists some recommended crystals (HSE and LSE) for STM32™ and
STM8A/S microcontrollers in order to quick start development.
www.st.com
Contents AN2867
2/24 Doc ID 15287 Rev 5
Contents
1 Quartz crystal properties and model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 Oscillator theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Pierce oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 Pierce oscillator design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1 Feedback resistor RF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.2 Load capacitor CL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.3 Gain margin of the oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.4 Drive level DL and external resistor RExt calculation . . . . . . . . . . . . . . . . 12
4.4.1 Calculating drive level DL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.4.2 Another drive level measurement method . . . . . . . . . . . . . . . . . . . . . . . 13
4.4.3 Calculating external resistor RExt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.5 Startup time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.6 Crystal pullability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5 Easy guideline for the selection of suitable crystal
and external components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6 Some recommended crystals for STM32™ microcontrollers . . . . . . . 16
6.1 HSE part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6.1.1 Part numbers of recommended 8 MHz crystals . . . . . . . . . . . . . . . . . . . 16
6.1.2 Part numbers of recommended ceramic resonators . . . . . . . . . . . . . . . 17
6.1.3 Part numbers of recommended 25 MHz crystals
(Ethernet applications) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.1.4 Part numbers of recommended 14.7456 MHz crystals (audio
applications) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.2 LSE part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7 Some recommended crystals for STM8A/S microcontrollers . . . . . . . 20
7.1 Part numbers of recommended crystal oscillators . . . . . . . . . . . . . . . . . . 20
7.2 Part numbers of recommended ceramic resonators . . . . . . . . . . . . . . . . 20
8 Some PCB hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
AN2867 Contents
Doc ID 15287 Rev 5 3/24
9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
10 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
List of tables AN2867
4/24 Doc ID 15287 Rev 5
List of tables
Table 1. Example of equivalent circuit parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table 2. Typical feedback resistor values for given frequencies . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 3. EPSON® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 4. HOSONIC ELECTRONIC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 5. CTS® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 6. FOXElectronics®. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 7. Recommendable conditions (for consumer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 8. HOSONIC ELECTRONIC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 9. FOXElectronics®. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 10. CTS® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 11. FOXElectronics®. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 12. ABRACON™ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 13. Recommendable crystals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 14. KYOCERA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 15. Recommendable conditions (for consumer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 16. Recommendable conditions (for CAN-BUS). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 17. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
AN2867 List of figures
Doc ID 15287 Rev 5 5/24
List of figures
Figure 1. Quartz crystal model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 2. Impedance representation in the frequency domain. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 3. Oscillator principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 4. Pierce oscillator circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 5. Inverter transfer function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 6. Current drive measurement with a current probe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 7. Recommended layout for an oscillator circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Quartz crystal properties and model AN2867
6/24 Doc ID 15287 Rev 5
1 Quartz crystal properties and model
A quartz crystal is a piezoelectric device transforming electric energy to mechanical energy
and vice versa. The transformation occurs at the resonant frequency. The quartz crystal can
be modeled as follows:
Figure 1. Quartz crystal model
C0: represents the shunt capacitance resulting from the capacitor formed by the electrodes
Lm: (motional inductance) represents the vibrating mass of the crystal
Cm: (motional capacitance) represents the elasticity of the crystal
Rm: (motional resistance) represents the circuit losses
The impedance of the crystal is given by the following equation (assuming that Rm is
negligible):
(1)
Figure 2 represents the impedance in the frequency domain.
Figure 2. Impedance representation in the frequency domain
Fs is the series resonant frequency when the impedance Z = 0. Its expression can be
deduced from equation (1) as follows:
(2)
Q
C0
Rm Cm
Lm
ai15833
Z j
w
----
w
2LmCm 1–
C0 Cm+ w2LmCmC0–
----------------------------------------------------------------=
Fs Fa
Impedance
Inductive behavior:
the quartz oscillates
Area of parallel
resonance: Fp
Capacitive behavior:
no oscillation
Phase (deg)
Frequency
Frequency
+90
–90
ai15834
Fs
1
2 LmCm
---------------------------=
AN2867 Quartz crystal properties and model
Doc ID 15287 Rev 5 7/24
Fa is the anti-resonant frequency when impedance Z tends to infinity. Using equation (1), it is
expressed as follows:
(3)
The region delimited by Fs and Fa is usually called the area of parallel resonance (shaded
area in Figure 2). In this region, the crystal operates in parallel resonance and behaves as
an inductance that adds an additional phase equal to 180 ° in the loop. Its frequency Fp (or
FL: load frequency) has the following expression:
(4)
From equation (4), it appears that the oscillation frequency of the crystal can be tuned by
varying the load capacitor CL. This is why in their datasheets, crystal manufacturers indicate
the exact CL required to make the crystal oscillate at the nominal frequency.
Table 1 gives an example of equivalent crystal circuit component values to have a nominal
frequency of 8 MHz.
Using equations (2), (3) and (4) we can determine Fs, Fa and Fp of this crystal:
and .
If the load capacitance CL at the crystal electrodes is equal to 10 pF, the crystal will oscillate
at the following frequency: .
To have an oscillation frequency of exactly 8 MHz, CL should be equal to 4.02 pF.
Table 1. Example of equivalent circuit parameters
Equivalent component Value
Rm 8
Lm 14.7 mH
Cm 0.027 pF
C0 5.57 pF
Fa Fs 1
Cm
C0
--------+=
Fp Fs 1
Cm
2 C0 CL+
-----------------------------+ =
Fs 7988768 Hz= Fa 8008102 Hz=
Fp 7995695 Hz=
Oscillator theory AN2867
8/24 Doc ID 15287 Rev 5
2 Oscillator theory
An oscillator consists of an amplifier and a feedback network to provide frequency selection.
Figure 3 shows the block diagram of the basic principle.
Figure 3. Oscillator principle
Where:
● A(f) is the complex transfer function of the amplifier that provides energy to keep the
oscillator oscillating.
● B(f) is the complex transfer function of the feedback that sets the oscillator frequency.
To oscillate, the following Barkhausen conditions must be fulfilled. The closed-loop gain
should be greater than 1 and the total phase shift of 360 ° is to be provided:
and
The oscillator needs initial electric energy to start up. Power-up transients and noise can
supply the needed energy. However, the energy level should be high enough to trigger
oscillation at the required frequency. Mathematically, this is represented by |,
which means that the open-loop gain should be much higher than 1. The time required for
the oscillations to become steady depends on the open-loop gain.
Meeting the oscillation conditions is not enough to explain why a crystal oscillator starts to
oscillate. Under these conditions, the amplifier is very unstable, any disturbance introduced
in this positive feedback loop system makes the amplifier unstable and causes oscillations
to start. This may be due to power-on, a disable-to enable sequence, the thermal noise of
the crystal, etc. It is also important to note that only noise within the range of serial-to
parallel frequency can be amplified. This represents but a little amount of energy, which is
why crystal oscillators are so long to start up.
Passive feedback element
A(f)
Active element
B(f)
ai15835
A f A f ejf f =
B f B f ejf f =
A f B f 1 f f + 2=
A f B f 1»
AN2867 Pierce oscillator
Doc ID 15287 Rev 5 9/24
3 Pierce oscillator
Pierce oscillators are commonly used in applications because of their low consumption, low
cost and stability.
Figure 4. Pierce oscillator circuitry
Inv: the internal inverter that works as an amplifier
Q: crystal quartz or a ceramic resonator
RF: internal feedback resistor
RExt: external resistor to limit the inverter output current
CL1 and CL2: are the two external load capacitors
Cs: stray capacitance is the addition of the MCU pin capacitance (OSC_IN and OSC_OUT)
and the PCB capacitance: it is a parasitical capacitance.
RExt
RF
Q
CL1 CL2
Microcontroller
Inv
Cs
ai15836
OSC_OUTOSC_IN
Pierce oscillator design AN2867
10/24 Doc ID 15287 Rev 5
4 Pierce oscillator design
This section describes the different parameters and how to determine their values in order
to be more conversant with the Pierce oscillator design.
4.1 Feedback resistor RF
In most of the cases in ST microcontrollers, RF is embedded in the oscillator circuitry. Its role
is to make the inverter act as an amplifier. The feedback resistor is connected between Vin
and Vout so as to bias the amplifier at Vout = Vin and force it to operate in the linear region
(shaded area in Figure 5). The amplifier amplifies the noise (for example, the thermal noise
of the crystal) within the range of serial to parallel frequency (Fa, Fa). This noise causes the
oscillations to start up. In some cases, if RF is removed after the oscillations have stabilized,
the oscillator continues to operate normally.
Figure 5. Inverter transfer function
Table 2 provides typical values of RF.
Table 2. Typical feedback resistor values for given frequencies
Frequency Feedback resistor range
32.768 kHz 10 to 25 M
1 MHz 5 to 10 M
10 MHz 1 to 5 M
20 MHz 470 k to 5 M
~VDD/2 VDD
VDD
Linear area: the inverter acts as an amplifier
Saturation
region
Saturation
region
Vout
Vin
ai15837
AN2867 Pierce oscillator design
Doc ID 15287 Rev 5 11/24
4.2 Load capacitor CL
The load capacitance is the terminal capacitance of the circuit connected to the crystal
oscillator. This value is determined by the external capacitors CL1 and CL2 and the stray
capacitance of the printed circuit board and connections (Cs). The CL value is specified by
the crystal manufacturer. Mainly, for the frequency to be accurate, the oscillator circuit has to
show the same load capacitance to the crystal as the one the crystal was adjusted for.
Frequency stability mainly requires that the load capacitance be constant. The external
capacitors CL1 and CL2 are used to tune the desired value of CL to reach the value specified
by the crystal manufacturer.
The following equation gives the expression of CL:
Example of CL1 and CL2 calculation:
For example if the CL value of the crystal is equal to 15 pF and, assuming that Cs = 5 pF,
then:
. That is: .
4.3 Gain margin of the oscillator
The gain margin is the key parameter that determines whether the oscillator will start up or
not. It has the following expression:
, where:
● gm is the transconductance of the inverter (in mA/V for the high-frequency part or in
µA/V for the low-frequency part: 32 kHz).
● gmcrit (gm critical) depends on the crystal parameters.
Assuming that CL1 = CL2, and assuming that the crystal sees the same CL on its pads
as the value given by the crystal manufacturer, gmcrit is expressed as follows:
, where ESR = equivalent series resistor
According to the Eric Vittoz theory: the impedance of the motional RLC equivalent circuit of
a crystal is compensated by the impedance of the amplifier and the two external
capacitances.
To satisfy this theory, the inverter transconductance (gm) must have a value gm > gmcrit. In
this case, the oscillation condition is reached. A gain margin of 5 can be considered as a
minimum to ensure an efficient startup of oscillations.
For example, to design the oscillator part of a microcontroller that has a gm value equal to
25 mA/V, we choose a quartz crystal (from Fox) that has the following characteristics:
frequency = 8 MHz, C0 = 7 pF, CL = 10 pF, ESR = 80 .. Will this crystal oscillate with this
microcontroller?
Let us calculate gmcrit:
CL
CL1 CL2
CL1 CL2+
-------------------------- Cs+=
CL Cs–
CL1 CL2
CL1 CL2+
-------------------------- 10 pF== CL1 CL2= 20 pF=
gainm inarg
gm
gmcrit
---------------=
gmcrit 4 ESR 2F 2 C0 CL+ 2=
gmcrit 4 80 2 8 610
2 7 12–10 10 12–10+ 2 0.23 mA V==
Pierce oscillator design AN2867
12/24 Doc ID 15287 Rev 5
Calculating the gain margin gives:
The gain margin is very sufficient to start the oscillation and the “gain margin greater than 5”
condition is reached. The crystal will oscillate normally.
If an insufficient gain margin is found (gain margin < 5) the oscillation condition is not
reached and the crystal will not start up. You should then try to select a crystal with a lower
ESR or/and with a lower CL.
4.4 Drive level DL and external resistor RExt calculation
The drive level and external resistor value are closely related. They will therefore be
addressed in the same section.
4.4.1 Calculating drive level DL
The drive level is the power dissipated in the crystal. It has to be limited otherwise the quartz
crystal can fail due to excessive mechanical vibration. The maximum drive level is specified
by the crystal manufacturer, usually in mW. Exceeding this maximum value may lead to the
crystal being damaged.
The drive level is given by the following formula: , where:
● ESR is the equivalent series resistor (specified by the crystal manufacturer):
● IQ is the current flowing through the crystal in RMS. This current can be displayed on
an oscilloscope as a sine wave. The current value can be read as the peak-to-peak
value (IPP). When using a current probe (as shown in Figure 6), the voltage scale of an
oscilloscope may be converted into 1mA/1mV.
Figure 6. Current drive measurement with a current probe
So as described previously, when tuning the current with the potentiometer, the current
through the crystal does not exceed IQmax RMS (assuming that the current through the
crystal is sinusoidal).
Thus IQmax RMS is given by:
gainm inarg
gm
gmcrit
---------------
25
0.23----------- 107= = =
DL ESR IQ
2=
ESR Rm 1
C0
CL
-------+
2=
Crystal
ai15838
To oscilloscope
Current probe
IQmaxRMS
DLmax
ESR-----------------
IQmaxPP
2 2
------------------------= =
AN2867 Pierce oscillator design
Doc ID 15287 Rev 5 13/24
Therefore the current through the crystal (peak-to-peak value read on the oscilloscope)
should not exceed a maximum peak-to-peak current (IQmaxPP) equal to:
Hence the need for an external resistor (RExt) (refer to Section 4.4.3) when IQ exceeds
IQmaxPP. The addition of RExt then becomes mandatory and it is added to ESR in the
expression of IQmax.
4.4.2 Another drive level measurement method
The drive level can be computed as:
DL= I²QRMS × ESR, where IQRMS is the RMS AC current.
This current can be calculated by measuring the voltage swing at the amplifier input with a
low-capacitance oscilloscope probe (no more than 1 pF). The amplifier input current is
negligible with respect to the current through CL1, so we can assume that the current
through the crystal is equal to the curr
本文档为【Oscillator design guide for ST microcontrollers】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。