Why do we use oscillators in microcontrollers?

The picture above is a hand crank music box, when you turn the hand rocker, you will hear beautiful music, as if coming from a miniature piano.

It works by cranking the steel drum by hand, and the drum body has small steel stakes protruding. Those little steel pegs that protrude hit a comb-like arrangement of metal teeth, each of which is a different length, causing different frequencies to vibrate to produce different notes.

Now, compare it to the microcontroller, the arrangement of instructions corresponds to the arrangement of the raised steel stakes on the steel drum; think of the metal teeth of the comb as the internal circuit of the microcontroller, if you don't turn the crank of your hand, nothing will happen . But when you turn the hand crank and the drum turns, you hear the music. When you stop, the music stops. At this time, the oscillator of the microcontroller is regarded as the hand that turns the hand crank.

As you probably already know, digital circuits work on high/low, on/off, 1/0 signals, and calculations/decisions made by "programs" also use 0s and 1s. Oscillators provide digital circuits with stable alternating beats of 0s and 1s, "turning" or "refreshing" digital circuits, interacting with the outside world through various sensors/actuators. However, this engine/machine does not perform this read/interaction/compute without manual cranking.

So the oscillator is the energy source that oscillates when the digital circuit works.

The oscillator is again the heart of the digital circuit, providing the circuit with "heartbeat pulse", the basic idea behind this is beat, output beat.

oscillator

There are many ways to generate "beats" for microcontrollers, and many microcontrollers offer many options. Here's a quick breakdown of the different types of "beat" generators:

External RC - This is typically used for *low cost* applications. Using a resistor and a capacitor, the circuit oscillates by charging and discharging the capacitor, generating pulses that can be used as clock inputs. I've never really used this type of clock.

Internal RC - Some MCUs usually come with an internal RC oscillator, which can be run without an external ceramic or quartz oscillator, which unfortunately has high environmental requirements, such as being sensitive to temperature changes. Can be used in applications that do not require high precision.

External oscillator - a quartz crystal ("crystal" for short) is connected to the two OSC pins of the MCU, and the code is executed at a given frequency. The current MCU use basically uses an external oscillator.

External resonator - is a typical passive device that requires peripheral circuits to drive its work and generate a clock output.

Most microcontrollers only need an external oscillator because they already contain all the other parts of the oscillator.

In general, we do not use internal RC for two reasons:

1. The internal RC oscillator is limited to a certain speed, so to get higher speed we need an external oscillator.

2. The noise of the internal RC oscillator is higher than that of the external oscillator.

The oscillator is a very important part of the system, I once had a problem with the crystal oscillator, shortly after the circuit started up and running, the microcontroller got stuck because the crystal oscillator didn't match the capacitors.

Guess you like

Origin blog.csdn.net/m0_67034740/article/details/124087878