Choosing a Crystal for a Microcontroller

I'm always amazed at the number of people who think this is so damned difficult to pick two caps, that you should buy a canned oscillator..

The crystal will probably "run" with any reasonable value of cap, somewhere close to it's loading spec. Indeed, most people seem to pick caps that are about half what they should be, yet they still "run".

In order to do it right though, you need to estimate your parasitics, (5pF-ish?) then double the loading spec, and subtract the parasitics. Populate with that, and check oscillation. I use a good shortwave receiver, as it does not load the circuit at all. Of course you can do a timing loop and attach a freq counter there, or whatever else works for the equipment you have.

Of course nobody would use a series crystal in a parallel circuit, you'd never be able to get it to sing the right tune! :)

There is a stability check that you should make, so on your protos, add a resistor between the osc out pin and the crystal, so you can make the test easily. In production you can zero it, or remove it entirely, as long as you don't overdrive the crystal.

Reply to
Dave VanHorn
Loading thread data ...

Crystals",

be

Not until you remember to include the 5pF of pin capacitance. ;-)

Seriously though, IMO the crystal manufacturer knows more about what caps to use than the datasheet does. The goal is to get the thing to start reliably and to oscillate within specs. Only the crystal manufacturer knows how they ground the crystal. Isn't anyone going to mention series vs. parallel? (:-)

Reply to
Anthony Fremont

the

grounded.

Actually pin/package capacitance of the microcontroller should be counted in as well. Some micros (MSP430 ie.) even has enough load for low cap xtals... However this is not a current Atmel feature.

Not that he'll need it of course ;-)

/A

Reply to
Anders F

order

parasitics

They are. But Dave is right: The needed capacitance should come from the xtal datasheet....

Precision over temperature for UART applications?

/A

Reply to
Anders F

I've

clear

will

the

got a

"Stop agonising - stick some bloody caps in there and see it oscillate ! The value is *non-critical* +/- about nearly 50%"

I guess the +/50% doesn't quite hold then? I haven't had big production of uCs yet - but oscillator problems are the worst, and I can follow Chris in wanting it right the first time!

ppl

That sucks! I'd be furios... Design changes should not be introduced without verification and updating documentation. Guess they didn't read the ISO qualification ;-)

Cheers, Anders

Reply to
Anders F

Precisely my point when I said that other microcontrollers data were less informative, and why I was asking these questions, to gain a broader understanding.

Please refer to the ATMEGA8 spec and give me the page number(s) where it answered ALL, or even ANY of SPECIFIC the questions I asked.

I've been building microcontroller circuits for quite some time, and they all work. However, my specific field is software, where I won a number of awards, made millions of dollars, and (semi) retired in my 40's.

I'm now experimenting with electronic music controllers. Hence my questions on specific electronic details, in which I tried to be as clear as possible about what I did and didn't understand, which others kindly and intelligently answered.

Thank you all who gave helpful answers!

Reply to
Chris Graham

Bingo.

Reply to
Bob Stephens

It's for a node on a 1 mbps RS485 network, so clock precision is important.

Reply to
Christopher Graham

Are you that "Ian Bell" thing?

Reply to
Fred Bloggs

Something like that. Actually I was design lead and software architect for Microsoft Excel.

This current project is to develop a network to carry the Open Sound Control protocol to connect inexpensive and tiny sensor nodes for integrating into custom electronic musical instruments.

Reply to
Chris Graham

The caps perform two functions:

  1. Get the crystal to its spec'd resonant frequency

  1. Generate the right gain and phase shift around the loop to guarantee reliable startup and oscillation.

The phase shift also depends on the time delay and output impedance of the cmos buffer inside the chip. That has potentially different small-signal and large-signal gain and Zout.

It is always tricky having a single part or two whose values affect two or more different, important circuit parameters. Sometimes you can't make everybody happy.

John

Reply to
John Larkin

crystal

capacitance

Just about any 16 MHz crystal will work with the caps recommended by Atmel. If there are no cap values in the datasheet, look at Atmel app notes etc and use the values you see there.

Two crystals with different capacitances can be identical pieces of rock ground in the same way. The only difference is that there is a slight frequency difference between the two. It is when you put the specified capacitances across the crystals that the frequency is tuned slightly to get spot on to 16 MHz.

The caps perform impedance transformations, so you can't pick any value - the manufacturer will give you recommendations, or you can look at other people's circuits. Once you know your cap values, you calculate value of the two caps in series, to get the capacitance spec of the crystal you will buy.

Many microprocessor apps are non-critical. The "wrong" crystal may be

1000ppm off in frequency, but mostly you don't care.

Cheaper crystals and small package crystals tend to be more lossy or at least have more variation in losses (ie Q factor). So you find that a production run may have a few percent of non-start oscillators. You grab a few of the non-starters and move the caps in value a bit until you find values which work for all samples. Next production run, you have 100% startup. On the testbench, mostly none of this matters. You wack in a crytal and it goes. Once in a while you move a cap value up or down to get it to run. Mostly, you don't care if it slightly off frequ.

Some microprocessors have more critical oscillators than others. I have found the AVR parts to be non-critical.

Roger

Reply to
Roger Lascelles

Red flag. Translate as "this mode doesn't always work."

John

Reply to
John Larkin

A series R adds (sometimes) valuable phase shift.

Horror stories like this are legion. Unless there's volume with huge cost pressure, it's safer to buy a canned oscillator. If there is volume with huge cost pressure, you can't afford to not do a thorough analysis and absolutely maintain control of the crystal motional parameters.

The funnest case is oscillators that won't start. That can be sensitive to temperature, emi, mounting (is the can *really* grounded, or just sometimes?) or power supply startup dV/dT.

John

Reply to
John Larkin

But if you're making 1M of them, what would a 5% field failure rate cost? It's fine to use a cheap crystal and a cap or two, as long as you thoroughly analyze the gain and phase margins, drive level, and startup dynamics, and you have a good enough relationship with the crystal manufacturer to control motional parameters. Most people posting here don't sound like they're doing it; they mostly suggest fiddling with a prototype until it oscillates. "Try 33 pF" is scairy.

John

Reply to
John Larkin

I sort of see your point, but the cost delta is much larger than that. Crystals run about $0.25-ish to $0.49 in moderate quantities, less if you shop around or order more.

In most of the designs I've done, adding $0.5 to the BOM is a serious offense.

If you're making 1M of them, then you just spent a couple years salary.

Reply to
Dave VanHorn

Helmholtz must be satisfied.. :)

3: Swamp out the parasitics so that the part you don't control very well, isn't the dominant factor.

My biggest beef with Atmel at this point, is that they don't charachterize the Vittoz mode operation at all, and yet it's far more picky than the normal rail-rail mode. (CKOPT fuse on M128-ish parts)

Reply to
Dave VanHorn

Ahh! The flight simulator easter egg...

--
Rich Webb   Norfolk, VA
Reply to
Rich Webb

Makes you wonder how those cheap asian network cards we all use ever work !!!!

Sounds like an awful lot of worry over nothing ! I'm sure the asians don't lose any sleep over such things.

Graham

Reply to
Pooh Bear

More reliable and faster startup, and thus excellent for low-power applications where you shut down the main clock oscillator to save power.

Best regards, Spehro Pefhany

--
"it's the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Reply to
Spehro Pefhany

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.