What needs to be done for using Atmega328 internal oscillator or 8Mhz crystal?

Hi Arduino experts,

I have 2 designs - one use internal oscillator and another use 8Mhz crystal. I am using Atmega328. What do I need to do for each of the 2 cases? I cannot see any code to initialize Arduino whether to use internal oscillator or crystal. Is it some hardware setting?

Thank you very much.

This can be set up via fuses.


note that 115kbaud serial can not be done reliably with crystal. its possible with internal oscillator using proper osccal register setting though.

I'm not an expert on this, but there are several variants in the boards.txt file [see path below] that will burn the bootloader into a 328 with 8 Mhz xtal, using an existing .hex file, so you might start there. Eg, Arduino Fio LilyPad Arduino w/ ATmega328 Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328

See the file, \arduino-1.0.3-windows\arduino-1.0.3\hardware\arduino\boards.txt

Then, when compiling a sketch, you need to select the board that matches the pin numbering you want to use. So, one section of boards.txt specifies bootloader, and another section specifies pin assignment for sketches.