How do you go about choosing an external oscillator for a microcontroller, given the frequency you want? What's the difference between just a crystal (https://www.digikey.com/en/products/detail/suntsu-electronics-inc/SXTHM212AA164-16-000MT/12264644) and an oscillator (https://www.digikey.com/en/products/detail/suntsu-electronics-inc/SXO53C3A161-16-000M/12163949)? Why does the oscillator need a supply voltage? Most of the circuits I've seen that use straight crystals also have some capacitors connected to them, what are these for and how do you select their values?

  • \$\begingroup\$ A Xtal for those who understand how to use it when they need accuracy, an oscillator with a crystal is cheap and will be more accurate if you appreciate ppm \$\endgroup\$ – Tony Stewart EE75 May 10 at 1:07
  • \$\begingroup\$ You read the electrical characteristics int he datasheet for the minimum and maximum oscillator or crystal frequency the MCU will accept (not always the same for both), and read what the PLL settings are in the manual. \$\endgroup\$ – DKNguyen May 10 at 1:09
  • \$\begingroup\$ If you'd read the datasheets for both the parts you're asking about, as well as that for your microcontroller, you'd know the answer here. Every microcontroller datasheet I've ever seen explains the difference and offers recommended circuits and capacitance values right there in the manual. \$\endgroup\$ – TomServo May 10 at 20:41
  • \$\begingroup\$ @TomServo I can't find that information, can you? ww1.microchip.com/downloads/en/DeviceDoc/… \$\endgroup\$ – kefffin May 10 at 23:12


A crystal is nothing more than a resonant piece of piezoelectric crystalline material, bonded to pins such that it has a resonant electrical behavior. It is a passive device which cannot oscillate on its own -- it does not have an input or an output pin. It's simply a passive blob of quartz or other material which has a particular impedance curve that looks resonant at particular frequencies.

It's combined with an active circuit onboard the microcontroller, which provides some gain to excitations at the crystal's resonant frequency, ultimately generating an oscillation. The microcontroller's power supply provides energy to the oscillation mechanism, by powering the active circuit providing gain.

An example combination of a crystal and a gain element is the Pierce oscillator topology, where the MOS inverter is provided by the microcontroller (e.g. between the XTAL1/XTAL2 pins), and the capacitors+crystal are provided by the board designer and attached to chip pins.

One way to estimate the necessary capacitors of such a topology is to partition the system into the crystal, modeled as a lossy RLC circuit, and the amplifier itself. The capacitors and gain element (e.g. MOSFET) onboard the chip together create an amplifier that presents a negative small-signal impedance at AC, which must be attached parallel to the crystal.1

By performing AC circuit analysis, the necessary values of the capacitors can be related to the performance of the gain element and the loss of the crystal. In the case of the Pierce oscillator, for a given transistor performance, there is a minimum value for the two capacitors. Run too close to the minimum and your circuit may not oscillate (at all, or intermittently depending on temperature and environment); run too large and the capacitors load the crystal, pull its frequency off its resonance, and reduce the quality-factor (increasing noise + decreasing performance).

As an example of the derivation, the following MOS structure is a suitable gain element for a Pierce oscillator (reproduced from slides I prepared for my masters thesis work). M1, M2, and Rf are typically part of the microcontroller, and the board designer provides CA, CB, and the crystal:

enter image description here

It can be shown2 that its input impedance at a high frequency \$\omega\$ is given by:

$$Z_{\text{in}} = \frac{1}{j\omega C_1} + \frac{1}{j\omega C_2} - \frac{g_m}{C_A C_B \omega^2}$$

where \$C_1\$ and \$C_2\$ are the equivalent series and parallel capacitances in the model of the crystal itself.

\$C_A\$ and \$C_B\$ are the two capacitors you add to the amplifier -- they must be large enough such that the term \$\frac{g_m}{C_A C_B \omega^2}\$ dominates and is enough to overpower the crystal's loss.

Of course, this is really annoying and math-heavy. Chip designers want to sell their chips, and crystal sellers want to sell their crystals, without making the user muck about with MOSFET transconductances and negative impedances. You're likely to find simpler formulae or lookup tables that suggest capacitor values in the datasheets and/or application notes of the parts themselves.


An oscillator is an active circuit; this means that it will need a power supply to power its onboard circuitry.

In the common standalone oscillators you'll see sold online, the active circuit encompasses a resonant element (e.g. a quartz crystal, MEMS device, TF-BAR, SAW resonator, etc) and a gain structure that's engineered to work well with that particular resonator (e.g. a Pierce oscillator's amplifier much as before, a differential Colpitts oscillator, etc). These are integrated into one integrated circuit package, and the output clock signal is sent out of a single output pin (or two differential pins in some high performance systems).

This is a simpler solution for the board designer; the complex circuit analysis is done by the oscillator manufacturer. All you need to do is ensure that the oscillator can drive the correct voltage swing and output current, that you've provided the right voltage+decoupling capacitor as stated in the datasheet, and that you're not exceeding environmental conditions (temperature, vibration, etc).

It's worth noting further that not every oscillator is based on a crystal or MEMS resonator. Some use electrical inductors and capacitors (e.g. LC cross-coupled oscillator), and some just use delays (e.g. ring oscillator, Xilinx digital clock manager delay-line loop) or even voltage-controlled variants of the above (e.g. voltage-controlled oscillator as found in a PLL)


1: It's possible to analyze the circuit as a feedback amplifier and apply Barkhausen's criterion for oscillation. I prefer the equivalent impedance at resonance approach as I personally find it a tad more intuitive.

2: Section 13.6 of B. Razavi, Fundamentals of Microelectronics, 2nd ed. Prentice Hall, 2012 -- applies to both the answer as a whole and this derivation in particular.

  • 6
    \$\begingroup\$ A lazy but effective trick to avoid the analysis: get the schematic of the development board the microcontroller maker sells, and copy their choice. \$\endgroup\$ – John Doty May 10 at 11:43
  • \$\begingroup\$ @JohnDoty: You also have to match the trace length, thickness and PCB material. \$\endgroup\$ – Michael May 10 at 11:49
  • 7
    \$\begingroup\$ @Michael That's usually a small effect in a practical circuit. Dev boards don't usually push the edges of the envelope. Just keep traces short. \$\endgroup\$ – John Doty May 10 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.