Author Topic: AVR crystal problems  (Read 6599 times)

0 Members and 1 Guest are viewing this topic.

Offline owlhawkTopic starter

  • Newbie
  • Posts: 9
  • Country: us
AVR crystal problems
« on: December 24, 2013, 10:12:24 pm »
I have a simple board with an ATmega16M1 microcontroller. It is working fine when running on the internal oscillator, but I'm having trouble getting it to work with a crystal.

It is just a standard crystal + two load caps setup. A 12mhz smd crystal and two 8pF caps. I've done several STM32 boards with the same parts and not had any trouble. But on this one it does not seem to oscillate. Running some really simple "led blink" code, it doesn't start at all. When I connect a scope probe across the crystal it sometimes runs, but much slower than it should be. And all I'm seeing on the scope is a few mV of noise.

I tried swapping out the crystal, removing the caps, and doubling them for 16pF per side with no luck. Atmel gives the formula C = 2*CL - CS. With CL being 8pF for my crystal and their estimate of 5-10pF for CS so I think my values are reasonable.

I also attached a screenshot of my layout in case that has something to do with it. Not much to it though.

Running out of ideas here... anyone have advice on what might be wrong?
 

Offline Jon86

  • Frequent Contributor
  • **
  • Posts: 526
  • Country: gb
Re: AVR crystal problems
« Reply #1 on: December 24, 2013, 10:22:06 pm »
Have you tried swapping out the microcontroller?
I can't see it being anything else, unless there's something wrong with the soldering or board.
Death, taxes and diode losses.
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4720
  • Country: au
  • Question Everything... Except This Statement
Re: AVR crystal problems
« Reply #2 on: December 24, 2013, 10:30:34 pm »
lift off your crystal and probe the 2 pins, with something like a 10K pulldown on xtal 2, this should drive xtal 1 high as a function test of the micro
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: AVR crystal problems
« Reply #3 on: December 24, 2013, 10:33:02 pm »
I also attached a screenshot of my layout in case that has something to do with it. Not much to it though.

I suspect microcontroller as well, but if you're going to attach it I'll bite! The layout could be fixed - the capacitors' grounding is not good. They need to be grounded close together (not too bad here), but they should also be grounded close to the oscillator's (microcontroller's, in this case) ground. You haven't shown the entire layout, but I'm having trouble seeing a ground path from crystal capacitor -> MCU that is not long and curvy.

The problem could be solved by putting a few (at least two each) ground vias near the capacitors to that nice ground plane underneath, and doing the same thing near the MCU ground pins.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline filip_cro

  • Regular Contributor
  • *
  • Posts: 71
  • Country: hr
Re: AVR crystal problems
« Reply #4 on: December 24, 2013, 11:10:22 pm »
Check fuse bits once more.  Programer works? If not try giving square wave signals to XTAL input.
« Last Edit: December 24, 2013, 11:12:22 pm by filip_cro »
 

Offline danellis

  • Newbie
  • Posts: 4
Re: AVR crystal problems
« Reply #5 on: December 25, 2013, 08:04:02 am »
Did you set the right fuse values? I don't the AVRs output a voltage to drive the crystal unless an external oscillator is selected (the pins can be used for other things).
 

Online hans

  • Super Contributor
  • ***
  • Posts: 2001
  • Country: 00
Re: AVR crystal problems
« Reply #6 on: December 25, 2013, 09:39:30 am »
Some of those square oscillators are 4-pin parts. The oscillator can, and the remaining 2 pins should sometimes be connected to GND.

You may try adding 2 patch wires to the GND of the capacitors and see if it helps. I have had this issue with a FT4232HL and the required oscillator.
Other times it didn't need it, so it depends a bit on the chip, PCB possibly, more importantly the crystal itself.
« Last Edit: December 25, 2013, 03:16:30 pm by hans »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: AVR crystal problems
« Reply #7 on: December 25, 2013, 01:07:13 pm »
Quote
anyone have advice on what might be wrong?

No idea what might have caused it but certainly it is not your code.
================================
https://dannyelectronics.wordpress.com/
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4665
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: AVR crystal problems
« Reply #8 on: December 25, 2013, 01:40:32 pm »
Only pin 1 and 3 are the oscillator, the other two are gnd or float depening on the oscillator.

Make sure you've soldered your crystal properly with hot-air and paste.
 

Offline owlhawkTopic starter

  • Newbie
  • Posts: 9
  • Country: us
Re: AVR crystal problems
« Reply #9 on: December 28, 2013, 06:53:00 am »
Finally got a chance to look at this again. Figured it out and now I just feel like an idiot. |O

I had one spare AVR chip so I assembled a second board, which worked fine right away. So I knew it had to be a problem with the something on the first board rather than the design. Turned out to be a bad solder joint on one of the crystal pins on the AVR. I had checked them under a magnifying glass and they looked perfect, but once I reflowed them it started working.

I guess my lesson here is that even if a joint looks good, go back over it with the iron anyway if you are having problems.

Thanks for the help!
 

Offline Jon86

  • Frequent Contributor
  • **
  • Posts: 526
  • Country: gb
Re: AVR crystal problems
« Reply #10 on: December 28, 2013, 11:39:06 am »
Very easy mistake to make, at least you know now  :-+
Death, taxes and diode losses.
 

Offline Zbig

  • Frequent Contributor
  • **
  • Posts: 927
  • Country: pl
Re: AVR crystal problems
« Reply #11 on: December 28, 2013, 02:56:47 pm »
When I'm done manually soldering a TQFP or similar package, what I usually do besides the visual inspection is, I'm taking a mini-screwdriver equipped with a pointy metal spike bit and gently (not to bend the pin in case it wasn't soldered properly) poke each and every leg from the side at its flush (parallel to the pad) part. I can instantly hear and/or feel when there is no usual mechanical resistance which is to be expected from the properly soldered pin. I do that because I myself was more than once deceived by a "perfectly good looking" joint.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->