Crystal oscillators function as the “beating heart” of a microcontroller—synchronizing clock signals and managing timing for all present operations. In this article, learn how start-up, cost, package size, tolerance, and drive level are important things to consider when choosing a crystal for an STM32 microcontroller.
STM32 processor families
Table 1 shows the range of STM32 processor families and how they have been matched to different application verticals. Picking the desired MCU family is obviously the first choice a designer must consider. Some of these choices are outside the remit of this paper, like clocking speed, internal architecture and memory levels that impact the overall design. Power level of the architecture is the key factor for the oscillator design that follows. The designer’s choice at this stage to use an ultra-low power processor will have a major impact later in the design of the oscillator loop. Many of the STM32 MCUs offer a variable drive level. These offer designers LSE oscillators with modifiable on-the-fly transconductance (dynamically) like the STM32L0 and others in this category. Other MCUs like STM32L1, or F4, are fixed drive levels, and may have less flexibility.
Table 1 – STM32MCUs
What overall considerations should a designer look at when choosing a crystal?
- Will the crystal meet design guidelines and operate as planned?
- Will the crystal oscillator meet the power drain needs of the application?
- Will the crystal size fit the applications needs; is it small enough, lower drive or AECQ200?
- Will the crystal meet the cost targets set by the design?
Spec parameters that impact SMT32 MCU crystal oscillator design |
|
|
Figure 1 – Oscillator Start-up |
Figure 1 shows a typical Vdd rise from 0V and how oscillator closed loop gain increases until unity gain is reached, and the oscillator loop stabilizes, locking onto the resonator frequency. The time from 0V to start-up of stable oscillation is shown a Start-up time. |
|
|
|
|
|
|
|
Figure 2 – Consideration for Drive level STM32 MCU |
|
|
Oscillator loop terminology explained |
|
|
Figure 3 – Shows a typical Pierce Oscillator loop and is common to STM32 MCU LSE crystal oscillators. |
Calculating Gain Margin
The calculation for Gain Margin: Gain Margin = gm / gmcrit This is where gm is the transconductance of the inverter stage in the MCU at the dedicated drive level and gm_crit = 4 x ESR x (2πF)2 x (C0 + CL)2. These are outlined in the STM32 AN2867.
The ECS Selection Tool has embedded these calculations to allow the user a convenient way to select the KHz crystal options to meet the needs of the LSE oscillator. All the crystals meet the gm_crit_max to attain the minimum GM (Gain Margin) of 5, however potential selections will offer even higher GM allowing the user to select different sizes, CL, ESR, Tolerance or Rating to meet application demands.
Calculating the External Capacitors for LSE oscillator |
|
Figure 3 – Pierce Oscillator Loop showing external capacitors |
The external capacitors are an integral part of the design of the oscillator loop. The total capacitance C1 // C2, Cs and Cin and Cout of the MCU all combine to a Total Capacitance. This needs to be the same as the Crystal CL for the frequency to be as near as possible to 32.768KHz. The following formula describes how to calculate CL: CL = ((Cin + C1) (C2 + Cout) + Cs) / (Cin + C1 + C2 + Cout) The formula includes the Cin and Cout of the MCU. The Cin is listed in the MCU data sheet, and Cout is normally approximately 2x the Cin. |
The lower the crystal CL, the more impact the Cs (Board Strays) has on the capacitor calculation. As mentioned in Section 4e iii, the low CL can be used in low drive applications, but lower CL has more pullability. When using this formula, it shows how the variability of the external capacitors or board stray capacitance will pull the frequency. When considering external capacitors use COG NPO 1% types to minimise the impact of capacitance change over temperature. |
Calculating the Drive level
The drive level is an important consideration; overdriving can lead to longer-term damage to the crystal, so the drive should be within the crystal drive rating found in the manufacturer’s specification.
The other less known impact comes from overdriving the sine wave, so that the sine peaks hit the supply rail. As this happens, the small signal loop gain can instantaneously drop to zero. The overall effect is the oscillator amplitude will stabilize when average gain over a cycle is one. The result of this gain averaging is harmonic distortion as seen in jitter of the output waveform.
- If calculating the drive level, I recommend the method taken from the STM32 drive level recommendation.
DL= I2QRMS × 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).
This will be in the uA range, so appropriate measurement equipment should be used. Therefore, the RMS voltage at this point is related to the RMS current by, IQRMS = 2 π F x VRMS x Ctot, where:
F = crystal frequency
VRMS = Vpp / 2√2, where Vpp is the peak-to-peak voltage measured at C1 level Ctot = C1 + (Cs / 2) + Cprobe where:
– C1 is the external load capacitance at the amplifier input
– Cs is the stray capacitance
– Cprobe is the probe capacitance
Therefore DL = (ESR x (π x F x Ctot)2 x (Vpp)2) / 2
Calculating External Rs value
If the drive level exceeds the crystal manufacturer’s recommendations, then two options are available to designers using the ECS Selection Tool:
- Look at crystal options with a lower actual gm_crit, this will improve the Gain Margin and lower drive current.
- Consider adding a Rs resistor. The role of the Rs resistor is to limit the drive current in the crystal.
- An initial estimation of Rs can be obtained by considering the voltage divider formed by Rs and C2. Thus, the value of Rs is equal to the reactance of C2. Therefore Rs = 1 / (2 π F C2),
- After picking the estimated Rs, then the Gain Margin needs to be recalculated but with Rs added to ESR
Gm_crit with Rs = 4 × (ESR + Rs) × (2 π F)2 × (C0 + CL)2
Gain Margin = gm / gmcrit with Rs
ECS Inc. has created an STM32 crystal selection tool that makes choosing the correct kHz or MHz crystal easier. This tool has been specifically designed for the range of STM32 MCUs and is updated daily. For questions about frequency control and STM32 MCUs, contact the engineering support team at engineering@ecsxtal.com.