Atmega 32u4 crystal can't oscillate

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

Hi all! First post here, even if it's quite a long since I've read the first post on this forum!
Today I want to ask you directly something after I've tried to work it out for over two weeks. I've built an Atmega32u4 (the RC version) board working @5V and running with a 16MHz crystal. I connected the two pins of the crystal at XTAL1 and XTAL2 of the atmega and put two capacitors to ground, as described in the datasheet. My issue is that I can't get the crystal oscillate. Below I'll point out all my try:
- Tried to set the fuse and uploading a simple blink program with 22pF capacitors and 16MHz crystal. The fuse were set correctly, but I couldn't communicate with the chip via ISP after that.
- generated a 1MHz external square wave clock and set back the fuse to internal oscillator to debrick the chip
- since the crystal is designed for 20pF load I bought some 15pF and 18pF capacitors (considering some capacitance for the tracks) and set again the fuses to external oscillator. Bricked again the chip and had to use the external clock.
- Changed 3 different type of crystals, same results.
- XTAL1 on the scope shows a sine wave but very distorted, and I think also at a lower voltage compared to any working boards I've made in the past. The scope is not able to determine the frequency, but seems to show values near 16MHz, sometimes faster sometimes slower.

I use this fuse settings for the 16MHz clock, which I calculated online: lfuse:0x7f, hfuse:0x99, efuse:0xf3.
I'd like to try the full swing, since power consumption and electromagnetic disturb are not a big issue, but I don't know how to set it up.

Have you ever experienced something like this?

Thank you!!

P.s. Here the crystal datasheet: Crystal

This topic has a solution.
Last Edited: Sat. Sep 2, 2017 - 08:50 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What does your board layout look like?

 

Have you connected all the power pins? All the GND and all the *VCC?  Bypass caps on all *VCC/GND pairs?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

I'm not an expert on that model series.

 

'Scope probing is usually better on XTAL2.

 

I don't think there is a full-swing option on this model series.

 

The datasheet speaks of "external clock switching".  Do you have to kick the crystal to get it going?  Dunno.

 

 

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

I haven't worked with the ATmega32U4, but ...

 

The Arduino Leonardo uses that uC (Link - scroll down to Documentation tab). 

A partial schematic is shown below.

Note R1, a 1Meg resistor across the crystal.

 

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

Triple-check the load caps are pF ...

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

The 1M resistor across XTAL1/2 is a long-standing design flaw in Arduino.  The AVR's inverting amplifier oscillator does not require it.
 

EDIT:  typo

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Wed. Aug 30, 2017 - 10:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks so much for replying guys!

@joeymorin Yes, I connected all the power pins and put 2 10uF bypass cap, and all the other caps suggested in the first pages of the sheet (the ones for USB and the low-pass filter for AVCC).

@theusch Yeah, XTAL2 is much more stable than XTAL1. I don't know if it has to be kicked, but I don't think so... Or at least I can't figure out why the other boars I designed works fine.

@Chuck99 I can try putting 1M resistor, I'll go find one tomorrow.

 

Yes, I'm quite sure they're pF, also because with scope I clearly see a sine wave... But it's not as sharp as the wave of a completely functional board: it's like it tries to oscillate but it really can't. And of course when I set back to the internal oscillator I see nothing on the scope.

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

Sixaxix9 wrote:
I've built an Atmega32u4 (the RC version) board ...

 

Breadboard?  Or real board?

 

Crystal real close to AVR pins?  Load caps real close to crystal?

 

Ground ring around crystal area?  And/or, no powerful signals nearby?

 

If there is stray capacitance (as would be on a breadboard lash-up) you might want to try reducing the pF of the load caps.

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

10uf's are NOT bypass caps, these should be 100nf across each vcc/gnd pair.

You could change the lfuse to 3f and look for your clock (square wave) on PortC7.

 

Jim

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

It's a PCB board, the crystal and the caps are less than an inch from the IC. The tracks are as straight as possible. There is a gorond plane all around the board.

I'll try to change the caps and set the fuse to output the clock as soon as possible.

Thanks!

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

The 32U4 has no full swing mode for the oscillator, so it can be fairly delicate.  An important piece is that the ground traces between the crystal's caps and the ground pin must have no other current flowing.  Generally this means a direct connection from the cap to the nearest AVR ground pin, and a direct connection between the ground pin to the ground entering the board.  No other components sharing those traces.

 

Maybe post a render of your board layout?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Thank you for the tip. I'll try to solder the crystal directly on the AVR to avoid any possibile interference and report back here

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

Ok, I tried to solder the crystal directly on the MCU (with capacitors connected to the nearest GND pin), but nothing has changed. The wave on the scope is much more stable, but again it cannot be reached via ISP.

I set the fuse to output the clock on PORTC7: when it uses the internal clock it shows a 8MHz square wave, but as soon as the fuse are reprogrammed the output becomes a 0V straight singal.

I'm uploading some images in a couple of hours of the board and of the schematic hoping it can help. Thanks again!

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

I'm not a sparky, but isn't there a difference between "low frequency" and "high frequency" crystals?  (and isn't the overlap in these ranges in the some-MHz area?)

 

Perhaps try e.g. 7.3728MHz crystal for a sanity check?

 

 

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

Unfortunately I don't have any... I've got some 20MHz crystals and the other are all 16MHz.

However I tried connecting together XTAL1 and XTAL2 of the atmega to a working arduino uno (without the atmega 328 of course), and nothing changed, still can't oscillate.

If it's an important try I can buy some low freq crystals.

 

EDIT: I've attached the schematic (screened a PDF), but I need my PC for the board (I'll upload it this evening).

 

Last Edited: Thu. Aug 31, 2017 - 02:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The OP's lfuse=0x7F selects:

  • low-power crystal oscillator
  • 8.0-16.0 MHz
  • slowly rising power
  • 16K CK from power-down/power-save
  • 14CK + 65ms from reset.

 

Should be fine.

 

 

 

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

I'd pull the crystal and carefully buzz out the board, checking resistances.

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

theusch wrote:

I'd pull the crystal and carefully buzz out the board, checking resistances.


Ok, I'll try that. I also have an old PCB I used to breakout tqfp packages, I can try to put my circuit on a breadboard.
This evening I'll post the results.

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

I tried the one on the breadboard and works flawlessly. I'm starting to think that the issue can be due to some cold joint in the vcc/gnd pins as suggested by joeymorin in the first reply. Tomorrow morning I'll get the iron on all the pins once again. I'm also going to check resistances, it would be funny if the problem was a misproduced PCB.

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

Hi all! Solved! I've soldered again the alimentation pins on the atmega, connected and tried again to set fuse. It's running all right, the clock is quite stable at 16MHz. I didn't tried that before because under a (very cheap) microscope the joints looked like pretty solid. I hope this will help others with the same problem.
So, thank you all again for helping me!

Last Edited: Sat. Sep 2, 2017 - 08:55 PM