I am a bit puzzled on how to choose the right capacitor value. After googling and cramming as much info as I can, at last I found this piece of guide in ATmega324PB Xplained Pro Schematics. I understand most of basic terminologies used here. Except one thing.
To get to the right value of caps, we know that on MCU's datasheet the pin capacitance is mentioned which is 6pF, which they did not use in the formula below.
We don't know what is the stray capacitance/track capacitance at this point, but below you see that they found 8.1pF which is (pin capacitance + stray capacitance) after measuring the frequency. How? How did they found the 1.8pF cap value to begin with?
Coming to actual point which is how to do this procedure correctly?
I am using 16 MHz crystal which has 20 pF load capacitance with ATmega324PB on PCB, where I am using 22pF capacitors for crystal.
Using the formula
Ce = 2(CL - Ci - Cs)
Ce = 2(20pF - 6pF - Cs)
How to find Cs? Above you see they say Cs can be ignored if it is less than 1pF, but what if it is not? On other sites I found people guesstimate this to be 5pF. Like here - Even using a ballpark Cstray plus good layout should give you far more accurate results than just copying and pasting a value
What I am thinking is can we find the stray capacitance by measuring the actual frequency with (presumably wrong size) 22pF capacitors for crystal? By using the CKOUT fuse I can measure the frequency with oscilloscope on the output pin without effecting it.
What do you guys think? If you had to do it at this level. How would you do it?