Go Down

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

#### Danois90

##### Sep 24, 2018, 08:28 pm
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).

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

#1
##### Sep 24, 2018, 08:59 pm
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

#2
##### Sep 24, 2018, 09:00 pm
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.
The slender snake hissed as she slithered slowly over the rocks, grass and leaves.

#### Perehama

#3
##### Sep 24, 2018, 09:02 pm
AVR4100 is specific to 32 kHz crystals.
The slender snake hissed as she slithered slowly over the rocks, grass and leaves.

#### MarkT

#4
##### Sep 24, 2018, 11:32 pmLast 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

#5
##### Sep 25, 2018, 07:48 pm
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