Choose external crystal for Atmega328P

Go To Last Post
25 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
Reading the datasheet I didn't find how to choose the right load capacitance of the crystal.

http://pt.mouser.com/Passive-Com... what load capacitance should I choose?

Thank you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have a look at the Atmel Application Note: AVR042 AVR Hardware Design Considerations.

It discusses the crystal's load capacitors in detail.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
Have a look at the Atmel Application Note: AVR042 AVR Hardware Design Considerations.

It discusses the crystal's load capacitors in detail.

JC

Thank you :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So looking at the atmega328p datasheet it says:

From the AVR042 app note we take the formula

C=2xCL-CS

where CS is the stray capacitance usually from 5pF to 10pF.

Lets take 22pF for C and 10pF for CS:
22 = 2xCL - 10 <=> CL = (22+10)/2 = 16pF;

So I need to choose a crystal with a capacitance load of 16pF, right?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone,

 

What would happen if one used a ZTT16.00MX Which has a capacitance of 30pF?

 

(CERAMIC RESONATOR, ZTT SERIES, THROUGH HOLE MOUNT, 3-PIN, 16 MHz)
http://www.digikey.com/product-d...

 

Regards,

J

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you use a HF crystal,  you need the 22pF capacitors.

If you use the ceramic resonator,  you do not need the 22pF capacitors.

 

In practice,   the standard crystals will work just fine.    The capacitors will not be that critical.  e.g. 15pF - 30pF will work.

Your frequency will be accurate enough.   e.g. +-50 ppm with a crystal or +-500 ppm with ceramic.

 

If you are aiming for +- 10ppm,   you need to worry about the spec.

 

David.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you David for your reply.

The reason I'm using the Ceramic Resonator with built in caps is it is a tidier circuit, i.e. less components.

 

From what I understand from your response, if I used the component I asked about, I will probably run the MCU at about 15.something MHz instead of 16Mhz.

If this is correct, then my use-case should work because I'm not aiming for precision timing one would use in a clock.

 

I was just concerned that I might break the MCU.

 

Warm regards,

Justin

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since you are not making a RTC,   the ceramic resonator will be absolutely fine.

 

Yes,  it might be anywhere from 15.992MHz to 16.008MHz.    It might even be exactly 16.000000MHz.

 

A typical 16MHz crystal might be 15.9992MHz to 16.0008MHz

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

The capacitors will not be that critical.  e.g. 15pF - 30pF will work.

 

I cannot remember the last time, in over 30 years of MCU experience, when I used anything other than 22pF. As David said, it just works.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I'm would like to use a resonator with an attiny45, is it the same load capacitance as atmega ?

I'm thinking of using CSTCE8M00G55 resonator. Do you think it is correct or I should use an other ?

Otherwise which good quality 8mhz resonator (I don't need more than 1% accuracy) do you recommend with Attiny mcu ?

 

Thanks

 

Last Edited: Mon. Jul 11, 2016 - 06:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You will not get any AVR to run reliably at 8mhz.
The internal RC clock works just fine at 8MHz.
It will have 1% accuracy without any problem.
Yes you could use a crystal if you want 0.003% accuracy.
Or a ceramic resonator with 0.03% accuracy.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
You will not get any AVR to run reliably at 8mhz. The internal RC clock works just fine at 8MHz. It will have 1% accuracy without any problem. Yes you could use a crystal if you want 0.003% accuracy. Or a ceramic resonator with 0.03% accuracy.

 

In attiny85 spec "21.4.1 Calibrated Internal RC Oscillator Accuracy" it is written factory calibration is 10%. That's why I prefer to use an external resonator 

Why have you said that any avr can not run reliably at 8mhz.  What's the problem with this frequency ?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

8 milli-Hz?

Leon Heller G1HSM

Last Edited: Mon. Jul 11, 2016 - 08:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, the Factory only guarantees 10% calibration accuracy.
In practice, most chips will be 1%.
If you are selling commercial boards, you would need to check the calibration as part of your test procedures because you could not rely on every chip being 1%.
If you use resonator or crystal, you do not have to worry about calibration. You will still have a board test procedure as part of your production. So you don't save any time by not testing the RC calibration.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

leon_heller wrote:
8 milli-Hz?
 

 

Ok catch it :-)

It was 8Mhz 

 

Last Edited: Mon. Jul 11, 2016 - 09:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Yes, the Factory only guarantees 10% calibration accuracy. In practice, most chips will be 1%. If you are selling commercial boards, you would need to check the calibration as part of your test procedures because you could not rely on every chip being 1%. If you use resonator or crystal, you do not have to worry about calibration. You will still have a board test procedure as part of your production. So you don't save any time by not testing the RC calibration. . David.

 

Accuracy is "at given Voltage & Temperature" so I prefer to guaranty the clock using a resonator

But my question was regarding the Built-in Load Capacitance of the resonator: Should I choose 33pf of CSTCE8M00G55 or 10pf of CSTCE8M00G52 ?

 

Thanks

Franck

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

franck007 wrote:
Ok catch it :-) It was 8Mhz

Sorry to be a complete pedant but that would be 8MHz.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

franck007 wrote:
Accuracy is "at given Voltage & Temperature" so I prefer to guaranty the clock using a resonator But my question was regarding the Built-in Load Capacitance of the resonator: Should I choose 33pf of CSTCE8M00G55 or 10pf of CSTCE8M00G52 ?

 

I don't think it is going to make much difference.  Page 30 of the datasheet shows a 10pF load resonator with a ATmega128.   I would expect the 33pF version to work exactly the same.

 

If you have a wide Temperature Range and/or Voltage Range,  you would need to compensate the RC.

The Resonator frequency will change too.   But within your tolerance so you do not need to worry.

 

If you are at Room Temperature and mains powered,  the RC would be fine.  

If you are low current battery app,  the RC would be less power, faster wake-up,  ...  but you would need to check calibration in your QC tests.

 

Personally,  I see little point in ceramic resonators.   They are less accurate than crystals.

They probably tolerate mechanical shock and vibration better than crystals.

An RC would be be "better" for mechanical stress.    But then your whole pcb requires design for shock.

 

If your product is going to be in a benign office environment,  you really do not need to worry about most of these things.

 

David.

Last Edited: Mon. Jul 11, 2016 - 10:08 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

franck007 wrote:

Ok catch it :-) It was 8Mhz

 

Sorry to be a complete pedant but that would be 8MHz.

 

Ok, thanks for the tip

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

franck007 wrote:
Accuracy is "at given Voltage & Temperature" so I prefer to guaranty the clock using a resonator But my question was regarding the Built-in Load Capacitance of the resonator: Should I choose 33pf of CSTCE8M00G55 or 10pf of CSTCE8M00G52 ?

 

I don't think it is going to make much difference.  Page 30 of the datasheet shows a 10pF load resonator with a ATmega128.   I would expect the 33pF version to work exactly the same.

 

If you have a wide Temperature Range and/or Voltage Range,  you would need to compensate the RC.

The Resonator frequency will change too.   But within your tolerance so you do not need to worry.

 

If you are at Room Temperature and mains powered,  the RC would be fine.  

If you are low current battery app,  the RC would be less power, faster wake-up,  ...  but you would need to check calibration in your QC tests.

 

Personally,  I see little point in ceramic resonators.   They are less accurate than crystals.

They probably tolerate mechanical shock and vibration better than crystals.

An RC would be be "better" for mechanical stress.    But then your whole pcb requires design for shock.

 

David.

 

I checked attiny85, atmega128 and ceralock datasheet and couldn't find the 10pf resonator load exemple

Which datasheet are you referring too ?

 

Thanks

 

Edit: found it

 

 

Last Edited: Mon. Jul 11, 2016 - 10:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Murata datasheet that I had to Google for myself.   i.e. the one with selection guide for your resonator type. http://www.mouser.com/ds/2/281/p16e-522700.pdf

 

Quite honestly,  AVRs will "drive" a crystal / ceramic oscillator very reliably.    (Unless it is the mega1284)

If you choose "lowest power" fuse settings,  you may not have enough drive for resonators.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do you mean by "lowest power" fuse settings ? 

Brown-out detection low voltage, slow startup or something else ?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

franck007 wrote:
What do you mean by "lowest power" fuse settings ?

Have you looked for that in the clocking section of the datasheet?

 

...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your answer. Yes I read the attiny85 datasheet that does not have this low power crystal oscillator mode.

I know, I've asked questions on a atmega thread as I though atmega and attiny85 were similar. It looks that it is not the case

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In decades of microcontroller work, I have always used an xtal that is a multiple of 16x115200 so I can hit the std baud rates. So convenient to use the serial for debug, changing params.

If resonator is .03%, I'd get one with a baud multiple frequency just like an xtal.

 

Imagecraft compiler user