External Oscillators; Placement and Routing Trade-offs
Does Changing the Clock Make any Difference to the PCB Layout?
Every six months, it becomes apparent that not enough of my household things are part of the “Internet Of Things”. <cue ominous violin squeals> Can we talk about my spouse's wall-clock fetish? At least, the one in the bedroom is the kind that doesn’t tick! And, of course, if a battery is near its end, an adjustment will probably put it out of business for good. It’s always something to put me back up on that step ladder. Setting and resetting clocks is also a thing in PCB design.
Keep the Working Circuits Intact
The engineers on the analog side of the coin get very attached to a circuit that works. If something is working with sufficient margin, then don’t even get near it with “arbitrary and capricious” revisions. Tread lightly in those situations as there are many ways for things to go haywire. Consider the crystal as a hostile device from the start. That way, if it should have to grow, the other geometry already leans away from the danger zone.
Figure 1. Image Credit: Author - The ground pour (green) surrounds the crystal but does not engage with the ground pins. The ground plane on layer 2 is similarly slotted around the crystal in order to help contain spurious emissions.
The main source of frustration during RF chip/board bring-up is out-of-band emissions. Some odd-order harmonic can end up exceeding the mask. There will be an unwanted spike or lump in the graph. Bandpass filters have their limits and cost money while using power. The analog engineers spend nights and weekends in their passion to solve these issues. They thrive on tweaking circuits and taking measurements.
A subtle tuning stub or an inductive neck-down on the power feed can be all it takes to solve the issue. But, now you’ve changed the little world around you and anything can happen. Radio frequencies are everywhere to be picked up and propagated. Making one strong sine wave without disturbing the spectrum in other ways is a tough assignment. We have good reason to venerate a fully compliant link in the chain.
External Oscillators - An Alarming Clock
The cautionary tale is this: digital circuits above a certain data rate will start to resemble analog circuits. Most MCUs have an option for an external oscillator. What is that? It’s usually a way to override the system clock and impose a different cycle time on the system. Why do so? In general, overclocking increases performance while underclocking saves power. Some are just for boot-up, others are only active when certain functions are in use. The thing is that when it is on, the string on ones and zeros is non-stop clatter to the rest of the circuitry.
Figure 2. Image Credit: Author - It would have been cleaner to rotate Y1 and align the passive elements. We compromised a little to fit inside the EMI shield.
The net-names associated with these clocks will typically include the letters, “XO”. Popular frequencies for these crystals are in the kilohertz range. Each of those available frequencies will have their own harmonics (and its own package size!).
So maybe you start at 16KHz as the external clock. That’s actually in the upper audible range but, of course, the vibration of the crystal is imperceptible without measuring equipment. Still, byproducts of 16KHz include 32KHz, 48K, 64K, 80K, 96K, 1.12MHz and so on.
Less is More – Keep the Crystal Circuit Short and Free of Vias.
It’s mostly on every other node but there are a lot of intersections where 16KHz has common multiples with other frequencies found in nature. A strong resonance will be a detriment to the circuit, particularly when it comes to coexistence. A compact XO circuit is a must but you can’t always get what you want.
Figure 3. Image Credit: SoundGuys: - A fundamental frequency showing sympathetic wavelengths that are often generated along with the original.
One of the worst scenarios is when there are XO pins located deep inside the rings of pins of a BGA. Usually, this is found in a small enclosure where there isn’t sufficient space on the bottom of the PCB for tall components. This means that the XO traces are going to be longer than usual. A typical example is the power management integrated circuit (PMIC) where all of the perimeter pins seem to be voltage in or out.
The crystal might be on the opposite side of the board but just as likely off in a corner on the side of the board that has the headroom. Make it the corner away from the receive chain. The TX side isn’t great either but usually less of a victim than the RX side if it's one or the other. Look for a neutral corner with the least amount of signal traffic.
Figure 4. Image Credit: Author - The vertical trace on the left (magenta) and the horizontal continuation (cyan) show how to create a guard-band around particularly noisy connections that are used by externally clocked devices.
Routing the external oscillator lines out from under a device like that should be done as one of the first things. If you have any freedom in the fan-out, a wide path should be carved out for these traces. There is always one row on a BGA where vias can fan in different directions. That row is often around the center line but it doesn’t have to be.
Other signals in the region ought to go on other layers, allocating as much extra space as possible to the clock nets. If you can create a guard band around the noisiest signals, then you can call it good. We always want an optimal placement that allows no-brainer routing. We can’t always get what we want. Then, we do what we must to get by.