EEVblog 1614 - Circuit Design TIP: Crystal Oscillators - Page 1
Forum section: electronics / general

author: EEVblog
author_rank: Unknown
timestamp: May 11, 2024, 01:06:59 am
content: You can easily replace any chip crystal circuit with a dedicated external crystal oscillator. Reducing your BOM count, and making your design easier, smaller, and potentially more robust.Cyber City Circuits:https://www.youtube.com/@cybercitycircuitshttps://twitter.com/MakeAugusta/status/1788651197055827992

author: westfw
author_rank: Super Contributor
timestamp: May 11, 2024, 08:19:02 am
content: One of the things I've noticed, if you're thinking of using an oscillator with a microcontroller, is that oscillators have pretty high current consumption, compared to modern microcontrollers. And it won't get shut off during the fancy low-power modes, either :-(

author: nali
author_rank: Frequent Contributor
timestamp: May 11, 2024, 08:29:03 am
content: What would be nice is something covering how to correctly calculate the loading caps for a MCU crystal. I don't think it's uncommon to think I have a 12pF xtal so I'll use 12pF capacitors, or tha app note shows 22pF caps so I need a 22pF xtal etc.For a lot of MCUs it's close-ish and Just Works, though for radio MCUs (WiFi Bluetooth etc) it can make a difference.

author: langwadt
author_rank: Super Contributor
timestamp: May 11, 2024, 11:23:56 am
content: I'm pretty certain that I've seen some datasheets that tell you to feed an external clock into X2

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 11, 2024, 09:49:51 pm
content: Yep; the i.MX RT1060 Processor Reference Manual (as used in Teensy 4.x) describes three different ways of replacing the 24MHz crystal with an external source, with the suggested one being driving XTALI at nominal 1.1V and leaving XTALO externally floating. (The other two are overdriving both differentially, or overdriving XTALO and capacitively loading XTALI, which also happen to work because it uses a differential amplifier to detect oscillation internally.)Even old ATmega32U4 (older AVR) datasheet explicitly mentions that you can leave XTAL2 floating and drive XTAL1 with a clock source (with less than 2% variation between consecutive clock cycle durations), although the CLKSEL fuses need to be programmed to a dedicated value (0000) in that case.I too would prefer good advice on calculating/choosing proper loading caps, though.

author: Kleinstein
author_rank: Super Contributor
timestamp: May 12, 2024, 05:18:06 am
content: The AVRs have extra fuse settings for external clock and crystal only. However the µC also works with the setting for just the crystal and using the external clock. An external cock is a typical method to recover a chip with somehow wrong fuse settings for the clock.For the AVRs in 32 kHz mode, the is a common errata that effects most (if not all of them): at least the older version supposedly had optional internal capacitors to activate, but these usually don't work.The load capacitors for the crystals are not that obvious. The value given in the datasheet is usually the one effectively parallel to the cystall and the 2 caps in the circuit are effectively in series for the RF part. So if the datasheet calls for 10 pF one would want 2 x 20 pF. In addition there is some parasitic capacitance from the PCB and the oscillator itself. So the suitable cap size is something like 2 x load cap specs minus some 2-3 pF.The small size oscillator chips are usually only for 3.3 V , but rarely for 5 V supply. The older style large cans are for 5 V, but they tend to use quite some power and obvous space. This may be more than a lower power µC needs.A positive side of an external oscillator is that they are better shielded. Just the crystal at a µC can be effected by ground bounce, neighboring pins and µC internal signals - it is not a super stable clock.

author: Dr. Frank
author_rank: Super Contributor
timestamp: May 12, 2024, 06:41:35 pm
content: Copying my comment from YT:For stable and safe operation of an XTAL oscillator, especially in a mass production and in a wider environmental temperature range, those standard 10, 20pF capacitors are undesirable, especially when built in a (digital type) oscillator circuit."Analogue oscillators" are preferable, but digital design engineers usually don't have that knowledge any more. It's too costly, as well, to mix analogue and digital on a chip.We usually send our new oscillator circuits (inside an embedded controller) to our XTAL manufacturers, like NDK, Kyocera, murata, former Tele Quartz, now AXTAL, etc., requesting a specific center frequency and XTAL type / case.They then determine their manufacturing parameters (cutting, trimming, blank type) and determine the optimum C1, C2 values, including layout pattern. That gives optimum start-up time and best "oscillation margin". C1, C2 should always be external.Please search for documentation on "XTAL oscillation margin" for more details, as well, how one can measure these parameters on his own.Attached are a few nice photos of a fused silica / quartz bar, 20cm x 2cm, artificially drawn in an autoclave.The crystal blanks are cut out of such bars.Frankhttps://www.ndk.com/en/products/crystal/ultimate/

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 12, 2024, 10:32:22 pm
content: Quote from: nali on May 11, 2024, 08:29:03 amThe problem is that when just a few pF of difference matter in some specific application (which is rarely the case for "MCU oscillators", but could be in some other cases), parasitic capacitance from a variety of sources (from the PCB to even the relative humidity, to component packages, capacitor tolerance and trace length...) will matter and if you can't take these into account, you can calculate to your heart's content, it won't get you very far. You may need expensive simulation tools with the knowledge to use them.

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 12, 2024, 10:50:33 pm
content: Quote from: westfw on May 11, 2024, 08:19:02 amYep. That's two points making it a good reason to avoid using external oscillators if low-power is a concern.

author: westfw
author_rank: Super Contributor
timestamp: May 13, 2024, 06:35:28 am
content: QuoteIs determining the "correct" capacitance(s) for an external crystal feasible for an amateur with cheap equipment? Even if you carefully follow instructions, you usually hit a spot that reads "now make a wild guess at the stray capacitance of your chip packages and PCB."Sure, I guess I could connect a frequency counter (or scope with freq counting ability) to some clocked pin and try "tuning" the crystals, but having a freq counter that is more accurate than the crystal is supposed to be seems ... somewhat unlikely.

author: EEVblog
author_rank: Unknown
timestamp: May 13, 2024, 08:18:12 am
content: Quote from: westfw on May 13, 2024, 06:35:28 amMost people and projects don't care about the absolute frequency of the crystal, if you did you generally be using a high precision TCXO or at the very least have an adjustable cap to trim it manually.So as long as your oscillator isn't completely chucking a wobbly, you'll be fine with just the typical datasheet example values.

author: EEVblog
author_rank: Unknown
timestamp: May 13, 2024, 08:21:05 am
content: Quote from: langwadt on May 11, 2024, 11:23:56 amSome chips might tri-state the internal inverter output, otherwise that's not going to work unless X2 is the input.

author: Dr. Frank
author_rank: Super Contributor
timestamp: May 13, 2024, 10:10:33 am
content: Quote from: westfw on May 13, 2024, 06:35:28 amIt's easy to determine the "oscillation margin" on your own, see e.g. description and YT videos by murata.If this O.M. is > 3 the chosen capacitors in conjunction with the given inverter work reasonable safe for commercial applications with low requirements.That means, your choice of C1, C2 is "correct".For Automotive application, i.e. more demanding requirements, you need an O.M. > 10.You need to know the ESR of the XTAL from the datasheet to calculate this O.M.Serious suppliers like NDK will have this already, others won't have it, so you would need access to an Impedance / Gain Phase Analyser, like the old HP 4194A (see HP AN 339-9).Otherwise, you have to make some trial-and-error approaches to change C1,C2 until you achieve O.M. >3, >10.I don't remember how NDK did the job, and which equipment they use. I guess they have an S-parameter analyzer for that and a dedicated test setup.Edit: One important criterion was, to limit the power dissipation for the XTAL to <1mW, even for those simple inverter oscillators, by e.g. adding a serial resistor.Frank

author: langwadt
author_rank: Super Contributor
timestamp: May 13, 2024, 11:37:31 am
content: Quote from: EEVblog on May 13, 2024, 08:21:05 amdepends on how wimpy the X2 output driver is

author: RLP
author_rank: Contributor
timestamp: May 14, 2024, 08:26:02 am
content: I once had a WiFi router which would connect to some ethernet devices at gigabit, some at 100Mbps, and some not at all. Amazon, who I bought it from, refunded me but didn't ask for it back (they'd have just binned it anyway after all). Years later, I opened it up, and found a missing load capacitor on an internal crystal, which was presumably throwing off the timing of the ethernet signals. I bodged on a through hole cap of approximately 20pF as a guess, in place of the missing 0402 SMD part, and it's worked perfectly sinceone would think the inductance of the long leads might be a problem but. These things seem forgiving until you need precision, I guess.

author: shapirus
author_rank: Super Contributor
timestamp: May 14, 2024, 08:47:39 am
content: Quote from: RLP on May 14, 2024, 08:26:02 amYeah, it works fine even on a test board like this, at least up to 16 MHz:There's apparently a lot of tolerance margin.

author: jnissen
author_rank: Regular Contributor
timestamp: May 14, 2024, 03:13:11 pm
content: Reminds me of the XTAL oscillator I designed into a implantable medical instrument. Extremely low crystal speeds were required to provide both stability and low power. The issue in this case was not only calculating the proper capacitance to hang off the crystal but how much gain to put into the amplifier driving the thing. Thankfully there are some fairly good crystal oscillator simulation settings in Cadence Virtuoso to help out a designer. Wasn't always the case. In the above situation we calculated that a startup and stable operation could take as long as 2 seconds. This is an eternity in simulation land and running all possible corners was problematic with limited compute resources. I had to old school it and shotgun the worst case corners and rely upon some analytical techniques of the data to fill in the gaps.Once the silicon got back we tested a variety of crystals across the IC and the startup behavior matched almost identically. If we sized the load caps incorrectly we could get situations where the startup failed to occur at all or took in excess of a few seconds. Obviously not a good situation if this happened in the OR and a persons body is open and ready to implant the thing! Needless to say we tested this thing every which way possible and across every split of silicon we could get from the FAB. IN our final design review with the customer they were extremely pleased as the prior art would often have chaotic startup and inconsistent power numbers. Bottom line there is a lot of engineering that goes into the crystal amplifier circuit for specialized crystal operation.

author: NaDobraNich
author_rank: Regular Contributor
timestamp: May 15, 2024, 04:28:47 pm
content: I do like little circuit tips like this.Questions though,1. What would I do if X1 and X2 aren't the labels? I have a module with an mcu on it, it wants OSC-IN and OSC-OUT. I assume based on this guide that OSC-IN, I would connect to my clock's output, seems reasonable. And what about MCU OSC-OUT? Just leave it floating?2. If I have the RTC / 32khz clock next to my main micro, and I want to get this output to my module that is 15mm away. Is there any serious concerns here? Impedance match? Keep on the top layer microstrip or move to a stripline even though its going to have two vias? There is a bluetooth radio on board so I am included to use a stripline.3. Can I just tap off the OSC-OUT on my oscillator? I guess I could use a CLOCK-OUT signal from my micro to the module, but then I'm not sure I would have that in all power modes and conditions of my MCU. How would I go about figuring out what two micros need to be run off the same clock?

author: thm_w
author_rank: Super Contributor
timestamp: May 15, 2024, 09:02:05 pm
content: Quote from: NaDobraNich on May 15, 2024, 04:28:47 pmYes, in is input, out is output left floating, I'm sure its in the datasheet.QuoteIts 32kHz, you don't need a transmission line.Question is if the signal will be loaded too much, or noise injected, timing acceptable, which is up to you to verify. Probably not worth the 3 cents you would save.QuoteAgain loading etc which is mentioned in the video. Using clock out means its buffered and you don't have to worry much about loading.

author: NaDobraNich
author_rank: Regular Contributor
timestamp: May 16, 2024, 10:43:05 pm
content: Quote from: thm_w on May 15, 2024, 09:02:05 pmI don't get it?? You aren't suggesting that adding another time source for that module would be 3 cents right? It costs me more than 3 cents to pick and place any part. What is 3 cents?

author: thm_w
author_rank: Super Contributor
timestamp: May 16, 2024, 11:04:07 pm
content: Quote from: NaDobraNich on May 16, 2024, 10:43:05 pm3.5 cents:https://www.lcsc.com/product-detail/Crystals_huaxindianzi-DP2032K76812001_C17702403.html

author: EEVblog
author_rank: Unknown
timestamp: May 17, 2024, 03:47:58 am
content: Quote from: thm_w on May 16, 2024, 11:04:07 pmYou can get a microcontroller for 3 cents:How about a 1 cent regulator