ATMega8u2 strange problem

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

Hi all.

 

I have a clone Arduino MEGA board which uses an ATmega8u2 as the USB to serial link. It works fine.

 

What I did was to change the low fuse of the 8u2 from 0xFF to 0xF7 (i.e. setting CSEL3 to 0) to set the crystal oscillator from normal to full swing mode.

 

This caused the 8u2 to stop working (the oscillator stopped). I could not even reset the fuse to 0xFF.

 

In order to unbrick the chip, I had to "borrow" the 2560 crystal oscillator and jump X2 of the MEGA to X1 of the 8u2 to give it a clock and allow re-flashing.

 

After setting the low fuse back to 0xFF, it worked again.

 

Any ideas as to why the full swing crystal setting would STOP the oscillator? I use full swing on everything else (that supports full swing) without any trouble at all.

 

Any info will be appreciated.

 

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Last Edited: Mon. May 4, 2020 - 04:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

According to the Web calculator http://www.engbedded.com/fusecal... the default fuses are:

-U lfuse:w:0x5e:m -U hfuse:w:0xd9:m -U efuse:w:0xf4:m 

If you set lfuse=0xF7 you get EXTCLOCK.

 

LFUSE bits vary for different chips.   You should check the datasheet.   Engbedded might have it wrong.

e.g. LFUSE=0xF7 on an ATmega88 would do FULLSWING Crystal

 

David.

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

Krupski wrote:
What I did was to change the low fuse of the 8u2 from 0xFF to 0xF7 (
My very first question would be why you actually thought the fuses needed to be changed in the first place. The Arduino Mega is a complete/designed/developed system. The designers who put the 8U2 in place as the UART bridge and applied a clock to it will have already determined the optimal fuse setting to use and will have set that already. So why would you change it?

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

david.prentice wrote:

According to the Web calculator http://www.engbedded.com/fusecal... the default fuses are:

-U lfuse:w:0x5e:m -U hfuse:w:0xd9:m -U efuse:w:0xf4:m 

If you set lfuse=0xF7 you get EXTCLOCK.

 

LFUSE bits vary for different chips.   You should check the datasheet.   Engbedded might have it wrong.

e.g. LFUSE=0xF7 on an ATmega88 would do FULLSWING Crystal

 

David.

 

According to the datasheet, CSEL3...0 should all be 0 for external clock (i.e. lfuse 0xF0).

 

I went by the datasheet from Microchip LINK. Is their datasheet wrong?

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Last Edited: Tue. May 5, 2020 - 02:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

Krupski wrote:
What I did was to change the low fuse of the 8u2 from 0xFF to 0xF7 (
My very first question would be why you actually thought the fuses needed to be changed in the first place. The Arduino Mega is a complete/designed/developed system. The designers who put the 8U2 in place as the UART bridge and applied a clock to it will have already determined the optimal fuse setting to use and will have set that already. So why would you change it?

 

Honestly... I get strong radiated RF from the clock crystal (22.1184 MHz) that I can pick up on a shortwave receiver (this oscillator runs full swing). I can also pick up 16.000 from the 8u2 oscillator (at a lower signal strength) and I was curious if setting it to full swing would make it "as loud" as the other clock. It was just out of curiousity that I tried this.

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

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

Ah-ha.   My datasheet is 2009.   I have downloaded the current datasheet 2012.   Both have identical Table 8-1. Device Clocking Options Select

This mentions Full-Swing and Low Power.   And a lot of Reserved values.

 

The Engbedded calculator has no "Full-Swing".   And it does not report the Reserved settings.

I attempted to use the AS7.0 Programming dialog with Simulator.   And it does not support 8U2, 32U4, ... and many other less common devices.

 

Datasheet Fuse chapters make my head hurt.   I use Engbedded whenever possible.

 

It looks as if the datasheet is wrong.   But the chip is 10 years old !!   Someone would have complained.   Have you Googled ?

I have a 32U2 somewhere.   I suppose that I should get it out and experiment with fuses.

 

Incidentally,  Engbedded shows 0xF7= Ext Clock and 0xE7=Ext Low-Freq Crystal.   i.e. SUT=11 is very critical.

Table 8-4. Start-up Times for the Low Power Crystal Oscillator Clock Selection does not mention.

 

Personally,   I agree with Cliff.   Why would you change the 8U2 on an Arduino board?

Later models have a 16U2.   These have enough Flash to create custom USB devices.   The 8U2 is only suitable as a USB-UART bridge i.e. your current firmware.

 

David.

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

Krupski wrote:
I have a clone Arduino MEGA board which uses an ATmega8u2 as the USB to serial link. It works fine.

Krupski wrote:
Honestly... I get strong radiated RF from the clock crystal (22.1184 MHz) that I can pick up on a shortwave receiver... (this oscillator runs full swing). I can also pick up 16.000 from the 8u2 oscillator (at a lower signal strength)

Does it emit strongly without external connections ?

Post a link to a decent picture and schematic, you may be able to quieten it down by other means.

 

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

I can also pick up 16.000 from the 8u2 oscillator (at a lower signal strength)

 

And then he attempted to make it louder !!

 

Most genuine Arduino boards use a 16MHz resonator for the main MCU.

But a real 16MHz crystal for the 8U2 or 16U2 USB-Serial bridge chip.

Clones usually use a proper crystal for the main MCU.   (resonators are crap)

 

I am not aware of any Arduinos with 11.057MHz or 22.1184MHz.

If Krupski picks up interference I would expect him to "reduce" it rather than increase it.

 

Since he listens to shortwave he will know all about 100nF ceramic capacitor placement and digital circuits.

 

David.

 

Edit.   I found my 32U2.  Connected to ATMEL-ICE.   AS7.0 Programming Tool could read my fuses.   I could select several clock options in the drop-down.

None of them say Full-Swing.   Just EXTCLK, INTRCOSC, EXTLOFXTAL, EXTXOSC0MHZ4, EXTXOSC0MHZ9, EXTXOSC3MHZ, EXTXOSC8MHZ

 

So you choose by Xtal frequency range e.g. 0.4MHz-, 0.9MHz-, 3MHz-, 8MHz-

 

There are several fuse values that are not offered by the AS7.0 drop-downs e.g. 0xF7

Last Edited: Tue. May 5, 2020 - 11:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've always had a little oscillator leakage. Normally it shows up in radiated emissions testing at the second harmonic. As it is below the required threshold, I've not had to worry about it. Switched mode supplies on the other hand.......

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

I have never tested emissions.   But surely a clock source provides a square wave to the outside world.   i.e. fundamental, 3rd, 5th, 7th, ... harmonic.

 

Yes,  the low power crystal oscillator might be close to a sinewave.   i.e. the lower the drive,  the purer the result with a low current.

But,  a MCU is safer with a reliable clock.   Hence full-swing drive with higher current and definitely higher harmonics.

A Triangle would be fundamental, 2nd, 4th, 6th, ... (from memory)

 

I am still intrigued by this Arduino clone with 11.059MHz

 

David.

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

Radiated emission testing is typically unconcerned with stuff below 30MHz. For the vast majority of low power micro-controller circuits it just isn't a problem.

 

david.prentice wrote:
But surely a clock source provides a square wave to the outside world

The crystal oscillator is essentially an analog circuit, I remember reading a yellowing National Semiconductor data-book going into great detail on crystal oscillators. They're fairly high gain & low power circuits generating waveforms recognisable as sinewaves which leads to layout & capacitor choice being important.

 

The squaring up,  buffering and clock distribution is where the harmonics are generated.

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

N.Winterbottom wrote:

Krupski wrote:
I have a clone Arduino MEGA board which uses an ATmega8u2 as the USB to serial link. It works fine.

Krupski wrote:
Honestly... I get strong radiated RF from the clock crystal (22.1184 MHz) that I can pick up on a shortwave receiver... (this oscillator runs full swing). I can also pick up 16.000 from the 8u2 oscillator (at a lower signal strength)

Does it emit strongly without external connections ?

Post a link to a decent picture and schematic, you may be able to quieten it down by other means.

 

 

The RF emission doesn't bother me. I was merely curious what would happen if the 8u2 were set to full swing mode.

 

By the way, in order to get a good signal on my radio (a Kenwood TS-590SG), I need to put a cliplead on the crystal body to act as an antenna. Without it, the crystal is only S5 on the meter.

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

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

david.prentice wrote:

I can also pick up 16.000 from the 8u2 oscillator (at a lower signal strength)

 

And then he attempted to make it louder !!

 

Most genuine Arduino boards use a 16MHz resonator for the main MCU.

But a real 16MHz crystal for the 8U2 or 16U2 USB-Serial bridge chip.

Clones usually use a proper crystal for the main MCU.   (resonators are crap)

 

I am not aware of any Arduinos with 11.057MHz or 22.1184MHz.

If Krupski picks up interference I would expect him to "reduce" it rather than increase it.

 

Since he listens to shortwave he will know all about 100nF ceramic capacitor placement and digital circuits.

 

David.

 

Edit.   I found my 32U2.  Connected to ATMEL-ICE.   AS7.0 Programming Tool could read my fuses.   I could select several clock options in the drop-down.

None of them say Full-Swing.   Just EXTCLK, INTRCOSC, EXTLOFXTAL, EXTXOSC0MHZ4, EXTXOSC0MHZ9, EXTXOSC3MHZ, EXTXOSC8MHZ

 

So you choose by Xtal frequency range e.g. 0.4MHz-, 0.9MHz-, 3MHz-, 8MHz-

 

There are several fuse values that are not offered by the AS7.0 drop-downs e.g. 0xF7

 

The 2560 I have is a Sainsmart board (LINK). I buy these in particular because along with the standard 16.0 MHz resonator, it also has traces for an HC49US crystal. So I remove the resonator, solder in two 18pf smt capacitors and a 22.1184 MHz crystal. I use this frequency because it gives perfect baud rates with the UART integer divider.

 

BTW, I don't (can't) use AS7 because I run Linux. I edit source with the NANO editor and either compile with a Makefile or else use the Arduino "IDE" as a "compile button".

 

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

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

N.Winterbottom wrote:

Radiated emission testing is typically unconcerned with stuff below 30MHz. For the vast majority of low power micro-controller circuits it just isn't a problem.

 

david.prentice wrote:
But surely a clock source provides a square wave to the outside world

The crystal oscillator is essentially an analog circuit, I remember reading a yellowing National Semiconductor data-book going into great detail on crystal oscillators. They're fairly high gain & low power circuits generating waveforms recognisable as sinewaves which leads to layout & capacitor choice being important.

 

The squaring up,  buffering and clock distribution is where the harmonics are generated.

 

The AVR clock is surely square inside the chip, but at the crystal pins, it's a decent sine wave (at low power or full swing). The X1 pin is a slightly warped sine wave, but the X2 pin is almost perfect.

 

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

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

The Amazon picture is low res rubbish. However I found an interesting aliexpress vendor offering both ATMEGA16U2 / CH340G  variants on the same page.

https://www.aliexpress.com/item/4000735384970.html

The ATMEGA16U2 variant looks identical to yours. Interestingly the CH340 variant has no decoupling capacitors. Guess which one I would purchase!