Pages: [1]   Go Down
Author Topic: Barebones ATmega328 - Why use caps on the crystal?  (Read 2444 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 141
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why do all minimal Atmega328 designs have caps on the the 16Mhz crystal? I haven't and it seems to run fine! just power to the pins 7&8 and Crystal between 9&10.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

A minimal atmega328 design doesn't have the crystal either.

With a crystal and no capacitors, you are relying on the stray capacitance of the wiring and the capacitance of the mcu. This may not work reliably, and the frequency will be a little higher than the nominal frequency of the crystal.

I normally use a 3-terminal ceramic resonator, which has the capacitors built-in.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Belgium
Offline Offline
Sr. Member
****
Karma: 1
Posts: 281
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, I once tried to bootload an ATmega328 on a breadboard and had forgotten to connect both caps to ground. I tried several times to burn the bootloader to no avail. Until I realised my mistake, connected the caps to ground and then it worked. I have read a couple of crystal datasheets and they all required caps. I don't think a crystal will work reliably with no caps. Try to do some high speed serial communication and see if it still works...
Logged


Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 142
Posts: 5275
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why do all minimal Atmega328 designs have caps on the the 16Mhz crystal? I haven't and it seems to run fine! just power to the pins 7&8 and Crystal between 9&10.

The capacitors make it much more reliable. Without them you depend on random factors like the length of the connection wires, the electrical noise in the room, etc.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It works without capacitors. The chip will run slightly faster, like 1Khz on a 4Mhz crystal, due to crystal's low pullability. Also 7pf crystals run much closer to spec than 15pf or 22pf crystals (rare today).

Capacitors become more important for 32Khz crystals.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 141
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ultimately I plan to implement a high speed serial communications network once I have finished experimenting. Currently I'm just sending a few bytes every second or so.

My crystals have the following specs:
Frequency: 16MHz
Frequency Tolerance: ± 30ppm
Load Capacitance: 18pF
Frequency Stability: ± 30ppm

Should I therefore be using 18pF Caps? I also assume lower is better for Frequency Tolerance and Stability?

Quote
I normally use a 3-terminal ceramic resonator, which has the capacitors built-in.
What would specs should I look for in one of these?
Is this preferred because of the lower part count?
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ultimately I plan to implement a high speed serial communications network once I have finished experimenting. Currently I'm just sending a few bytes every second or so.

My crystals have the following specs:
Frequency: 16MHz
Frequency Tolerance: ± 30ppm
Load Capacitance: 18pF
Frequency Stability: ± 30ppm

Should I therefore be using 18pF Caps? I also assume lower is better for Frequency Tolerance and Stability?

To get as close to 16MHz as possible without using a variable capacitor, you should aim for 18pF loading. The 2 capacitors are in series as seen from the crystal, so two 22pF caps gives a loading of 11pF. Add the stray capacitance of the circuit and the capacitance of the IC, and you will be close to 18pF.

Quote
I normally use a 3-terminal ceramic resonator, which has the capacitors built-in.
What would specs should I look for in one of these?
Is this preferred because of the lower part count?

The main advantage is the lower part count. Ceramic resonators also cost slightly less than crystals. The disadvantage is that ceramic resonators have a lower frequency accuracy and stability than crystals - but still good enough for serial comms.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Shannon Member
****
Karma: 198
Posts: 11625
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Without the right load caps the frequency won't be in-spec for that crystal (they are calibrated for a given load capacitance). 

Load caps make the oscillation frequency much less sensitive to stray circuit capacitances I believe - not necessarily important.

A particular oscillator design may assume a certain range of load capacitance too - without it there might be no guarantee of oscillator start-up?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Without the right load caps the frequency won't be in-spec for that crystal (they are calibrated for a given load capacitance).

Depends on what you meant by "in-spec".

Quote
Load caps make the oscillation frequency much less sensitive to stray circuit capacitances I believe - not necessarily important.

It doesn't make it less sensitive. It makes the frequency closer to spec.

Quote
A particular oscillator design may assume a certain range of load capacitance too - without it there might be no guarantee of oscillator start-up?

Yes, but generally only for low frequency oscillators.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 109
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A Crystal has an equivalent RLC model, see: http://www.eetkorea.com/ARTICLES/2001SEP/2001SEP06_AMD_AN.PDF

The Crystal together with its two capacitors and maybe other components make a filter. You just have cu calculate the resonant frequency of this filter and reach the conclusion that the two added capacitors help in obtaining a precise frequency for the oscillator (filter + inverter).

There is no other explanation.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The capacitors perform another important function. The combination of capacitors, crystal and the inverting amplifier make up a Colpitts oscillator. Without the capacitors (or sufficient stray and pin capacitance instead), the circuit would not oscillate.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 512
Posts: 26211
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also helps to read this Atmel Application note, section 5, where it describes what the internals of the OSC1 & OSC2 pins are and how they are to be connected to external components such as crystals.

* Atmel AVR042 AVR Hardware Design Considerations.pdf (236.19 KB - downloaded 33 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Shannon Member
****
Karma: 198
Posts: 11625
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The capacitors perform another important function. The combination of capacitors, crystal and the inverting amplifier make up a Colpitts oscillator. Without the capacitors (or sufficient stray and pin capacitance instead), the circuit would not oscillate.

CMOS inverter is a phase-shift oscillator surely?
Logged

[ I won't respond to messages, use the forum please ]

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I suppose you could view it as a phase shift oscilator, but it's more usually viewed as a Colpitts oscillator in which the inductor and most of the capacitance is replaced by a crystal. If you google "colpitts oscillator crystal" you will find lots of references to a Colpitts oscillator that uses a crystal. But when I googled "phase shift oscillator crystal", the hits were mostly describing two different oscillators, not a phase shift oscillator that used a crystal.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Jr. Member
**
Karma: 9
Posts: 78
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've run various experiments to measure frequency offset on various MCU's and RTC's.  I connected 32Khz crystal to oscillator pins on 328p both with and without load capacitors.  Crystal worked in both configurations, though maybe a little more jitter with no capacitors. More than you wanted to know here
 
   https://github.com/manitou48/crystals
Logged

Pages: [1]   Go Up
Jump to: