Using Arduino As AvrISP With Avrdude

Arduino IDE is a great environment for getting started with programming a microprocessor. It greatly simplifies the learning curve. The integrated development environment is very beginner-friendly and is really the perfect starting point.

But if you really want to be any good at programming microprocessors,  C/C++ is the way to go. But the problem with this approach is that you need to compile ( ie. Convert the C++ code into something that is machine readable like a .hex or an .ihex file ).

The Arduino does all this behind the scene using avrdude. If you have Arduino installed, you will find avrdude files in your Arduino directory ( My/Arduino/Folder/arduino-xxxx /hardware/tools/avr). When you are uploading the file, Press Shift and then click on Compile. “Shift” enables the verbose mode ( -v in avrdude) and hence gives you a glimpse of all that is happening behind the scene<CLICK ON THE IMAGE TO ENLARGE>

You will notice that  a lot of temporary files get created ( .o,.obj,.elf) and finally the .hex which gets uploaded to the atmega chip that rests upon the Arduino board.

So really all we need is a MakeFile that converts the C++ code into a hex file. In walks the mighty WinAVR.



1. Atmega chip that you want to program (I used an atmega328p)

2. An Arduino and the IDE ( This Arduino is used as a hardware programmer for the Atmega Chip).

3. WinAVR ( Mainly the Programmer’s Notepad and MFile)



All Arduino come with a bootloader loaded on them. It’s a piece of program that tells the atmega chip when to expect a program, which part of the memory to write it to and other important things. But what it basically does is lets you program the onboard chip without a hardware programmer. All you need is a USB A to B cable.

But when you are programming a standalone atmega chip you will need a hardware programmer. This work can be done by the Arduino.



1. Assuming you have installed the Programmer’s Notepad, Open a new C/C++ project.

2. Write a sample blink/hello world program. There are a lot of them available out there on the web. Here is one.

#include <avr/io.h>

#include <util/delay.h>

void delay_ms(uint16_t ms)







int main(void)


DDRC = 0x01;



PORTC &=~ 0x01;


PORTC |= 0x01;




To learn more on coding part, well the internet is the guide. Many datasheets also have a lot of info on ASM and C++ programming,but then you’ll have to sit  down and read the codes and understand them.

3. Save it as “main”

4. Open MFile.

5. Click on MakeFile

* Select the correct MCU type.

* Select the hardware programmer to avrisp

* Make sure the main file name is main

6. “Save as” the MakeFile into the directory where you saved your main.c

7. Open the main.c in Programmer’s Notepad again, and click on Tools -> Make All.

8. You will now have a hex file in the same directory. All we need to do now is to burn this hex file onto the target atmega chip.

9. Open the Arduino IDE, connect the Arduino and burn the Example->ArduinoISP onto your Arduino.

This converts your Arduino board into an AVRISP (AVR In System Programmer). You can now use the following digital GPI/O pins on the Arduino board as:

Digital 10: slave reset

Digital 11: MOSI

Digital 12: MISO

Digital 13: SCK

10. Make the necessary connections between your Arduino board (which is now an AVRISP) and the standalone atmega chip. Connect the MISO(Digital Pin 12) to your chips MISO. (Refer the datasheet). Similarly connect all corresponding pins and supply power to the standalone atmega chip using a regulated 5V power supply.VCC,AVCC and VREF Pins need to be brought up to 5V. Additionally, you could add an external crystal with 22pf capacitors but that would require tinkering with the code. Google it up for more knowledge on adding external crystals.

<coutesy: >

11. Connect your PC and arduino using the usb cable.

12. Open Command Prompt,Go to the directory which contains your hex file and run avrdude. It was automatically installed when you installed WinAVR.


avrdude –c avrisp –p <processor signature> -P usb  -u –U flash:w:filename.hex

-p indicates your MCU type. eg m328p for atmega328p etc.

-c indicates the programmer type. We made our arduino into an avrisp.

-u disable the fuse reading that is done 3 times

memtype:op:file -> memorytype(here flash) followed by operation where w stands for writing and filename  refers to the hex file that needs to be written.

Refer here for more info upon avrdude programming.

Now your standalone atmega is programmed with a hex file and is ready to work independently.

Feel free to comment your ideas on the topic. 🙂


About ranjanritesh

I am currently working as a Software Engineer for Cisco Systems India in Bangalore. I’ve been working for Cisco since August 2013. I am a BITS Goa Alumni. I earned my Bachelors in Electronics and Instrumentation in August 2013 from there. My interests include Image Processing, Systems Programming and hacking on the Linux Kernel. I also like tinker a bit with Arduino and other microcontrollers.
This entry was posted in Arduino, Open Source, Tutorial and tagged , , , . Bookmark the permalink.

2 Responses to Using Arduino As AvrISP With Avrdude

  1. akeel says:

    i cant understand step4 what is m file where does this came from? plz explain i am a beginner…

    • ranjanritesh says:

      Whenever you write a C/C++ program,you need to compile(and link) the program.This is handelled by makefile.
      Embedded C codes have specific way to compiling.Their makefile requires the information such as type of chip,programmer type etc.This helps is generating an executable that is best suited and optimized for the chip of your choice.
      You can make your own makefiles but it requires knowledge of how the compiler works. Instead,when you install Programmer’s Notepad and avrdude,a software called MFile is installed automatically.This has a template makefile where all you need to do is put the name of the correct MCU,programmer etc like I explained above.Thus compiling becomes lot easier as opposed to when you would have had to write your own makefile

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s