Arduino @ 8MHz instead of 16MHz

I have a few question regarding running the Atmega328P-PU at 8MHz instead of 16MHz. I'm looking to do a battery powered Arduino, so I'm considering the slower clock speed so that when the battery runs low, it'll still run stable.

  1. Is there a difference between using the internal 8MHz clock oscillator on the Atmega328P-PU vs. using an external 8MHz discrete oscillator? If it doesn't make a difference, I'd rather use the internal one to save on component cost.

  2. I'm still new at this, so this is a really basic question. The Atmega328P-PU with the Arduino bootloader already loaded, can those be configured to use the internal 8MHz osciallator? Or do I have to buy a blank Atmega328P-PU, load the boot loader myself, and in the process, configure it to run at 8MHz. I'm not sure what are all the steps required to make the AVR run at 8MHz.

  3. Does running at 8MHz instead of 16MHz make a difference on the sketches you use? Can a sketch that works on a 16MHz Arduino also run on an 8MHz Arduino? How does the slower clock speed effect SPI devices like wireless modules connected to the Arduino?

arusr:

  1. Is there a difference between using the internal 8MHz clock oscillator on the Atmega328P-PU vs. using an external 8MHz discrete oscillator? If it doesn't make a difference, I'd rather use the internal one to save on component cost.

The internal oscillator isn't very accurate. Things like serial port which rely on critical timing might stop working.

arusr:
2) I'm still new at this, so this is a really basic question. The Atmega328P-PU with the Arduino bootloader already loaded, can those be configured to use the internal 8MHz osciallator?

Yes.

arusr:
3) Does running at 8MHz instead of 16MHz make a difference on the sketches you use? Can a sketch that works on a 16MHz Arduino also run on an 8MHz Arduino?

Most will still work.

arusr:
How does the slower clock speed effect SPI devices like wireless modules connected to the Arduino?

SPI will work but data will transfer at half the speed.

I read your questions different than fungus.
For 8MHz you need a new bootloader, but there is already an Arduino board using the ATmega328p with 8MHz : the Lilypad
http://arduino.cc/en/Main/arduinoBoardLilyPad
If you make your board compatible with that, you can use the LilyPad bootloader.

A sketch is compiled for 16MHz or 8MHz, so all clocks speeds are taken into account.

As fungus wrote, the serial baudrate might be less accurate.

Please read this carefully: The power dilemma
The Arduino can enter sleep mode. If the Arduino is running during 1ms and sleeping during 9ms, it uses only 10% of the energy.
Suppose you have it running at 8MHz and everything takes twice as long. So instead of running 1ms, you need 2ms. That will reduce the power saving a lot. In some very special situations the lower clock speed might even result into a higher total power usage.

Caltoa:
Please read this carefully: The power dilemma
The Arduino can enter sleep mode. If the Arduino is running during 1ms and sleeping during 9ms, it uses only 10% of the energy.
Suppose you have it running at 8MHz and everything takes twice as long. So instead of running 1ms, you need 2ms. That will reduce the power saving a lot. In some very special situations the lower clock speed might even result into a higher total power usage.

But the slower the clock frequency, the less current drawn by the MCU. At 5V, going from 16MHz to 8MHz just about cuts it in half. No need to use 5V at 8MHz, though. Using 3.3V at 8MHz will result in roughly one-third the current as 16MHz @ 5V. See the data sheet. But yes I wouldn't be surprised if there were some special cases where a slower clock resulted in higher energy use.

Beware however, the MCU is not the only component on an Arduino board that draws power. While the MCU can sleep, other components cannot. See: When sleeping helps - #34 by JChristensen - Microcontrollers - Arduino Forum

Also, the internal RC oscillator can be calibrated so that it should be accurate enough for serial comm.

Caltoa:
I read your questions different than fungus.
For 8MHz you need a new bootloader

You might not need a bootloader at all. If you use an ISP device to program the chip.

The old bootloader should work if you edit "boards.txt" and halve the baud rate setting.

Caltoa:
Please read this carefully: The power dilemma
The Arduino can enter sleep mode. If the Arduino is running during 1ms and sleeping during 9ms, it uses only 10% of the energy.
Suppose you have it running at 8MHz and everything takes twice as long. So instead of running 1ms, you need 2ms. That will reduce the power saving a lot. In some very special situations the lower clock speed might even result into a higher total power usage.

Lower clock speeds use less power. It's a thing you have to study on a case-by-case basis.

Another consideration is that he wants to power it with 3xAA batteries. 3xAA is on the limits of acceptable voltage for 16MHz operation. 3xAA is completely safe at 8Mhz.

I just read that the Lilypad uses an external resonator. Sorry for that, it does not use the internal oscillator.

Caltoa:
I just read that the Lilypad uses an external resonator. Sorry for that, it does not use the internal oscillator.

Anything which uses a serial (RS232) bootloader will probably have external clock. The bootloader won't be reliable otherwise.

Caltoa:
I just read that the Lilypad uses an external resonator. Sorry for that, it does not use the internal oscillator.

I'm fairly sure the original 168 based Lilypad used the internal oscillator. I believe they made the change when it was upgraded to a 328.

Personally I've never had a problem using 38400 as the baud rate with an 8Mhz 168/328 but maybe I've just been lucky.

FWIW,

Brad
KF7FER

Ah, thanks. So the things involved for making and running a 8MHz ATMEGA328P w/ an external oscillator:

  1. Burn the correct bootloader (8MHz bootloader, not the one for 16MHz)
  2. Fuse the pin to use external bootloader
  3. Compile the .ino for 8MHz

This helps me figure out what I need to google so I don't miss something. Thanks.

Why change any hardware (crystal, intern clock, etc)? Why not simply use the prescaling function in ATmega328? See chap. 8.11 System Clock Prescaler. In Cosa the following member function is available.

void
Power::clock_prescale(uint8_t factor)
{
  if (factor > 8) factor = 8;
  synchronized {
    CLKPR = (1 << CLKPCE);
    CLKPR = factor;
  }
}

And then there are all the Power Management functions. Below is a link to a Blink sketch that uses three threads (each with 60 byte environment) that runs on ATtiny85 and uses only 10-15 uA when the LED is off.

Another Cosa low power example sketch is:

This sketch demonstrates a number of different strategies to reduce power.

Cheers!

kowalski:
Why change any hardware (crystal, intern clock, etc)? Why not simply use the prescaling function in ATmega328? See chap. 8.11 System Clock Prescaler. In Cosa the following member function is available.

Another thing I didn't know about. So, these tactics decrease power consumption, but do they make it run more stably at lower voltage?

Besides which, I think if I don't take out the voltage regulator for a battery powered application, the regulators would just eat too much power.

When the clock divider is used, the bootloader and the first code is running at 16MHz.
That is not reliable with a low voltage.

When the clock divider is used, the bootloader and the first code is running at 16MHz.
That is not reliable with a low voltage.

May not be reliable outside a narrow temperature band.... Or, most appropriately said, Atmel dies not guarantee it to work at all. But, it likely will especially if used inside with environmental conditioning we humans demand for our comfort.

Rasy

In my world, the specifications are not like rubber bands.

In my world, the specifications are not like rubber bands.

If we were using the AVR in a commercial product, I would agree. But "Arduino" used in education and hobby for ones own use certainly begs to be contorted in any dimension that will work for the owner... The caveat being that the Op understands that the manufacturer does not guarantee operation in that mode.

The Atmega328 has been a around for a number of years and it is likely that early production runs may have been more sensitive to voltage-frequency issues in the clock section. In the two years I have used the 328P-PU at 16MHz and 3.3V, I have yet to have a single failure... Perhaps 15 builds. I will say that I do use first-quality crystals and load caps.... No junk-box parts. Even the 328Ps are purchased prime in quantity. I have yet to flame a 328, but I have run them hot- at $2, who cares?

Rubber-banding specifications is a ligimate hobby experience: the entire over clocking of electrical components is no different than any other extreme sport... Except we are not using bikes, motorcycles, or automobiles and unless we blow up our basement lab (guilty here with my rockets) no one is put into harms way.

So forum dudes and dudettes, Atmel says they do not support 16MHz @3.3 Volts. But, it will likely work and in my experience, it has worked 100% of the time.

Ray

So forum dudes and dudettes, Atmel says they do not support 16MHz @3.3 Volts. But, it will likely work and in my experience, it has worked 100% of the time.

I have have often run 16Mhz arduinos at 3-4 volts with no problem. Everything you say is correct. Nevertheless your noise margins and other potential problems become more probable.

The main issue is that LiPo cells do not match exactly to our traditional favorite voltages. A bit of "rubber-banding" is OK for casual hobby projects.

Servos are another example. They are specified for "4-6 volts" - a poor match for Lithium. Actually I have used them at 3.3 to 7.5 with no problem.

Joe

A bit of "rubber-banding" is OK for casual hobby projects.

Exactly.
As long as you have the knowledge that you are on your own... Manufacturing techniques improvement and manufacturers' headroom are not reflected in the official data sheets.
caveat emptor!

Ray

  1. rasy is right. except its "caveat insurancium compania". ive personally run torture benchmarks on several part numbers for 3v@8mhz from freezing to boiling w/o issues. ok for hobby. apparently many commercial too judging from the market.

  2. osc drifts very little during temperature but more for voltage. rs232 is workable for direct lipo power (4.2-3.6v) but only if properly calibrated at median. the real problem is divisors just dont work out for 115kbaud @8mhz. thats why a reasonably designed bootloader would choose 57k as default. little to do with osc stability.

  3. no need to change bootloaders going from 16mhz to 8mhz. one size fits all. simply use next baud rate down.

  4. regulators would not "just eat too much power". ldo which is the only type that makes sense here draw picoamps.

  5. "code" is not always a mass noun. ie "morse and enigma codes proved useful during the war".

ps lipo or 3 rechargeable aa cells no regulator are personal favorites for 99% of my projects. they are really interchangeable.

john1993:
5. "code" is not always a mass noun. ie "morse and enigma codes proved useful during the war".

Haha, yes I know, I've been waiting for someone to call me on that one. Of course what I mean is, "The word code, when used to refer to instructions written in a computer programming language, is a mass noun..." but I went for brevity and figured context would carry the day.

Morse and Enigma are ciphers, not codes, although I am aware that the word code is applied to both ciphers and true codes in non-technical situations.

lol! obviously i was just trolling for trouble with that one.

seriously though, arduino chips are just about the best of the bunch for directly powering from batteries with 3v-4v being a good range. i forgot to mention the highly popular 3.3v dc supply fits right in there and that can be had from just about every ftdi dongle. " we doe neeeeed no steeenkin' 5v"