Looking for info on running at 20mHz

Can anyone point me to / explain information about what is entailed in running the Arduino with ATMEGA328 at 20mHz?

Do I have to reburn the bootloader? What is needed to do this if so? Are there consequences in software, or other gotchas I need to watch out for if I do this?

I've used 20MHz crystals in a couple of stand alone Arduino applications and it was OK apart from running a bit faster. Going a bit faster shouldn't be a problem unless you had time critical delays, used the com port or the PWM output for servos etc.


You probably mean 20 MHz and not mHz.

mHz: Milli Hertz MHz: Mega Hertz

You are correct. I mean 20MHz.

Regardless, could someone let me know how this can be done?

Some specs:

I don’t care about serial monitor. I only care about being able to code in Arduino IDE and compile. So if I can do this and then program the Arduino without it having the bootloader, that is totally fine with me.

I’m essentially curious what I would need to do in order to be able to:

Buy a clean Atmega328
Attach FTDI for serial and a 20MHz external crystal
Program some Arduino code onto it

And am wondering if there would be timing issues I’d have to worry about, or anything else. What machine code does Arduino compile into? When does it set the clock speed for the Atmega?

Attach FTDI for serial

Since you don’t care about the serial monitor, or using a bootloader, I am not sure what you need the FTDI cable for; instead, you should use an ISP programmer. Once you have compiled your sketch, there should be a binary/hex file created, that you can then use avrdude (or maybe even the IDE, can’t remember) to upload via the ISP programmer.

You will need to change some fuses on the ATMega to get it to work at 20 MHz (but then again, I think you need to do this for 16 MHz operation anyhow).

Finally, realize that certain routines involving the timer interrupts won’t work the same (mainly things like PWM - ie, analogWrite) because of the timing differences (you can alter the library, though, if you wanted to).

There’s probably a few other things you might have to do; I am not an expert on any of this, I have never tried it, I just know what I have heard from others and from what little I have read about the process.

Good luck!


Got it. I have a PicKit2 programmer, any change I can repurpose that to program an Atmega? And does anyone know of a post or tutorial that summarizes the pros/cons/steps completely?

I need the FTDI breakout because I am going to be doing serial communication, it's just I don't need to use the IDE serial monitor to do it...

ORRRRR - would this work:

I just program this Atmega328 by popping it in a Duemilanove, then pulling it out to put in my breadboard that has a 20MHz resonator and FTDI breakout.

Would it just run correctly at 20MHz then? I will only be using analogRead, Serial.print, and setting digital pins high and low. No PWM.


I need the FTDI breakout because I am going to be doing serial communication, it’s just I don’t need to use the IDE serial monitor to do it…

This thing has worked well for me. It’s a programmer and a TTL serial port (and a SLO-scope)…

If you add the following to your hardware/arduino/boards.txt, I think the arduino core itself should compile just fine and run things (including serial and millis/delay/etc) correctly even at 20MHz (the entry should just appear in the TOOLS/BOARDS menu.):


atmega32820M.name=Arduino Duemilanove ATmega328 20MHz




(this is a copy of the atmega328/duemilanove defintion with build.f_cpu changed, and a new name.)

I'm not sure that the new bootloader speed will work, but it MIGHT...

Alright, I'll give it a try!

I tried it. You get this message:

avrdude: serial_baud_lookup(): unknown baud rate: 72000


Search the forums for a lot of discussion and solutions on this topic.

Here's where I posted a zip file with custom bootloaders and board definitions: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1240016311/17#17