32mHz ARDUINO PROJECTS.. ATMega328P etc...

I have done many ATMega projects using 32MHz TTL clock oscillators and not found any heat problems, in fact not noticed and heat given off at all. I cant verify that any new microcontrollers still work as well since Microchip took over the AVR range and I believe they opened a new fabrication plant in Scandinavia and reduced some of the specs on devices from 20MHz down to 16MHz.. early 2017 from my memory anyway !

mcnobby:
... reduced some of the specs on devices from 20MHz down to 16MHz..

Which ones specifically? I checked the 328P and my favorite 1284P. Both are 20MHz and additional about 40 mega and tiny MCUs.

Which mega with 32MHz did you use? Try to check the ADC. I doubt it will work reliably - sample rate and the highest resolution. I tested 1284P. It seems to work reliably just up to 25MHz.

Hi, I just saw some notification last year, I cant remember the detail now but I think it had something to do with the maximum frequency using a standard xtal (maybe)
and with my overclocking I wasnt using ADC, just bit blasting
I was using ATTiny13A/85 and ATMega328/1284 with 32Mhz clock oscillator
I think I found that you can use up to 24Mhz standard xtals with some of the ATMegas

Hi!
I think, they use same fabrication process for all AVRs, so it is not as surprising that it works with 32MHz clock. You motivate me to test it at least on spare time.
It is some time ago, but I think Krupski had presented here ATmega2560 at 32MHz. This is only 16MHz MCU according the datasheet.

BTW: The link "www.smartshow.lighting" below your karma is incorrect.

I also bought some 40MHz clock oscillators, but never got round to testing them :slight_smile:

mcnobby:
I have been using 32mHz crystal oscillators on my projects for some time now without any crashes or ANY noticable heat from the processor.

I run my AVR boards at 22.1184 all the way to 29.952 without any problems. By the way, you don't need an OSCILLATOR to do this, just set your crystal drive from "low power" to "full swing" and it works fine.

john1993:
as mentioned a crystal cannot be used at that frequency, only an external oscillator. this is confirmed by my own tests. the fastest i was able to get with a crystal was 22mhz-24mhz depending on the cut and caps.

moral of the story: if you overclock dont write to flash.

Just set your low fuse from 0xFF to 0xF7 (full swing oscillator) and any reasonable crystal up to 32-something works fine.

As far as writing flash or eeprom, since those writes are timed by the internal R/C oscillator, the clock speed is irrelevant. Have you ever actually TRIED what you posted?

mrburnette:
You can lower the clock core frequency before flash/EEPROM critical write functions.
From change-the-frequency-of-my-atmega

Apart from that default loaded value you can change the clock prescale at will during runtime, all you need is to include the following header

#include <avr/power.h>
and call the following function with the appropriate value you want to use

clock_prescale_set(clock_div_1),    // divide by 1, for example with 20MHz clock result      20MHz
  clock_prescale_set(clock_div_2),    // divide by 2, for example with 20MHz clock result      10MHz
  clock_prescale_set(clock_div_4),    // divide by 4, for example with 20MHz clock result       5MHz
  clock_prescale_set(clock_div_8),    // divide by 8, for example with 20MHz clock result     2.5MHz
  clock_prescale_set(clock_div_16),   // divide by 16, for example with 20MHz clock result   1.25MHz
  clock_prescale_set(clock_div_32),   // divide by 32, for example with 20MHz clock result  0.625MHz
  clock_prescale_set(clock_div_64),   // divide by 64, for example with 20MHz clock result  0.312MHz
  clock_prescale_set(lock_div_128),   // divide by 128 for example with 20MHz clock result  0.156MHz
  clock_prescale_set(clock_div_256),  // divide by 256, for example with 20MHz clock result 0.078MHz
power.h manual

Not necessary. The AVR internal R/C oscillator times flash and eeprom writes. The cpu clock speed is irrelevant.

AWOL:
Yes, it really, really is.
In thirty odd years in the electronics industry, I have never, ever seen a single "20/24/25/32 mHz" crystal.

Ever see a DDS board?

nickgammon:
Interesting, I had found I could run at around 24 MHz (note the M) with a crystal but not faster. Now I am motivated to try faster clock inputs, excluding crystals.

Just remember to set your LFUSE from 0xFF to 0xF7 (full swing). And, contrary to what the "experts" here say, running at full swing doesn't draw any more current (at least nothing I can measure).

@mcnobby
Seems like some AVRs are discontinued under Microchip, e.g. ATmega2560 is not on product list anymore.

Huh? http://www.microchip.com/wwwproducts/en/atmega2560
Don't be fooled by the "new and popular" listing you get on the AVR landing page.

Aha! :o
Anyway, there is no direct path from PRODUCTS to ATmega2560. I had to choose any ATmega from offered "new and popular" and then simlar products.
Wrong!

I don' understand why the ATmega2560 isn't popular according their list. Personally, I think It is 2nd most popular ATmega. :slight_smile:

hello guys,
reviving the post, for need for help
I've ran out of clock with my apa102 POV toy with nano

krupski:
Just set your low fuse from 0xFF to 0xF7 (full swing oscillator) and any reasonable crystal up to 32-something works fine.

As far as writing flash or eeprom, since those writes are timed by the internal R/C oscillator, the clock speed is irrelevant. Have you ever actually TRIED what you posted?

@krupski , can I ask if I do that " 0xFF to 0xF7",
would I know what speed am I in?
or I just randomly falls to 22.1184 to 29.952 Mhz depends on voltage,crystall and luck?

Can I possibly get a 1000ms delay with delay(1000)?
Or am I getting speed without accuracy ?

thanks

can I ask if I do that " 0xFF to 0xF7",
would I know what speed am I in?

No, CKSEL3=0 bit just says that full swing oscillator is used. The frequency is given by crystal. If you want to use a crystal for higher frequency, you should use full swing osc. and Vcc = 5V. In the datasheet see 31.2 speed grades - safe operating area graph.

Can I possibly get a 1000ms delay with delay(1000)?
Or am I getting speed without accuracy ?

The delay function and all stuff around is designed with regard to frequency (wiring.c), but up to 24MHz (20MHz in older SW versions). The precision is decreasing for higher frequencies or if the frequency does not fit to exact value defined in wiring.c. The solution is to modify the wiring.c according your needs.

alans7077:
hello guys,
reviving the post, for need for help
I've ran out of clock with my apa102 POV toy with nano

@krupski , can I ask if I do that " 0xFF to 0xF7",
would I know what speed am I in?
or I just randomly falls to 22.1184 to 29.952 Mhz depends on voltage,crystall and luck?

Can I possibly get a 1000ms delay with delay(1000)?
Or am I getting speed without accuracy ?

thanks

The low fuse setting controls the oscillator MODE, not it's frequency. Using "0xF7" simply sets the crystal oscillator circuit to "full swing". To change the fuse setting, go into boards.txt and edit the value for the low fuse. If you put an oscilloscope on the crystal, you would see this (click pics for full size):

(small swing)
small_swing.jpg

(full swing)
full_swing.jpg

As far as getting correct timing, you need to edit your boards.txt file and change xxx.build.f_cpu=16000000UL to xxx.build.f_cpu=22118400UL (or whatever frequency you use).

@budvar10
@krupski

thanks, I took a in the datasheet pages about full-swing
so the stats full-swing drives the crystall with higher voltage and more currency,
and should be more stable from noise, am I correct?

Did the #1 @mcnobby uses 0xff and still met no problem?

btw, I use usbasp to upload my program
does that still takes settings in "boards.txt" ?

I've just ordered my crystall with 20&24&32 Mhz is and waiting for test :slight_smile:
thank for your kind replies , wait for my results soon

okay, heres are my results with 24 , 27.12 and 32Mhz

My hardwares:
atmega328p(tqfp32) + crystall (w/o 20pf)
2 SPI devices (apa102, SD)
4.2V Lithium battery power supply with extra 100uF cap(yes, for ultimate laziness!)
"bootloader.txt" modified for full swing and proper timing.

results:

32Mhz : burnable but not working, prorably due to no 20pf cap or low voltage
27.12Mhz :works, and I have to try many settings to let SPI devices work, but still unstable and resets randomly after minutes.
24Mhz: good, with default code(SPI) settings they worked well for my desired 12 minutes, and repeatable b2b. All the way down to 3.3V (battery's empty) and still fine.
16->24Mhz that's a 50% extra speed fore me, enough :slight_smile:

Thanks for the post, guys.

I had the best results with 24MHz also. The 328P and similar will have problems with the frequency above 25MHz. All interfaces which use clock signal which is derived from main clock are out of range for reliable run. On the other hand the VCC should be 5V. If you are using less than 5V, you should expect problems.