First of all, one of the necessary conditions for a single-chip microcomputer to work normally is the clock circuit, so the single-chip microcomputer needs crystal oscillator very much.
Crystal oscillator, full name is quartz crystal oscillator, is a kind of oscillator with high precision and stability. Through a certain external circuit, it can generate sine wave with stable frequency and peak value. When the single chip microcomputer is running, it needs a pulse signal as the trigger signal of its own execution instructions. It can be simply imagined as follows: when the single chip microcomputer receives a pulse, it will execute one or more instructions.。
Why does singlechip need crystal oscillator
When the single chip microcomputer works, it takes instructions from the ROM one by one, and then executes them step by step. The time when a single chip computer accesses a memory is called a machine cycle, which is a time benchmark. A machine cycle includes 12 clock cycles. If a single chip computer chooses 12 MHz crystal oscillator, its clock period is 1 / 12us, and its machine period is 12 × (1 / 12) us, that is 1US.
Among all the instructions of MCS-51 single-chip microcomputer, some of them are completed relatively fast, as long as one machine cycle is enough, and some of them are completed relatively quickly, which requires two machine cycles and two instructions require four machine cycles. In order to measure the execution time of instructions, a new concept, instruction cycle, is introduced. The so-called instruction cycle refers to the time when an instruction is executed. For example, when it is necessary to calculate the time required for djnz instruction to complete, the frequency of crystal oscillator must be known first. If the crystal oscillator used is 12V Hz, then a machine cycle is 1US. The djnz instruction is a two cycle instruction, so it executes 2us once. If the instruction needs to be executed 500 times, exactly 1000 US, that is, 1 ms.
Machine cycle is not only of great significance for instruction execution, but also the time benchmark of timer and counter. For example, if a single-chip microcomputer chooses 12 MHz 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.
Crystal oscillator provides working signal pulse for MCU. This pulse is the working speed of the single chip microcomputer. For example, 12 trillion crystal oscillator. The speed of single chip microcomputer is 12 megabits per second. There are crystal oscillator in the single chip microcomputer. With external crystal oscillator, the frequency can be more stable.