Go Down

Topic: The right capacitors for the (wrong) crystal.. (Read 167 times) previous topic - next topic

Danois90

I found this blog post where the formula is: CL=(C1*C2)/(C1+C2)+Cs. If the crystal has a load capacitance of 20pF the capacitors would be just about 35pF if the stray capacitance is guesstimated to 2.5pF, because 20=(35*35)/(35+35)+2.5.

But when I look into the spec sheet for an ATmega328P (section 13.3), the capacitors is to be calculated with the formula: Ce+Ci=2Cl-Cs where Ci is the internal capacitance of 18pF on XTAL1 and 8pF on XTAL2. With the same crystal and stray capacitance as before that would result in two different caps of each ~20pF (XTAL1: 20+18~=20+20-2.5) and 30pF (XTAL2: 30+8~=20+20-2.5).

The difference between the two formulas is not insignificant and I'm assuming that I should trust the manual. But would the first method yield better accuracy? And how would a "too large" or "too small" capacitor influence the crystal?

And finally: I'm using a 32kHz (20pF Cl) crystal with Timer2 on an ATmega328P and it is not 100% accurate but the frequency is consistent compared to the WDT which is definately not reliable. If I remove the 22pF caps the crystal (or rather the entire code execution) becomes defunct (spec sheet dictates that Cl>6pF requires external caps).

Thanks in advance! :)
Instead of mocking what's wrong, teach what's right! ;)
When you get help, remember to thank the helper and give some karma!
Please, do NOT send me any private messages!!

jremington

Check the crystal data sheet. The required capacitors are part of the crystal specification, which differs from crystal to crystal.

Note that board/trace capacitance contributes to the overall requirement.

Perehama

While the spec sheet has some information, AN2519 will provide more information about not only the crystal selection and capacitor selection, but also layout and other design principles.
F=C/V=(A*s)/V=J/V^2=(W*s)/V^2=(N*m)/V^2=C^2/J=C^2/(N*m)=(s^2*C^2)/(m^2*Kg)=s/Ω=1/(Ω*Hz)=s^2/H

Perehama

F=C/V=(A*s)/V=J/V^2=(W*s)/V^2=(N*m)/V^2=C^2/J=C^2/(N*m)=(s^2*C^2)/(m^2*Kg)=s/Ω=1/(Ω*Hz)=s^2/H

MarkT

#4
Sep 24, 2018, 11:32 pm Last Edit: Sep 24, 2018, 11:33 pm by MarkT
The older datasheet says the two load capacitors should always be equal for both crystals and resonators...

Its not critical, getting the loading a bit wrong just pulls the frequency a bit.  Getting it wildly
wrong will risk failure to start up.  I've always just used 18pF or 22pF caps with a 16MHz crystal.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Danois90

I've been fiddeling a bit with it today. No caps = no go. 22pF on XTAL1 only = no go. 22pF on XTAL2 only = inconsistent frequency. 22pF on both legs gives me a consistent frequency but it is not "watch perfect" - but as long as I can expect it to be consistent, it is good enough for me! :)

Thanks for the answers, karma scattered!
Instead of mocking what's wrong, teach what's right! ;)
When you get help, remember to thank the helper and give some karma!
Please, do NOT send me any private messages!!

Go Up