ST AN2867 APPLICATION NOTE

AN2867
Application note
Oscillator design guide for STM8S, STM8A
and STM32F1 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 STM32F1 and STM8A/S microcontrollers in order to quick start development. Refer to Ta bl e 1 for the list of applicable products.

Table 1. Applicable products

Type Product sub-classes
STM8S Mainstream microcontrollers
Microcontrollers
STM8A Automotive microcontrollers
STM32 F1 Mainstream microcontrollers
July 2012 Doc ID 15287 Rev 6 1/24
www.st.com
Contents AN2867
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 C
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
L . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5 Easy guideline for the selection of suitable crystal
and external components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6 Some recommended crystals for STM32F1 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
2/24 Doc ID 15287 Rev 6
AN2867 Contents
9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
10 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Doc ID 15287 Rev 6 3/24
List of tables AN2867
List of tables
Table 1. Applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Table 2. Example of equivalent circuit parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table 3. Typical feedback resistor values for given frequencies . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 4. EPSON
Table 5. HOSONIC ELECTRONIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 6. CTS Table 7. FOXElectronics
Table 8. Recommendable conditions (for consumer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 9. HOSONIC ELECTRONIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 10. FOXElectronics Table 11. CTS Table 12. FOXElectronics
Table 13. ABRACON™ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Table 14. Recommendable crystals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 15. KYOCERA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 16. Recommendable conditions (for consumer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 17. Recommendable conditions (for CAN-BUS). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 18. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
®. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
®. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
®. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4/24 Doc ID 15287 Rev 6
AN2867 List of figures
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
Doc ID 15287 Rev 6 5/24
Quartz crystal properties and model AN2867
Q
C
0
R
m
C
m
L
m
ai15833
Z
j
w
--- -
w
2
Lm× C
m
× 1
C
0Cm
+()w
2
Lm× Cm× C
0
×
--------------------------------------------------------------------------------- -
×=

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

C
: represents the shunt capacitance resulting from the capacitor formed by the electrodes
0
L
: (motional inductance) represents the vibrating mass of the crystal
m
C
: (motional capacitance) represents the elasticity of the crystal
m
R
: (motional resistance) represents the circuit losses
m
The impedance of the crystal is given by the following equation (assuming that R negligible):
is
m
(1)
Figure 2 represents the impedance in the frequency domain.

Figure 2. Impedance representation in the frequency domain

Impedance
Area of parallel
Inductive behavior: the quartz oscillates
Capacitive behavior: no oscillation
Phase (deg)
+90
–90
resonance: Fp
F
s
F
a
Frequency
Frequency
ai15834
6/24 Doc ID 15287 Rev 6
AN2867 Quartz crystal properties and model
F
s
1
2π LmC
m
----------------------------- -
=
F
a
Fs1
C
m
C
0
---------
+=
F
p
Fs1
C
m
2C0C
L
+()
------------------------------
+
⎝⎠
⎜⎟
⎛⎞
=
F
s
7988768 H z=
F
a
8008102 H z=
F
p
7995695 H z=
Fs is the series resonant frequency when the impedance Z = 0. Its expression can be deduced from equation (1) as follows:
(2)
F
is the anti-resonant frequency when impedance Z tends to infinity. Using equation (1), it is
a
expressed as follows:
(3)
The region delimited by F
and Fa is usually called the area of parallel resonance (shaded
s
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 F F
: load frequency) has the following expression:
L
p
(or
(4)
From equation (4), it appears that the oscillation frequency of the crystal can be tuned by varying the load capacitor C the exact C
required to make the crystal oscillate at the nominal frequency.
L
. This is why in their datasheets, crystal manufacturers indicate
L
Ta bl e 2 gives an example of equivalent crystal circuit component values to have a nominal
frequency of 8 MHz.

Table 2. Example of equivalent circuit parameters

Equivalent component Value
R
m
L
m
C
m
C
0
8 Ω
14.7 mH
0.027 pF
5.57 pF
Using equations (2), (3) and (4) we can determine Fs, Fa and Fp of this crystal:
and .
If the load capacitance C
at the crystal electrodes is equal to 10 pF, the crystal will oscillate
L
at the following frequency: .
To have an oscillation frequency of exactly 8 MHz, C
Doc ID 15287 Rev 6 7/24
should be equal to 4.02 pF.
L
Oscillator theory AN2867
Passive feedback element
A(f)
Active element
B(f)
ai15835
Af() Af() e
jfα f()
=
Bf() Bf() e
jfβ f()
=
Af() Bf() 1
α f() βf()+ =
Af() Bf() 1»

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.
8/24 Doc ID 15287 Rev 6
Loading...
+ 16 hidden pages