The clock circuit is an oscillator that provides a rhythm for the microcontroller. The microcontroller must operate under this rhythm to perform various tasks. Therefore, the microcontroller will not function properly without a clock circuit. The clock circuit itself does not control anything; rather, it is the program that allows the microcontroller to perform corresponding tasks based on the clock.
In the MCS-51 microcontroller, there is a high-gain inverting amplifier. The input terminal of the inverting amplifier is XTAL1, and the output terminal is XTAL2. The oscillation circuit formed by this amplifier and the clock circuit together constitute the clocking method of the microcontroller. Depending on the hardware circuit, the clock connection method of the microcontroller can be divided into internal clock mode and external clock mode, as shown in Figure 1.

(a) Internal clock circuit (b) External clock circuit
Figure 1 Clock Circuit
Internal clock schematic (which is a self-excited oscillation circuit)
In the internal clock circuit mode, a quartz crystal oscillator and two trimming capacitors must be connected across the XTAL1 and XTAL2 pins to form the oscillation circuit. Typically, C1 and C2 are taken as 30pF, and the frequency of the crystal oscillator is selected between 1.2MHz and 12MHz. For the external clock circuit, XTAL1 must be grounded, and the XTAL2 pin is connected to the external clock. There are no special requirements for the external clock signal, as long as a certain pulse width is ensured, and the clock frequency is below 12MHz.
The oscillation signal from the crystal oscillator is sent from the XTAL2 terminal into the internal clock circuit, where it is divided by two to generate two-phase clock signals P1 and P2 for the microcontroller. The period of the clock signal is called the state time S, which is twice the oscillation period. The P1 signal is effective during the first half of each state, while the P2 signal is effective during the second half of each state. The CPU coordinates the effective operation of various parts of the microcontroller based on the two-phase clock P1 and P2.
(Source: Electronic Engineering Magazine)

Editor of this issue: SUN
Editor-in-Chief: Electronic Department Student Media Office

