Electronics > Microcontrollers
AVR crystal problems
owlhawk:
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?
Jon86:
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.
Rerouter:
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
c4757p:
--- Quote from: owlhawk on December 24, 2013, 10:12:24 pm ---I also attached a screenshot of my layout in case that has something to do with it. Not much to it though.
--- End quote ---
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.
filip_cro:
Check fuse bits once more. Programer works? If not try giving square wave signals to XTAL input.
Navigation
[0] Message Index
[#] Next page
Go to full version