ATmega4809 running on 12MHz external crystal impossible?

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

Hi!

 

I'm designing new board which is intended to run with 12MHz clock because of USB HID feature. As with many previous projects for older ATmega chips, it was as easy as soldering 12MHz with two 22pF caps crystal to XTAL pins and applying V-USB library or other. 

 

But after opening ATmega4809 datasheet I got really confused

 

 

There are no XTAL pins! Datasheet says TOSC1 and TOSC2 are intended to work with 32768Hz crystal and nothing else. Have they really forgotten about crystal oscillators? Do I need to buy 10x more expensive integrated clock generator instead of mere crystal?

extronic.pl

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

I wonder too...lowest $osc is about $0.54   ...lowest xtal is about $0.13....that's a big difference in a $3 board

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

avrcandies wrote:

I wonder too...lowest $osc is about $0.54   ...lowest xtal is about $0.13....that's a big difference in a $3 board

 

But you wouldn't put a $1 micro on a $3 board.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

In truth, all you need is a Pierce oscillator:

The AVR-0/1 have internal circuitry (i.e. inverters in every I/O pin + event system) that allow you to create one with just a few external components.

I tested this a while back: https://www.avrfreaks.net/forum/...

 

The question is, would this be reliable for an actual design? I have no idea. Maybe I'll ask Microchip support, one day, what they think.

 

 

Last Edited: Thu. May 9, 2019 - 07:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Could it simply be that 4809 (and probably V-USB) are the wrong choice for the job? Why not pick a micro with dedicated USB h/w if your core design aim is a USB interface?

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

extronic wrote:
There are no XTAL pins! Datasheet says TOSC1 and TOSC2 are intended to work with 32768Hz crystal and nothing else. Have they really forgotten about crystal oscillators? Do I need to buy 10x more expensive integrated clock generator instead of mere crystal?

 

Yes, for some reason, they consider a  ATmega4809, a very small micro, and they remove the unbuffered oscillator gate. They are not the only vendors to do this, on the bottom end MCUs, but it does get annoying to see it removed on the mid-tier devices.

 

A large Asian vendor, who removed XTAL support on their low end MCUs, has added back Xtal support on their newest parts, so maybe user agitation is reaching the  product managers ?

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

clawson wrote:

Could it simply be that 4809 (and probably V-USB) are the wrong choice for the job? Why not pick a micro with dedicated USB h/w if your core design aim is a USB interface?

Core design aim is RFID scanner and the product is actually developed and working. We were planning to just do a quick update to add a 'virtual keyboard' feature as many barcode scanners do - when you scan a barcode the scanner acts as a keyboard and types the barcode value into a Notepad/Word/Excel/anything. I've seen many people na Hackaday doing fancy USB keyboards, mice, password managers, etc with simple ATtiny2313 so I thought ATmega4809 should also handle simple USB communication but I didn't realize I can't use crystal oscillator :D so I'll take an integrated SMD generator instead.

extronic.pl

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

Every Silicon vendor has been adding crystal-less USB controllers.

In other words they have developed stable RC oscillators that are accurate enough for USB.

 

You will have to study the 4809 datasheet to see if the RC is "good enough".

 

Obviously you need better performance for a Nuclear bomb or navigation project.

 

Hey-ho,   RC have been good enough for USART comms for many years.   (perhaps not Atmel)

RC is now good enough for USB comms (USB chips from many vendors)

 

If your device requires absolute accuracy,  use an external clock.

 

David.

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

david.prentice wrote:
Hey-ho,   RC have been good enough for USART comms for many years.   (perhaps not Atmel)

RC is now good enough for USB comms (USB chips from many vendors)

 

Sure, provided the RC has right frequency value. ATmega4809 has 16MHz and 20MHz RC with prescaler 1, 2, 4, 6, 8, 10, 16, 24, 32, 48 and 64. I would need a fractional divider to get 12MHz out of 16MHZ or 20MHz.

extronic.pl

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

No.   Surely you just adjust the coarse RC value and calibrate for an accurate 12MHz.

 

Ah-ha.   OSC16M is 14.5-17.5MHz.   And OSC20M is 18.5-21.5MHz.

So you can't get 12MHz with OSC20M div2

 

I suggest that you just try the out-of-spec behaviour.

Seriously.   There are lots of other makes.   There are lots of real hardware USB controllers.

 

From memory,   there are several "cheapskate" V-USB projects that use non-12MHz F_CPU.

 

Since you are probably not doing a Guided Missile,   the non-12MHz V-USB would be "good enough".

 

David.

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

From https://hackaday.com/2012/12/03/... :

 

USB 1.0 : low-speed 1.5 Mbps, full-speed 12 Mbps (low-speed * 8)
USB 1.1 : + hub support
USB 2.0 : + high-speed 480 Mbps
USB 3.0 : + super-speed 5 Gbps (with appropriate cable)
The speed is signaled by the device with pull-up resistors on D-/D+ lines.
Low-speed supports only “interrupt” transfers in very small packets, bulk transfer endpoints are not allowed (in order not to saturate the bus with slow bulk transactions).

This project is obviously a low-speed USB device.

There is nothing magic about bit-banging a serial protocol.
For transmission you can always send data at CPU clock speed or at least half CPU clock speed, easy.
For reception, there is a clock recovery problem. Without clock-recovery hardware (like PLL), the only way to receive data is to oversample it, 8 samples per bit is a minimum with quartz clocks. So for low-speed USB you need at least a 12 MHz CPU clock/sampling.

Now USB is very painful to bitbang because it requires bit stuffing (at least one forced line transition every 7 bit times) and CRC checksums. If the uC isn’t fast enough to do it on the fly, it can always pre-calculate the bit stuffing and the checksums.

All in all, any 12 MHz uC can do low-speed USB in a more or less efficient way.

This means that you can modify the library and use 13.5, 15, 16.5, 18, 19.5 or 21MHz clock. If the RC is not accurate enough, you can use the 32768 quartz and on an interrupt lets say every second, check a timer driven by the main clock and adjust the RC continuously.

Edit: 16.5, not 16.8

Last Edited: Thu. May 9, 2019 - 02:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

extronic wrote:
Have they really forgotten about crystal oscillators?
Reasons :

One less failure point (crystal internal mechanical failure due to excessive acceleration rate, ESD/EFT/lightning induced upset of a crystal oscillator due to excessive di/dt under the MCU)

megaAVR 0-series UART have FBRG and auto-baud.

extronic wrote:
Do I need to buy 10x more expensive integrated clock generator instead of mere crystal?
No; calibrate 16MHz vs 32KHz then adjust V-USB from 12MHz to 16MHz.

ΔfOSC20M = 0.75% (Calibration step size)

USB low-speed's accuracy is 1.5%.

 

AN_8002 AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC

USB in a NutShell - Chapter 2 - Hardware | Data Signaling Rate

 


ATMEGA4809 - 8-bit AVR Microcontrollers - Microcontrollers and Processors

 

edit : quote

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Thu. May 9, 2019 - 02:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Every Silicon vendor has been adding crystal-less USB controllers.

In other words they have developed stable RC oscillators that are accurate enough for USB.

PIC18F25K50 - Microcontrollers and Processors

...

  • Internal 48MHz Oscillator with USB Accuracy -Via Active Clock Tuning from USB Host

...

(USB host controller creates an accurate USB SOF signal)

USB megaAVR are low-speed capable without a crystal.

ATmega32U4 - 8-bit AVR Microcontrollers

...

Crystal-less operation for Low Speed mode

Am guessing that megaAVR 1-series may be the follow-on to USB megaAVR.

 


PIC18F25K50 :

Pololu USB AVR Programmer v2.1

 

"Dare to be naïve." - Buckminster Fuller