Changing Arduino Clock Frequency / Programming ATMEGA 8 directly from Arduino Software using USBasp

Programming ATMEGA 8 is difficult because Arduino by default has a pre-defined clock frequency of 16MHz.

All the delay subroutine, PWM and Baud Rate generations are calculated using this frequency.

Programming ATMEGA 8 is difficult using this configuration, as ATMEGA 8 supports maximum 8 MHz clock frequency, or If you connect crystal other than 16MHz then serial communication will not work, delays and PWM will not be exact because default programming is done onĀ 16 MHz.

If you want to check, what is current clock frequency, you can check it by following steps: –

1. For Arduino versions less than 1.0, press SHIFT key and click on COMPILE/ VERIFY

– For Arduino versions greater than 1.0, FILE > PREFERENCES > select COMPILATION (as shown in Fig)

Arduino IDE Options

– Now when you COMPILE, it will show compilation progress

Showing Log and verbose in Arduino IDE

– Look at the starting few lines of Arduino Compilation, check -DF_CPU=4000000L
– This is the Clock Frequency at which Arduino is compiling (i.e. 4 MHz), which is set by Me (Arduino default was 16000000L)

– The clock instructions like #define F_CPU 4000000 does not work on Arduino
– All you have to do is changing the board configuration.

Changing Frequency for Particular Arduino Board:

– If you are not using original Arduino board, or want to use the programmer to upload the program to a Chip using ISP, then you need to configure Arduino clock frequency for the crystal / clock used with the CHIP.
– To do so, open Arduino directory > Hardware > Arduino > AVR >

– Now create a backup of boards.txt
– Now open Boards.txt
– Find the board for which you want to change programming frequency
– For Example: If we you want to program ATMEGA8 IC using USBasp Programmer, having clock frequency of 4 MHz then find Arduino NG or older change to and in ATmega8 section find Fuses and change it to your required Fuse values

We have set fuse values to:


– Now save the file

– Now check if the frequency is set or not, by COMPILING the program

Showing Log and verbose in Arduino IDE

Programming ATMEGA8 using USBasp from Arduino directly:

If you want to program ATMEGA 8 IC directly from Arduino via USBasp Programmer, then Open Arduino, write program, select Arduino NG or older

Arduino Board Selection in Arduino IDE

Now Select ATMEGA 8 in Processors:

Selecting Processors in Arduino IDE

Select USBasp in Programmer:

Selecting Programmer in case if user don't want to program Arduino board

Now connect USBasp programmer with PC and click Upload using Programmer:

Program using 3rd party Programmer via Arduino IDE

– That’s All – Enjoy !!!

2 Comments on “Changing Arduino Clock Frequency / Programming ATMEGA 8 directly from Arduino Software using USBasp”

Leave a Reply