Some 16MHz crystal not working well with ATMEGA328 and 22pF

Received an email from a friend/customer that our recent batch of crystals don't work well for him and since this may be troubling other people as well, I would like to reach to the Arduino community and give some hints.

We changed 16MHz crystal supplier around mid April 2014 and sold quite a few since, this is first time anyone reported an issue.

After the email, I hooked up a ZY-60 breadboard with ATMEGA328 preloaded with blink sketch and tested 5pcs 16MHz crystals with 2x 22pF loading caps. 4 crystals worked and one did not. 2x 18pF loading caps resolved the non-working unit. Also found 16MHz crystal from previous supplier at the bottom of the bin and tried all 6 of them without any loading caps and all worked, but I suspect breadboard added few pF.

If crystal does not oscillate at all, correction is to lower C1,C2. ATMEGA328 @ 16MHz is unlikely to oscillate on first harmonic 32MHz, and itself it has high parasitic capacitance, so in my opinion it's safe to simply remove loading caps for units that won't start as temporary workaround.

ATMEGA328P datasheet in section 9.4 table 9.5 recommends C1 and C2 range 12-22pF for entire frequency range 0.4-20MHz. With higher frequency, lower C1,C2 should be used, so my recommendation for ATMEGA328P is to use C1,C2=15pF @ 16MHz and C1,C2=12pF @ 20MHz.

Might also try changing the fuse settings, from
Low Power Crystal Oscillator
to
Full Swing Crystal Oscillator

With '328P, change Low Fuse byte in boards.txt, from
uno.bootloader.low_fuses=0xff
to
uno.bootloader.low_fuses=0xf7

This change also fixed a '1284P problem I had that may have been crystal related recently (didn't look with a scope). Not sure where the crystal was from; dipmicro is one of my regular sources, along with taydaelectronics, digikey and mouser; wiho I order from depends on what other parts I am buying at the time, and what I might be low on.

That was a good catch Rob. I have been flashing 328Ps with lfuse:w:0xff:m

Already dismantled my breadboard setup and don't have time right now to retest with 0xf7 and 0xff but if someone has parts in the drawer and little time, I will give $10 store credit to first one who promises to do following experiment then reports result back to this thread:

  1. test several 16MHz crystals with ATMEGA328P and lfuse=0xff, C1,C2=22pF, find at least one unit that repeatedly fails to start. If you cannot find such crystal, try 27pF or even 33pF.

  2. reflash MEGA with lfuse=0xf7, and test in the same setup with xtal that was failing before. See if you can reliably start the micro now.

Thanks :slight_smile:

I'll give it a try when I get my shipment from digikey. I ordered some 22pf, 27pf, and 33pf caps with both 12pF and 18pF load capacitance crystals. My experience with 1284p is that the dip version worked with half the crystals I tried (over a dozen) that I bought from dipmicro and other half didn't work. This test was repeated with 328p dip version and those crystals that worked with 1284p worked with 328p. Those that didn't have a few that worked with 328p. Although I didn't know, I suspect dipmicro's previous batch of crystals had less than 18pF load caps, possibly 12pF. I've used them all up so I got new ones. My surface mount crystals from digital or mouser are 12pF (just checked) and I didn't have problems with 328p-au (qtfp) and 22pf caps.
If I can test out at least a few dozens of 328p with dipmicro's 18pF load cap crystals and they work, I'll just re-bag my kits. Otherwise I'll change the fuse and test again. This has given me some headache but hey who would have thought something called load capacitance is something they should be aware of? It's a good thing to actually know what I'm doing.

I got 10 each crystals from digikey (877-2014 and 877-1019). They are 12pF and 18pF load capacitance so they should go with 22pF and 33pF. I have an ATMEGA1284P-PU hooked up and loaded with blink. I tried all of them on 22pF caps and they all work. I also tried 33pF with the 18pF load capacitance crystals and they all work. I then tried 22pF and 33pF on 10 of your crystals that should have 18pF load capacitance. 4 failed with 22pF and 5 failed with 33pF, including the same 4 that failed with 22pF. This seems to be a quality issue rather than cap value issue. I was using 0xF7 fuse setting so the oscillator should be making rail-to-rail oscillations instead of saving power.

I then used my scope to look at the oscillations. As I said earlier I only was able to see oscillations on the one crystal that I got from a colleague (big one) but not on the one from dipmicro. This time with the 5 dipmicro crystals out of 10 that work with 33pF/22pF caps, I was able to see 4 oscillate with 16MHz oscillations. They are touchy when I have the minigrabber on them. One fails to oscillate with the scope attached. The peak to peak swing is less than 2V, compared with digikey crystals that produce ~3V peak to peak swing. I only tried 4 of digikey crystals and they all work fine with my scope. Also tried 22pF caps and saw the same thing. My scope is a Tecktronic TDS 2024. At the quantity I'm looking to buy (200-ish), it's is about $0.240 each at digikey and yours $0.108. I think I'm going to get theirs. Please find some screen shot of my scope below. The screen is damaged (laser, blunt object?!) long ago.

Thanks John, I was looking for difference between lfuse 0xff and 0f7, so offer from post#2 is still on.

Btw. if you have unused crystals from dipmicro that you don't need anymore, we will accept them back. I don't think there is a problem, but they may be 12pF not 18pF. Unfortunately, many Asian suppliers of generic parts do not believe in specifications.

dipmicro:
Thanks John, I was looking for difference between lfuse 0xff and 0f7, so offer from post#2 is still on.

Btw. if you have unused crystals from dipmicro that you don't need anymore, we will accept them back. I don't think there is a problem, but they may be 12pF not 18pF. Unfortunately, many Asian suppliers of generic parts do not believe in specifications.

I continued on where I left off at work. I had about 15-16 of your crystals that I tested. Two of them consistently failed to start my ATMEGA328P-PU with 22pf caps. I tried LF=0xFF and 0xF7 and 22pF and 33pF. Neither crystal worked at any of the settings while the working crystals and one digikey crystal that I used all worked. At low-power setting, the crystal output is around 300mV peak to peak and the full-swing setting gives about 3V or more peak to peak. Yours compares to digikey's about same amplitude. I didn't test 27pF. I still think it is a matter of bad crystal. Thanks for offering to take the crystals back. I've used a couple of them on some pcbs, luckly they all work thus I had not considered that the crystals could be the problem. I still have the rest, with a few having some kinked pins due to breadboard work and one with legs cut short. I don't need to return them. But have no doubt that I'll purchase other components from you in bulk as usual. We probably never thought that crystals could be bad but they do come in bad quality sometimes :slight_smile:

I own an electronic assembly service. Last year one of our customers experienced crystal problems with the GPS boards we were producing. They traced the problem to a particular BATCH of crystals. Batches before and after the problem batch were ok.

Your crystals should have a batch identifier printed on them. Perhaps the bad batch go to you!

Paul

Paul,

Thanks for sharing your experience! The crystals don't have any batch identifiers. I'll ask dipmicro maybe he has a batch number with bulk package. If I may ask, how did you figure out it was the crystals?

dipmicro:
If crystal does not oscillate at all, correction is to lower C1,C2.

I respectfully disagree (unless the point being made here is that the crystal specs are different from those advertised in the datasheet). The loading capacitors should be sized to provide the load capacitance specified in the crystal's datasheet, usually with an allowance for stray capacitance. Assuming that this is the crystal being discussed, it requires an 18pF load capacitance. Allowing 5pF for stray capacitance, the load capacitors are then calculated as 27pF (nearest standard value).

If that doesn't work, then something else is wrong. I'm not a fan of the diddle-with-it-until-it-works approach, I much prefer to know what the problem is.

liudr:
Paul,

Thanks for sharing your experience! The crystals don't have any batch identifiers. I'll ask dipmicro maybe he has a batch number with bulk package. If I may ask, how did you figure out it was the crystals?

The customer figured it out. Don't know what procedure they used, but the problem existed for several builds.

Paul

Where does 5pF stray come from?

dipmicro:
Where does 5pF stray come from?

Wiring, etc. Parasitic capacitance - Wikipedia

I think I said in another thread, I'd used those crystals before without any issues but they were bought a while back, certainly before the supplier change.

Coincidentally, I've been putting an order together so I'll get some crystals to see how they work for me, should be interesting to experiment with. I'll report back with my results.

I am removing datasheet reference, seems worthless, and will not specify loading capacitance from now on.

Recommend keeping few spare 12pF, 15pF, 18pF, 22pF, 27pF in the drawer.

If you make kits, either get brand name specified crystals or if buying from dipmicro or other generic parts source, get more at a time and in comment section request all from same bag (manufacturers usually pack in 200 or sometimes 1000pcs), then try a few units and find best loading capacitor for that batch.

Btw. when testing few units for the purpose of my original post in this thread I found all crystals work without loading capacitors. What is the problem with that approach ?

My first dozen all worked on 328 with 22pF caps. That is not the point. About a quarter of the 200 didnt after I tested them all.