Introduction: Programming AVR With Arduino As ISP Without Bootloader and External Crystal


Hey, I am riktronics , and this is my first instructable. Here I explained how to burn programs in your AVR microcontroller with an Arduino. By this, you won't need to purchase a costly AVR programmer if you already have an Arduino. And I guess you already have one.

Here you won't need any external crystal to be attached, neither need painful process to optimize "bootloader" for your standalone AVR. Just connect your arduino to microcontroller, and start uploading codes.


Step 1: Things You Need. (not Much)


1. A breadboard

2. 6 jumper wires and some extra wires.

3. An arduino board. ( I used arduino UNO)

4. a LED and a 220 ohms resistor.

5. 10 microfarad capacitor .(only if you are using older ardino boards such as duemilianove or NG, which don't have auto reset feature).

6. And of course the target AVR. Here I used ATmega8-16PU.

Step 2: Upload ArduinoISP Code on Arduino Board

The first step is the upload the ArduinoISP sketch to your Arduino to make it a programmer.It’s located under File >> Examples >> ArduinoISP. Ensure that the Board and Serial Port configuration is correct (under Tools), and then press Upload.

To check Serial Port, go to tools >> serial port. (for example, it may be "COM11 (arduino UNO)" ). note down that serial port number somewhere, soon you gonna need it.

Step 3: Open Command Prompt (in Windows OS)

When command prompt is opened, it will show you the root directory. it may be C:\> , or may be anything like C:\xx\yy\zz> . for me, it is C:\Users\Abhra Mitra> (see picture) . Whatever the root directory is, just note that down somewhere as very soon you gonna need it.

Step 4: Required Downloads..

Step 5: Installation of WinAVR (only Help for Windows OS Is Covered for Now)

Start installing winAVR and make sure if all three dialogue boxes are checked while installing. Don'tchange the installation directory from the default one, that is C:\winAVR. See pictures..

Step 6: Opening Toolchain Apps ( MFile[winAVR], Programmer's Notepad[winAVR])

After installation done, you may wonder where the hell the installed software is gone as you can't see that on desktop. so, you need to "search" with key word "winavr". see the picture given. you will have multiple results. you need two apps, MFile[winAVR], and programmer's notepad[winAVR]. Ignore rest of them.

Step 7: Editing "MakeFile"


Makefile is a file without any extension. It commands the compiler to upload the code according to target AVR's property and programmer's property. Hence, it's really really important to configure a appropriate Makefile. Without deep knowledge on AVR and C language, you can't make a Makefile. So I included a template. you just need to edit it as per your AVR IC.
1. Open MFile[winAVR].
2. now. Makefile >> Enabe editing of makefile >> (select it.).
3. now, File >> Open >> ( now navigate to where you have downloaded the Makefile).
4. now, you need to edit it. See the third image with red markings on it. Only the marked areas are needed to be changed by you. in "DEVICE" write your AVR's name. Here mine is atmega8. Yours may differ. If it's attiny2313, then write so. The "CLOCK" is set at 8000000 which implies 8MHz internal clock. Don't change it. Now come to "PROGRAMMER". you only need to change the COM port. I've told you in 2nd step to note down the COM Port number from arduino IDE. Just write that now. It may be COM4, may be COM3. Mine is COM11. Now you need to change the fusebit. Go to step4 and choose "fuse calculator" from my given links. A site will be opened named there select your AVR type and fuses will automatically be generated (see last image. that is fusebit of atmega8). Just copy and paste that after "FUSES" option. Don't forget to delete my fusebit before pasting yours.

5. All done. now save the file to your root directory. Don't save it any different place.(In step3 I have told you to note down the root directory from command prompt. )

Step 8: Editing Main.c

Open Programmer's Notepad[winAVR]. Select C/C++ from drop down. (see image). Now go to File >> Open >> (now navigate to where you have downloaded the main.c file.).

Open the file. The code is set to blink a LED connected to PD6 PIN at 1 Hz frequency. I am not going to explain details about the code here, but you can learn C for AVR from ladyada or from youtube. and much more sites are available for learning AVR coding.

Actually you need not change anything in code now. It's just a hello world code. now go to File >> save as >> (now save it to root directory, where you have also saved the Makefile).

Note: Makefile and main.c must be in same directory. and the directory must be root directory that you have found in command prompt in step3.

After you have saved it, now go to Tools >> [winAVR]Make All >> (click).

Compiling is successfully done if you have not done things wrong. see the last image. If all is OK, then you can see it on programmer's notepad's "Output" window.

Step 9: Circuit Diagram

This is the minimum circuit diagram to program an AVR using Arduino. I have given circuits for three very common AVRs. ATMega328p, ATMega8 and ATTiny2313. But following thee below PIN connection, you can easily program any AVR.

PIN MOSI of AVR to digital PIN11 of Arduino.

PIN MISO of AVR to digital PIN12 of Arduino.

PIN SCK of AVR to digital PIN13 of Arduino.

PIN RESET of AVR to digital PIN10 of Arduino.

PIN VCC of AVR to 5V PIN of Arduino.

PIN GND of AVR to GND PIN of Arduino.

To know the PIN configuration of your AVR, go to Atmel's website. In search bar, type your AVR's name. now, choose appropriate search result and select "datasheet" option. Download it and open. there you can see the PIN configuration. I am giving here atmega8 datasheet and pin configuration.

You may need to add a 10 microfarad capacitor between RESET and GND PIN in Arduino, only if your Arduino is older version and doesn't support auto reset. but if you are using UNO R3. MEGA or any newer version, you will not need it.

Make the circuit on breadboard without any loose connection.(see last 2 images). {my circuit is already coded, so green LED on breadboard is ON}



Now be very attentive and careful. Because, in following steps, we going to upload the compiled code to AVR using AVRDUDE. Urrgh, what is AVRDUDE? Okay, AVRDUDE is a command line software that comes with winAVR and makes the uploading process. To call AVRDUDE you need to open command prompt and then put correct commands to make it work as it is a command line software.

In AVRDUDE, we will define programmer type, AVR name, COM Port, baud rate (speed of uploading) and command to flash the defined .hex file.

Step 11: Know Your AVR's Code Name

You know your AVR's name, no doubt but you don't know it's code name which must be mentioned in AVRDUDE command line to upload the code. how can you know it? okay, you need to put a command, which will show you code names of all AVRs.

open command prompt >> (you can see the root directory is already written on screen) >> type the following code and press enter.

avrdude -c arduino -p xyz

It will open a chart of AVR names and corresponding code names.(see image 1).

now you know your chip's name. replace "xyz" after -p with your chip's name. If AVR is atmega8, command line will be,

avrdude -c arduino -p m8

Step 12: Set COM Port

I think you have noted down the COM Port already. Now make sure if your Arduino is connected to pc and AVR on breadboards is connected with arduino.

Now put this code on Command Prompt, (don't forget to replace my AVR's code name with your AVR's and my COM Port with yours COM Port). now press enter.

avrdude -c arduino -p m8 -P COM11

Again, type correct chip name and COM Port. Don't just copy paste this code.

Now it may give you a message like "your chip's signature is blah blah

expected atmega8 signature is blah blah and blah

check your chip connection or use -F to avoid it"

Do nothing. Just ignore it. Go to next step.

But, if you get any error message, fault is yours. double check all connections. set correct AVR name and COM Port.

Step 13: Upload HEX File to AVR

You are almost done. now it's time to upload the .hex code that is generated in root directory by programmer's notepad[winAVR] (at that moment when you have clicked on "make all" option).

Now in command prompt you need to put the command to upload the hex file (main.hex). use the below command but don't forget to change chip name and COM Port as per your AVR and PC, then press enter.

avrdude -c arduino -p m8 -P COM11 -b 19200 -U flash:w:main.hex

look at those images to get clarifications.

now you will see led on breadboard is blinking.

Done, code is uploaded.


Linux and Mac users can get help from YouTube video by Michael Holachek (VIDEO CREDIT GOES TO HIM, NOT TO ME).



For beginners, an awesome guidance to get started in electronics can be found HERE.

Arduino All The Things! Contest

Participated in the
Arduino All The Things! Contest