Sunday 4 June 2017

Use Atmega8 in circuit, programmed with Arduino Uno

Now you have programmed Atmega8 on Arduino Uno board and you want to place it on real circuit. But there is problem. On Arduino Board there is external crystal clock and in real circuit it is not there. To solve this problem, atmega8 need to set for internal clock while loading its bootloader.

Now I assume you have followed the procedure given in my blog http://nilyash81.blogspot.in/2017/01/burn-arduino-bootloader-on-atmega8.html. The blog explains about burning arduino bootloader on atmega8. Lets move ahead from there.


  1. Open Board.txt file in Vim editor. Search in file for  NG. You will find a line atmegang.name=Arduino NG or older.
  2. Change a line atmegang.build.f_cpu=16000000L to atmegang.build.f_cpu=8000000L. It will basically change cpu frequency from 16 mhz to 8 mhz. This way we can set any clock speed as per the need.
  3. Go to line ## Arduino NG or older w/ ATmega8. Below this line is block dealing with atmega8 and above it is a block deals with atmega168. We are focused on atmega8 block. In this fuse bits are set which decides about internal or external clock to be used.
  4. We want to use internal clock of atmega8. Hence change lines
             atmegang.menu.cpu.atmega8.bootloader.low_fuses=0xdf
             atmegang.menu.cpu.atmega8.bootloader.high_fuses=0xca


with

            atmegang.menu.cpu.atmega8.bootloader.low_fuses=0xe4
            atmegang.menu.cpu.atmega8.bootloader.high_fuses=0xc2


Save the file and again burn bootloader using usbasp (using programer). Now atmega8 is set to work with 8 mhz internal clock. Also upload the code using usbasp. Now your chip is ready to work standalone on veroboard or breadboard. You only need to connect 5v and ground to chip the code inside chip will start executing.

If you are lazy to edit Board.txt. You can download it from https://www.dropbox.com/s/pektx7if5dn9qxc/boards.txt?dl=0. Paste it at location C:\Program Files (x86)\Arduino\hardware\arduino\avr. Before you paste the file, it is better to backup original Board.txt file.

Thanks for reading......Keep coding.....