Jotrin Electronics
Description Quantity Total (USD) Operation
Shopping cart products
Shopping cart products : 0
Home > Control / MCU > What is the relationship between a microcontroller and a crystal oscil

What is the relationship between a microcontroller and a crystal oscillator?

Published time: 2020-02-21 12:42:49

When beginning to learn a single-chip microcomputer, there are always many questions about the crystal oscillator. In fact, the crystal oscillator is like the heart of a person, it is the pulse of blood. The problem of the single-chip crystal oscillator is understood, and other problems of the 51 single-chip microcomputer are solved ...


What is a crystal

A crystal oscillator is generally called a crystal resonator. It is a kind of electromechanical device. It is made of quartz crystal with very little electrical loss after precision cutting and grinding, and is plated with electrodes and welded with leads.

Crystal oscillator, full name is quartz crystal oscillator, is a kind of oscillator with high precision and high stability. Through a certain external circuit, a sine wave with stable frequency and peak value can be generated. When the single-chip microcomputer is running, it needs a pulse signal as a trigger signal for executing instructions by itself. It can be simply imagined that the single-chip microcomputer receives one pulse and executes one or more instructions.

A crystal oscillator is very important for a single-chip microcomputer. It can be said that there is no clock cycle without a crystal oscillator, and program code cannot be executed without a clock cycle. In that case, the single-chip microcomputer cannot work.

Crystal Oscillator and MCU Period

When the single-chip microcomputer works, it fetches instructions from RoM one by one and then executes them step by step. The time it takes for a microcontroller to access a memory is called a machine cycle, which is a time reference. One machine cycle includes 12 clock cycles. If a single-chip microcomputer selects a 12MHZ crystal oscillator, its clock cycle is 1 / 12us, which is also a crystal oscillator cycle. Its one machine cycle is 12 × (1/12) us, which is 1us.

The machine cycle is not only of great significance to the execution of instructions, but the machine cycle is also the time reference for the timers and counters of the microcontroller. For example, a single-chip microcomputer selects a 12MHZ crystal oscillator. When the timer value is increased by 1, the actual elapsed time is 1us, which is the timing principle of the single-chip microcomputer.

The role of a single-chip crystal

The function of the one-chip computer crystal oscillator is to provide the basic clock signal for the system. Normally, one crystal is shared by one system, so that the parts can be synchronized. Some communication systems use different crystals for the fundamental and radio frequencies, and electronically adjust the frequency to maintain synchronization.

Crystals are often used in conjunction with phase-locked loop circuits to provide the clock frequency required by the system. If different subsystems require clock signals of different frequencies, they can be provided by different phase-locked loops connected to the same crystal.

Under normal operating conditions, the absolute accuracy of ordinary crystal frequencies can reach 50 parts per million. Advanced accuracy is higher. Some crystals can also adjust the frequency within a certain range by an applied voltage, which is called a voltage controlled oscillator (VCO). The crystal oscillator works with a crystal that can convert electrical energy and mechanical energy into each other to provide stable and accurate single frequency oscillation.

Instruction cycle

The instruction cycle is the time required to execute an instruction, and generally consists of several machine cycles. The number of machine cycles required varies with instructions. For some simple single-byte instructions, in the instruction fetch cycle, after the instruction is fetched to the instruction register, it is decoded and executed immediately, no other machine cycles are required. For some more complex instructions, such as branch instructions and multiplication instructions, two or more machine cycles are required. Usually contains one

Machine cycle instructions are called single cycle instructions, and instructions containing two machine cycles are called double cycle instructions. Simply put, without a crystal oscillator, there is no clock cycle, without a clock cycle, the program code cannot be executed, and the microcontroller cannot work.

The machine cycle is not only of great significance for instruction execution, but also the machine benchmark is the time reference for the timer and counter of the microcontroller. For example, if a single-chip microcomputer selects a 12 MHz crystal oscillator, then when the timer value is increased by 1, the actual elapsed time is 1us, which is the timing principle of the single-chip microcomputer.

The crystal oscillator provides working signal pulses for the microcontroller. This pulse is the working speed of the microcontroller. For example, 12 trillion crystal oscillator. The operating speed of the single-chip microcomputer is 12 trillion per second. There is also a crystal inside the microcontroller. The external crystal can be connected to a more stable frequency.

In addition, I would like to mention here: the crystal is not the same as the crystal.

The difference between a crystal and a crystal

1) Crystal is the abbreviation of active crystal, also called oscillator. The English name is oscillator. Crystal is the abbreviation of passive crystal oscillator, also called resonator. The English name is crystal.

2) Passive crystal (crystal) is generally a non-polar component that is directly inserted into two pins. It needs a clock circuit to generate an oscillating signal. Common 49U, 49S packages.

3) The active crystal (crystal oscillator) is generally a surface-mounted package with four pins. There is a clock circuit inside, which can generate an oscillating signal just by supplying power. Generally divided into 7050, 5032, 3225, 2520 several packaging forms.

When designing a microcontroller, it is also important to choose the right crystal. Generally, some margin should be set aside when selecting a device to ensure the reliability of the product. Selecting a higher-grade device can further reduce the probability of failure and bring potential benefits, which must also be considered when comparing product prices. In order to make the "overall performance" of the oscillator balanced and reasonable, it needs to weigh factors such as stability, operating temperature range, crystal aging effect, phase noise, and cost. The cost here includes not only the price of the device. It also includes the cost of using the product over its entire life.



Account Center

Points Mall


Live Chat

Product comparison

(Supporting the comparison of similar products)
Compare Clear