AN2867
Application note
Oscillator design guide for STM8S, STM8A
and STM32 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. Refer to
Table 1
for the list of
applicable products.
Table 1. Applicable products
Type
Product categories
STM8S Series
Microcontrollers
STM8AF Series, STM8AL Series
STM32 32-bit ARM Cortex MCUs.
February 2015
DocID15287 Rev 9
1/41
www.st.com
1
List of tables
AN2867
List of tables
1
2
Quartz crystal properties and model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Oscillator theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1
2.2
2.3
Negative resistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Transconductance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Negative-resistance oscillator principles . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3
Pierce oscillator design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1
3.2
3.3
3.4
3.5
Introduction to pierce oscillators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
RF feedback resistor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
C
L
load capacitance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Oscillator transconductance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Drive level (DL) and external resistor (RExt) calculation . . . . . . . . . . . . . 15
3.5.1
3.5.2
3.5.3
Calculating drive level (DL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Another drive level measurement method . . . . . . . . . . . . . . . . . . . . . . . 16
Calculating external resistor (RExt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.6
3.7
3.8
Startup time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Crystal pullability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Safety factor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.8.1
3.8.2
3.8.3
Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Measurement methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Safety factor for STM32 and STM8 oscillators . . . . . . . . . . . . . . . . . . . 19
4
Guidelines for selecting suitable crystal
and external components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1
4.2
Low-speed oscillators embedded into STM32 microcontrollers . . . . . . . . 20
Detailed steps to select an STM32-compatible crystal . . . . . . . . . . . . . . . 23
5
Some recommended resonators for
STM32 microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.1
5.2
STM32-compatible high-speed resonators . . . . . . . . . . . . . . . . . . . . . . . 26
STM32-compatible low-speed resonators . . . . . . . . . . . . . . . . . . . . . . . . 27
2/41
DocID15287 Rev 9
AN2867
List of tables
6
Some recommended crystals for STM8A/S microcontrollers . . . . . . . 29
6.1
6.2
Part numbers of recommended crystal oscillators . . . . . . . . . . . . . . . . . . 29
Part numbers of recommended ceramic resonators . . . . . . . . . . . . . . . . 29
7
Tips for improving oscillator stability . . . . . . . . . . . . . . . . . . . . . . . . . . 30
7.1
7.2
7.3
PCB design guidelines
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
PCB design examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Soldering guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8
9
10
Reference documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
DocID15287 Rev 9
3/41
3
List of tables
AN2867
List of tables
Table 1.
Table 2.
Table 3.
Table 4.
Table 5.
Table 6.
Table 7.
Table 8.
Table 9.
Table 10.
Table 11.
Applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Example of equivalent circuit parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Typical feedback resistor values for given frequencies . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Safety Factor (Sf) for STM32 and STM8 oscillators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
LSE oscillators embedded into STM32 microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . 22
HSE oscillators embedded in STM32 microcontrollers. . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Recommended crystal resonators for LSE oscillator
embedded in STM32 microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
KYOCERA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Recommendable conditions (for consumer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Recommendable conditions (for CAN-BUS). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4/41
DocID15287 Rev 9
AN2867
List of figures
List of figures
Figure 1.
Figure 2.
Figure 3.
Figure 4.
Figure 5.
Figure 6.
Figure 7.
Figure 8.
Figure 9.
Figure 10.
Figure 11.
Figure 12.
Figure 13.
Figure 14.
Figure 15.
Figure 16.
Figure 17.
Figure 18.
Figure 19.
Quartz crystal model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Impedance representation in the frequency domain. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
I-V curve of a dipole showing a negative transresistance area (in purple) . . . . . . . . . . . . . . 9
Block diagram of a typical oscillation loop based on a crystal resonator . . . . . . . . . . . . . . 10
Pierce-oscillator circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Inverter transfer function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Current drive measurement with a current probe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Negative resistance measurement methodology description . . . . . . . . . . . . . . . . . . . . . . . 19
Classification of low-speed crystal resonators available on the market . . . . . . . . . . . . . . . 20
Recommended layout for an oscillator circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
PCB with separated GND plane and guard ring around the oscillator . . . . . . . . . . . . . . . . 32
GND plane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Signals around the oscillator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Preliminary design (PCB design guidelines not respected) . . . . . . . . . . . . . . . . . . . . . . . . 33
Final design (all design guidelines have been respected) . . . . . . . . . . . . . . . . . . . . . . . . . 34
GND plane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Top layer view. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
PCB guidelines not respected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
PCB guidelines respected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
DocID15287 Rev 9
5/41
5