You are currently viewing Crystal oscillator for your digital ICs

Crystal oscillator for your digital ICs

Just as a stable voltage source is necessary for any analogue circuit to work properly, a clock is required for any digital circuit to appropriate shift from one state to the next. In this short article, we will look into the design of an oscillator circuit to give your circuit’s MCU or any other digital IC the necessary clock to perform its functions.

But hang on a second, I thought MCUs already have an internal oscillator so why do I need another one?

That’s correct. Some MCUs like the PIC16F722 already have an internal oscillator and other MCUs only require an external crystal, two capacitors and one resistor to create the necessary oscillator circuit:pic_osc

Then, why would I need to design my own oscillator? You don’t unless you have more than one digital circuit running off two different oscillators. In one of my previous projects, I was sending samples from the MCU to a DAC via I2S protocol. The MCU was running off a 16MHz crystal using the internal oscillator while the DAC from a 12.288MHz external oscillator. I remember I was testing the audio quality and something wasn’t right, there seemed to be a lot of popping noise happening, so I played a low-frequency sine wave and got the oscilloscope out to measure it and this is how it looked like:

poping

pcb_osc

Not knowing what could cause this issue, I decided to run both the MCU and DAC from the same clock which instantly fixed the popping noises.

Lesson learned: when running two time sensitive asynchronous circuits that communicate each other make sure they follow the same clock or a synchronous mechanism is implemented. Note that the issue here wasn’t the different frequencies but the synchronization between both circuits timing wise.

Circuit from my project with calculations and components

Before placing a circuit in your board please note that some MCUs let you use one pin as a clock output, therefore you can use your MCU oscillator to drive the other IC and no extra components are required. However, in my design, the pin was located in an inconvenient area that required me to draw a long PCB trace cutting other signals. When routing high-speed signals such as this, it is better to have the source close to the receiving end and only have a GND plane below them for the returning currents and to avoid vias as they can act as antennas.

The circuit used was a Pierce Oscillator, this circuit consists in the use of one crystal, two caps, two resistors and a double unbuffered inverter:

osc_circuit

Design tips:

  1. C47 and C52 need to be calculated using the load capacitance value given in the crystal’s datasheet and the stray capacitance created by the PCB: C47 = C52 = 2*CL – 2*Cs, where Cs is roughly 5pF (this last value can vary depending on the layout)
  2. Adding a 10nF cap in parallel to C53 could be a good idea if higher frequencies are required from your oscillator
  3. For the inverter use an unbuffered type such as the NL27WZU04. An unbuffered inverter is required to avoid loading the crystal and reduce the propagation delay
  4. R71 is required to dampen the signal and match the impedance between the source and the receiver. A smaller resistor between 22R and 56R is recommended for the 2-16MHz frequency range.

If you want to learn more about the theory behind this circuit I recommend checking out these websites and references I used:

Pierce Oscillators

Crystals

Choosing the right capacitors for your crystal

Caps and frequencies that filter

F. Zlotnick, “Designing Crystal Oscillators with Modern CMOS Gates,” On Semiconductor

Roberto Weiser

Roberto has experience in electronic embedded systems design and programming from concept to production, including: power electronics, audio electronics, automotive, battery management systems and renewable energies control systems. Roberto is interested in technology and sustainability of which he has practical experience acquired in his University degree, Master's, external courses, placement and also from volunteering in Peru. Furthermore Roberto has skills for business, leadership and teamwork from his time as Chairman of the Latinos and Spanish Society and Resident DJ in Plymouth

Leave a Reply