
Using crystal circuit to generate clock pulse for the chip, I'm using a technique called Schmitt- Triggered inverter. So the if the input of the inverter goes low and therefore the output goes high. And the transition is very sharp contain many different frequency harmonics but only the one with the same frequency as the crystal will pass through. So the Schmitt-Triggered inverter compares the input signal with two thresholds instead of one as in simple inverters or gate. Therefore, the input has to be higher than one threshold for the output to change and lower than the other one for the output to change back. As shown in figure below when there is a low on the input of the inverter and a high at its output, the capacitor on the input of the inverter is charged through the feedback resistor. When the capacitor is charged high enough that the input voltage of the inverter passes the higher threshold then its output drops to zero. Then the capacitor will start discharging through the same resistor and when its voltage drops below the lower threshold of the inverter and its output jumps up again and this will happen continuously and resulting in a square wave. The oscillating frequency of this circuit depends on how fast the capacitor charges and discharges and therefore is a factor of the resistance and capacitance value, while it is also dependent on the threshold levels. Below is the circuit that used 2 MHz crystal to generate master clock for the chip. The biggest problem for this circuit is that the oscillating frequency is not stable so I had to find the best combination of the resistor and capacitor to make it stable. So we get the clock frequency that we desire for the master clock.