Arduino Forum

Using Arduino => Microcontrollers => Topic started by: mcnobby on Nov 20, 2014, 10:38 pm

Title: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Nov 20, 2014, 10:38 pm
I have been using 32mHz crystal oscillators on my projects for some time now without any crashes or ANY noticable heat from the processor.

Instead of the 16mhz crystal the parts I use are like these
http://www.ebay.co.uk/itm/201074903412 (http://www.ebay.co.uk/itm/201074903412)

You cant just use a 32mHz CRYSTAL because the micro isnt able to drive it properly, so therefore it must be a TTL CRYSTAL OSCILLATOR (as above)

I created a new entry in boards.txt to cover the new chip frequency (for example)

Code: [Select]

uno32.name=Arduino Uno 32mhz
uno32.upload.protocol=arduino
uno32.upload.maximum_size=32256
uno32.upload.speed=115200
uno32.bootloader.low_fuses=0xff
uno32.bootloader.high_fuses=0xde
uno32.bootloader.extended_fuses=0x05
uno32.bootloader.path=optiboot
uno32.bootloader.file=optiboot_atmega328.hex
uno32.bootloader.unlock_bits=0x3F
uno32.bootloader.lock_bits=0x0F
uno32.build.mcu=atmega328p
uno32.build.f_cpu=32000000L
uno32.build.core=arduino
uno.build.variant=standard


This WILL affect your BOOTLOADER as it will be running a 2x speed, you can solve this problem by one of two ways:
(1) Dont use the bootloader, only upload via USBISP etc etc
(2) Put some clever switch to switch between 16mhz (serial upload) and 32mhz (operational) clocks

There could be a few issues regarding your peripheral devices, for example using LCDs, perhaps SPI problems, and obviously serial is cracking away twice as fast so your debugging speed will need adjustment.

LIBRARIES:

so far, in the LiquidCrystal library, I found that the following mod fixed writing problems

Code: [Select]
void LiquidCrystal::pulseEnable(void) {
  digitalWrite(_enable_pin, LOW);
  delayMicroseconds(1);   
  digitalWrite(_enable_pin, HIGH);
  delayMicroseconds(1);    // enable pulse must be >450ns
  digitalWrite(_enable_pin, LOW);
  [b]delayMicroseconds(200);[/b]   // commands need 200us if using 32mHz xtal (was 100us)
}


As yet I havent found any issues when using internal EEPROM and the EEPROM library

I have been using 32mHz on ATMega328P_PU (DIL) and ATMega328P_AU (QFP32) chips so far without problems, and I shall be trying many more as I get them

This may be well outside the 20mhz specification of the atmel device, but sometimes its worth a little extra nitro to squeeze a bit more out, just for fun.

NOTE: Please do this at your own risk, even though I havent had a problem there is no guarantee that your device wont kick the bucket, blow up in your face, or set off world war III !

Regards Bob
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: ChilliTronix on Nov 20, 2014, 11:51 pm
Well done. If I want to over clock I now know how....
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: DrAzzy on Nov 21, 2014, 12:25 am
Am I missing something?

I would think that if you set uno32.build.f_cpu=32000000L, delay should work correctly, without having to change delay lengths...
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Nov 21, 2014, 07:47 am
Am I missing something?

I would think that if you set uno32.build.f_cpu=32000000L, delay should work correctly, without having to change delay lengths...
Well I think you are correct, but if you are talking about the amendment in liquidCrystal.cpp then its because the HD44780 chip needs >37us to set the command, I tried it at the 100us delay and the display was crashing, adjusted to 150us still the same, 200us worked fine.

It may be worth checking each timing-based function you may use. When I use a 32mHz clock, I just go through everything and work out what MAY be affected, perhaps even do a few solo tests in a clean sketch etc

Regards
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Nov 21, 2014, 08:26 am
In Arduino.h I found this...

Code: [Select]

#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )


so with that, millis() and micros() should work as intended, unless micros() is timer interrupt triggered based on a number rather than a function.. I shall look into this
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: cyclegadget on Nov 22, 2014, 12:21 am

 I am surprised that more people aren't interested in testing 32mHz... at least just for fun. Would you be able to share how you wired the crystal and what "extra" parts you use to make it work?


 Thanks for posting!
Mark
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: john1993 on Nov 22, 2014, 01:19 am
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.

this is great for fun but be aware there is potential for damage. not from heat like overclocking a pc cpu as many think but damage to the flash structures. atmel makes it clear flash and eeprom cell programming is not recommended over 10% of nominal clock speed. i verified that spm at highest limit does indeed result in failure. constant erase cycles caused measurable retention time deficit in minutes or hours overclocked while same routines within spec went for weeks. few tens of thousands vs at least couple million.

moral of the story: if you overclock dont write to flash.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: rogerClark on Nov 22, 2014, 01:38 am
I don't know if you can program them to have a default frequency, but using an AD9850 function (square wave) generator module for the clock would be interesting.

i.e you could dynamically increase the frequency using the device its self

not sure about initial boot though from cold / no power
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mrburnette on Nov 22, 2014, 03:43 am
You can lower the clock core frequency before flash/EEPROM critical write functions.
From change-the-frequency-of-my-atmega (http://electronics.stackexchange.com/questions/87185/how-can-i-change-the-frequency-of-my-atmega168)

Code: [Select]
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

Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Nov 22, 2014, 10:40 am
Interesting views - as I said I havent had any problems YET

Ray, thats an interesting concept for the frquency drop before eeprom write, I do use eeprom within the app, but I am guessing it doesnt matter much about the frequency when programming via USBASP ??

I also tried using standard xtals, I bought a range to try, I could only get to 24mHz before it became hit and miss...

I have dozens of 20/24/25/32 mHz crystals if anyone wants them !! :)
Title: Re: 32MHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: AWOL on Nov 22, 2014, 10:47 am
Quote
I have dozens of 20/24/25/32 mHz crystals
I very much doubt that ;)
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: john1993 on Nov 22, 2014, 02:49 pm
Interesting views - as I said I havent had any problems YET
probably wouldnt ever because not many people reprogram tens of thousands of times. typically a few dozen or hundred. and you might not notice that the 10-20 yr retention spec was compromised.

eeprom tolerates about an order of magnitude more cycles so unless writing constantly wouldnt notice there either. rare applications that reprogram flash a lot and need long data storage might have a problem though.

also worth noting that the programming timer is not influenced by clk prescale so while slowing the cpu helps with power consumption, it does not fix the flash retention problem.

I also tried using standard xtals, I bought a range to try, I could only get to 24mHz before it became hit and miss...
glad to see you were able to duplicate my own crystal experiments.

they are so cheap i also have dozens of different crystals, even hundreds for common values like 16mhz.  not that unbelievable.
Title: Re: 32MHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: AWOL on Nov 22, 2014, 03:26 pm
Quote
even hundreds for common values like 16mhz.  not that unbelievable.
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.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Nov 22, 2014, 03:44 pm
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.
Ah, I get it now... 20/24/25/32 mhz = 1041 hz :)
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Nov 22, 2014, 03:45 pm
or perhaps you meant I spelled Mega Hertz with a small M, so its milli Hertz !!

That really HURTZ !! ha ha
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Jan 21, 2015, 08:05 pm
UPDATE : I have tried & tested 32MHz crystal oscillators on many ATMega328, ATTiny85, and ATTiny13A (all 20MHz variants) I have decided to push things to the limit...

I have ordered one 40mhz oscillator for testing.. these things run at a juicy 40ma plus more current drawn from the microprocessor because of the extra speed.

I shall revisit with my results soon :)


Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: ChilliTronix on Jan 21, 2015, 11:22 pm
Do you feel the need for speed?
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mrburnette on Jan 22, 2015, 05:05 am
Do you feel the need for speed?
IMO..

Not just speed, but the thrill of the chase.

Ray
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: westfw on Jan 22, 2015, 07:18 am
For a while, I was thinking that one of the new XMega chips running at 32MHz would be a useful addition to the Arduino line.   Now, I just think that anyone who needs the speed should jump to one of the ARM boards.

Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: CrossRoads on Jan 22, 2015, 08:18 am
Yes, make those LEDs blink really fast ... even faster delay() for button pushes ...
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Jan 22, 2015, 08:22 am
Ha ha, thanks all !!

westFw, I have been thinking about the arm stuff, even to the point of getting several stm32f1 boards after the (now very long) topic was started on here.

for me its not a simple jump, I write in C AND assembler, the task of learning the 32bit assembly and all the register manupulation didnt suit me too well as I am just about coping with 8 bit !!

:)

Crossroads, it is mainly for multicolour VGA purposes, I really need the speed !!
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: westfw on Jan 22, 2015, 10:31 am
Quote
for me its not a simple jump [to ARM]
This online class has just started, and I highly recommend it.  If you already have experience programming AVRs in C and assembly, you'll be well ahead of "median" background, but it's STILL a good introduction to ARM programming...

https://www.edx.org/course/embedded-systems-shape-world-utaustinx-ut-6-02x (https://www.edx.org/course/embedded-systems-shape-world-utaustinx-ut-6-02x)
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Jan 22, 2015, 08:36 pm
Cheers WestFw, I think I would need to sign up as I cant see much on that page/link
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: westfw on Jan 23, 2015, 03:09 am
Link with no-login-required info (also, previous post "fixed"):  https://www.edx.org/course/embedded-systems-shape-world-utaustinx-ut-6-02x (https://www.edx.org/course/embedded-systems-shape-world-utaustinx-ut-6-02x)
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: nickgammon on Jan 24, 2015, 06:26 am
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.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: nickgammon on Jan 24, 2015, 06:31 am
I very much doubt that ;)
Annoyingly, the proper capitalization of 1,000 is k but 1,000,000 is M.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Jan 24, 2015, 08:26 am
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.
Yes Nick, I got that far too, but then realised I had to switch to a TTL clock gen for higher speeds as the micro wasnt able to drive the crystal or something, I cant remember the full reason but thats in the past now

:)
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: cyclegadget on Feb 19, 2015, 02:36 am
@mcnobby,

I have looked for the crystal that you are using but, have not found a cheap way to buy a crystal just for playing around. However, I ordered a breakout board last night that may prove interesting!
Adafruit Si5351A Clock Generator Breakout Board - 8KHz to 160MHz
http://www.adafruit.com/product/2045

The breakout board is not practical for a finished product but, it will allow me to find out how fast an Arduino can go. :)
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Feb 19, 2015, 06:41 pm
I have looked for the crystal that you are using but, have not found a cheap way to buy a crystal just for playing around.
I have been using THESE (http://www.ebay.co.uk/itm/231251490155). they are about £0.19p each in qty of 10, but they are surface mount which can be a problem if you just use standard mount

I did find some surplus stock standard mount ones on ebay, bought a load for testing/playing very cheap, I have had a look but cant find them anymore
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: DrAzzy on Feb 20, 2015, 06:28 pm
Neat stuff. Sounds like a good omen for trying to make the ATTiny's that are normally spec'ed only to 12mhz run at 16mhz like a normal Arduino.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: Tom Carpenter on Feb 22, 2015, 07:32 pm
Which ATTiny's are spec'ed at 12MHz? The t84 and t85 are both rated up to 20MHz...
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: aldolo on Jan 09, 2018, 05:01 am
Hi. Are you still here? I wonder how you can remove the crystal and replace it with an external clock without changing the fuse bits before. It seem a chicken and egg problem. Have you burned the bootloader with the fuse and then changed the circuit?
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: Budvar10 on Jan 09, 2018, 01:12 pm
It is absolutely no problem, but once if the chip is set to use external clock or crystal, it (clock signal generally) must be present otherwise the MCU will not start. So, just replace the crystal. Of course, the bootloader have to be changed for exact frequency.
However I'm not recommending to use 32MHz. I have some experience with overclocking on ATmega1284P. Some features doesn't work at higher frequency as 25MHz, e.g. prescaler for ADC. I had the best results with 24MHz. The MCU works reliably at 24MHz, no getting a heat and all features seem to work.
...but 328P can be different story!
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Mar 05, 2018, 12:30 pm
Hi All

I am currently overclocking an ATTiny13A to about 16MHz on INTERNAL resonator, just by setting it to 9.6MHz internal resonator, then writing OSCCAL to 255 (I think only 7 bits are actually used), this then doubles the 9.6MHz internal clock approximately. If you dont need to worry about exact timing then this is great fudge.

I use this for receiving and decoding an 800KBPS data stream and driving a servo from the data and it works a treat as I continually sync on the start/high transition of each bit and sample in the middle, so probably even 1MHz either way would still work

The ATTiny13A does not have pins for a standard xtal, and can only be driven externally by a TTL Clock oscillator, so I chose the method above for cost and simplicity

This overclock can also be done on an ATTiny45/85, so I believe (although you can use a standard xtal with those)

Bob
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Mar 05, 2018, 12:33 pm
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 !
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: Budvar10 on Mar 06, 2018, 08:14 am
... 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.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Mar 08, 2018, 10:46 am
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
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: Budvar10 on Mar 08, 2018, 02:17 pm
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.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: mcnobby on Mar 08, 2018, 05:39 pm
I also bought some 40MHz clock oscillators, but never got round to testing them :)
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: krupski on Mar 09, 2018, 09:46 am
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.


Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: krupski on Mar 09, 2018, 09:50 am
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?
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: krupski on Mar 09, 2018, 09:58 am
You can lower the clock core frequency before flash/EEPROM critical write functions.
From change-the-frequency-of-my-atmega (http://electronics.stackexchange.com/questions/87185/how-can-i-change-the-frequency-of-my-atmega168)

Code: [Select]
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.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: krupski on Mar 09, 2018, 10:00 am
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?
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: krupski on Mar 09, 2018, 10:03 am
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).
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: Budvar10 on Mar 12, 2018, 06:48 pm
@mcnobby
Seems like some AVRs are discontinued under Microchip, e.g. ATmega2560 is not on product list anymore.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: westfw on Mar 12, 2018, 07:32 pm
Huh?  http://www.microchip.com/wwwproducts/en/atmega2560 (http://www.microchip.com/wwwproducts/en/atmega2560)
Don't be fooled by the "new and popular" listing you get on the AVR landing page.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: Budvar10 on Mar 12, 2018, 07:48 pm
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. :)
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: alans7077 on Jun 11, 2018, 07:01 pm
hello guys,
reviving the post, for need for help
I've ran out of clock with my apa102 POV toy with nano

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

Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: Budvar10 on Jun 12, 2018, 08:35 am
Quote
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.

Quote
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.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: krupski on Jun 14, 2018, 11:45 pm
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)
(http://forum.arduino.cc/index.php?action=dlattach;topic=280417.0;attach=262275) (http://forum.arduino.cc/index.php?action=dlattach;topic=280417.0;attach=262275)


(full swing)
(http://forum.arduino.cc/index.php?action=dlattach;topic=280417.0;attach=262277) (http://forum.arduino.cc/index.php?action=dlattach;topic=280417.0;attach=262277)


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).
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: alans7077 on Jun 15, 2018, 04:50 pm
@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 :)
 thank for your kind replies , wait for my results soon
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: alans7077 on Jun 19, 2018, 01:05 pm
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 :)

Thanks for the post, guys.
Title: Re: 32mHz ARDUINO PROJECTS.. ATMega328P etc...
Post by: Budvar10 on Jun 20, 2018, 08:45 am
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.