The Good and the Bad of MCU Internal OscillatorsDecember 11, 2019 by Eduardo Corpeño
This article describes the benefits and requirements of the internal RC oscillator often available inside many low-cost Microcontroller units, including the calibration procedure to obtain the best possible accuracy.
Low-cost microcontroller units often come with an internal RC oscillator for you to use instead of an external ceramic or quartz crystal oscillator. However, you are expected to fine-tune this oscillator.
Chances are, your favorite MCU has an internal RC oscillator. There are numerous microcontroller families from all major manufacturers that include this module, including those from Texas Instruments, STMicroelectronics, and Microchip. There are also accompanying application notes online from virtually all manufacturers on how to calibrate the internal oscillator of their MCUs.
Using an internal oscillator has a number of benefits, and you may not really need an external crystal or ceramic oscillator. However, there are some critical applications that need very accurate timing like serial ports, timers, and USB interfaces. Even for most of these applications, an internal oscillator will likely live up to strict timing requirements if you fine-tune it.
Read on to learn about internal oscillators and an easy calibration procedure to get the best performance of your clock signals.
A GPIO application of the 9S08SH8 microcontroller, by NXP. Notice the absence of an external oscillator.
For more on MCU oscillators, you should read the article Choosing the Right Oscillator for Your Microcontroller by Robert Keim.
Benefits of Internal Oscillators
Internal oscillators are everywhere for a reason. Here are some of their benefits:
1. They require fewer external components. An external oscillator circuit or its feedback circuitry are no longer necessary. This has a positive impact on budgets, PCB area, and the overall size of your finished gadget.
2. They leave one or two pins available for I/O. Most MCUs with a low pin-count assign several functions to each pin for the user to choose its purpose. So if you choose to use the internal oscillator in your MCU, you’ll free up the clock input pin, or the two pins where a crystal or ceramic resonator would go.
DIP28 pinout of the ATmega328 MCU, the core of the Arduino Uno. Pins 9 and 10 are intended for a crystal resonator, and alternatively for GPIO pins PB6 and PB7, respectively. Image used courtesy of Mediaquark [CC BY-SA 4.0],
3. They keep high frequencies inside the IC. Although some microcontrollers employ a crystal or ceramic resonator at low frequencies under 100kHz, it’s much more common to use an external oscillator at or above 10MHz. This high clock frequency is almost always used exclusively by the CPU, and prescaled down inside the MCU for its peripheral modules (ADC, UART, SPI, USB, GPIO, etc.)
Having high frequencies outside the chip might be a problem in some PCBs, so keeping the high frequencies inside is usually a good idea.
The Drawbacks of Internal Oscillators
Internal oscillators are made of resistors and capacitors inside the integrated circuit. Producing these passive devices inside chips has its limitations, especially when it comes to accuracy and repeatability. This means that two identical microcontroller chips will likely show a meaningful difference in their internal oscillator frequencies, just like two identical guitars will play at slightly different pitches after being tuned at two different dinner parties.
For more on RC oscillators, you may want to read the article I wrote on Exactly How Schmitt Trigger Oscillators Work.
Aside from getting exactly the intended values of resistance and capacitance inside a chip (accuracy), and getting exactly the same values for all chips in a lot (repeatability), there’s the problem of temperature. It turns out that capacitance and resistance both experience slight changes with temperature, and this is particularly significant for internal oscillators. So, you don’t only have to worry about different chips working at slightly different frequencies, but also about their frequency changing with temperature.
If you don’t expect ambient temperature to change dramatically, you shouldn’t worry about your internal oscillator once you’ve calibrated it. However, if you expect significant temperature variations and your system is highly sensitive to frequency changes (like a real-time clock, or a high-speed communication system), then an external oscillator is a better option.
If RC oscillators are so bad, why don’t manufacturers embed a crystal or ceramic oscillator inside the MCU?
The IC manufacturing process is very limited in the list of materials that can be miniaturized, and as you may guess, quartz and ceramic are not on that list. So, although a hybrid approach is conceivable, it’s not practical.
RC oscillators aren’t really that bad. In fact, user guides for modern MCUs report internal oscillator frequency accuracies typically under ±10%, which can be fine-tuned to under ±0.5%. So the bottom line is that you will get away with a lot of applications if you don’t even bother fine-tuning the internal oscillator, and with most applications if you do.
Even though crystal and ceramic oscillators are highly reliable because of their accuracy and stability, RC oscillators are pretty good for many modest applications, and offer important benefits.
On the other hand, RC oscillators aren’t perfect, so you must always assess your application to be able to tell when to use the internal oscillator, and when you’re better off with a crystal or ceramic oscillator.
In a follow-up article titled Calibration of MCU Internal Oscillators, we’ll explore the calibration mechanism, a simple calibration procedure, and some examples of automated calibration. After that, we'll go over an example DIY trimming procedure algorithm to turn theory into practice.