Use Arduino as an ISP programmer to program non-Arduino AVR microcontrollers

Program ATMega 16 using Arduino as ISP Programmer

After reading my recent tutorial on using Arduino code in non-Arduino microcontrollers, one of my readers asked me if it is possible to use Arduino as an ISP programmer to program these micro controllers, instead of using a separate dedicated AVR programmer.

The answer is a definite yes and I use it all the time, since I have a lot of Arduinos lying around. I thought of writing a tutorial, so that it will be useful for others who want to do this.

In this tutorial, I will show how you can program a non-Arduino AVR microcontroller like AtMega 16/16A using Arduino as an ISP programmer.

Loading Arduino ISP sketch

By default Arduino IDE comes with an ISP sketch. All you need to do is to open it up in your Arduino IDE (or using my Arduino makefile), then connect your Arduino to your computer and then upload the sketch to your Arduino.

You should not connect anything else to your Arduino at this point and you will find the Arduino ISP sketch in File -> Examples -> ArduinoISP

Installing Arduino core for your microcontroller

The next step is to find the Arduino core support for the microcontroller you want to program and then install it.

If you want program ATMega 16/16A, then you can use my “Arduino extra core“. I have also written a separate tutorial explaining how to use it. Or if you want to program ATtiny microcontrollers, then you can use the ATtiny core by David Mellis, one of the co-founders of Arduino.

Most of the time, you just have to place these core files inside /hardware directory in your sketchbook folder, but consult the documentation of the actual core library you are using.

Connect the circuit

The next step is to connect the microcontroller to your Arduino. The below diagram shows how to connect ATMega 16/16A. In general the principle remains the same for other micro controllers as well.

Program ATMega 16 using Arduino as ISP Programmer

Program ATMega 16 using Arduino as ISP Programmer

The following are the different pin connections

  • Arduino Pin 13 to ATMega 16 Pin 8 (or SCK of another microcontroller)
  • Arduino Pin 12 to ATMega 16 Pin 7 (or MISO of another microcontroller)
  • Arduino Pin 11 to ATMega 16 Pin 6 (or MOSI of another microcontroller)
  • Arduino Pin 10 to ATMega 16 Pin 9 (or RESET of another microcontroller)
  • Arduino 5+ to ATMega 16 Pin 10 (or Vcc of another microcontroller)
  • Arduino Gnd to ATMega 16 Pin 11 (or Gnd of another microcontroller)
  • 10 uF capacitor between Arduino Reset Pin and Gnd Pin (+ve leg of capacitor should go to Reset pin)
  • LED through proper resistor on any pin of the microcontroller, which you will be controlling through code

This is how my connection looks like

Program ATMega 16 using Arduino as ISP Programmer

Program ATMega 16 using Arduino as ISP Programmer

Burn bootloader/fuse

The next step is to burn the bootloader or/and fuses. For most cores, you don’t need to use the bootloader.

My Arduino extra core doesn’t need any bootloader, but only needs some fuses to be set.

You can burn the bootloader and/or the fuses, by selecting Tools -> Burn Bootloader. Make sure you have chosen the correct board type before you do that.

Upload your sketch

Now, everything is ready, and all you need to do is to write your sketch and then upload it. The ISP sketch that your burned into your Arduino, will take care of the rest.

To use serial monitor, with your microcontroller, you can use my other tutorial which shows how you can use another Arduino as a bridge.

Upload your sketch using makefile

My Arduino makefile also supports uploading sketches through Arduino ISP programmer. Follow all the normal instructions and then define ALTERNATE_CORE and ISP_PORT in your makefile and run make ispload target.

Happy Hacking 😉

89 thoughts on “Use Arduino as an ISP programmer to program non-Arduino AVR microcontrollers

  1. davidhengo

    Hi Sudar, i followed the steps and i finally could upload my sketche, Thank you.

    Do you know the reason why four of my new atmega16A chips don´t work the digital pins 18,19,20,21 and PWM on D11?

    I’ve been trying to debug but still no conclusions.

    Best Regards.

    Reply
  2. Meraj

    thanks for making it easier to access avr controllers with arduino. I was able to burn bootloader succesfully on atmega16l but cannot upload the sketches.The error shows:
    avrdude: stk500_getsync(): not in sync: resp=0x00. It would be a privilege to have your assistance in this problem.

    Reply
  3. Meraj

    I am programming via IDE and using a USB-UART cable to do the communication. The converter consists of RX/TX/5v/3.3v/GND pins. Since there is no DTR pin for autoreset, I used a button to reset manually at intervals during the upload. It worked for me with atmega328 but not with atmega16L. I still have the issue on the term L which is low frequency,and arduino ide needs 16Mhz to work with. Is there any way to rectify this problem?

    Reply
    1. Meraj

      It finally worked, I forgot to change the pin no. declaration in blink sketch. Thanks once again. I still have problem on how to do serial communication via ide with atmega16l without using the arduino?

      Reply
  4. Intex

    i would like to connect the RTC module with the Atmega16-16u microcontroller , could this be possible ?

    Reply
    1. Sudar Post author

      I am not sure if I understand your question.

      Can you explain what you are trying to do and what is the problem that you are facing?

      Reply
  5. NicoHood

    Hey,
    do you know if you can program the 16u4 from the arduino uno/mega with another uno? I have no idea where i could find a profile for this chip. I want to patch a hid function

    Reply
  6. Akki

    hey there,
    i have atmega 32A chip which i want to program using arduino uno. I have done the above steps. But i am stuck at burning the bootloader. When I burn the bootloader, the arduino IDE says,
    avrdude: Expected signature for ATMEGA16 is 1E 94 03
    Double check chip, or use -F to override this check.

    What could be possibly wrong?

    Reply
    1. Sudar Post author

      In the above article I am using Atmega 16 core. In your case you are using atmega 32A. So you should a core that is compatible with atmega 32A, not my core which is only for atmega 16.

      Reply
      1. Akki

        I got the core files for atmega32A . But got another problem now.
        While burning bootloader, it says
        avrdude: verification error, first mismatch at byte 0x3891
        0xff != 0x3c
        avrdude: verification error; content mismatch

        Reply
          1. Akki

            Ok now finally burning the bootloader is done… Now which type of program should i upload?
            I have uploaded both arduino one and the atmega32 supported program but neither one is working.

          2. Sudar Post author

            Which core are you using? Also refer to your core to make sure that you are using the proper pin mapping.

          3. Akki

            When the code uploads, it gives an error:

            avrdude: verification error, first mismatch at byte 0x0002
            0x2a != 0x28
            avrdude: verification error; content mismatch

  7. Ojasvi Yadav

    The pin numbers in the standard pinout diagram of Atmega16 don’t coincide with the actual pin numbers required while programming. By Hit and trial i figured out that you need to name the pin 19 as ’36’ while programming. I mean, if you’re programming and you are to use the pin 19 of Atmega16, you must refer it’s location as ’36’, otherwise it doesn’t work. Is there any direct list available where all these actual pin numbers with their programming counterparts are listed?

    Reply
    1. Sudar Post author

      @Ojasvi,

      Can you let me know pins by functionality instead of pin number? I don’t have the datasheet handy so I am not able to refer to find out what pin 19 and 36 refer to.

      Reply
      1. Ojasvi Yadav

        When I type the program in Arduino IDE, I have to define the pin name as ’36’ when I want to refer to pin ’19’ on the Atmega16. Similarly, I have to write the pin name as ’34’ when i need to program any input/output on the actual pin ’17’ of the Atmega16. Now these corresponding adjustments I figured out by myself, but it would be very handy if there was a valid information as to what every pin should be referred to as.

        Reply
  8. Satish Pawar

    Hi sir,
    I also followed your steps and tried to make my led blink. but got same error as Ojasvi got
    please help..???

    Reply
  9. Pingback: Use Arduino as an ISP programmer to program non-Arduino AVR microcontrollers | techblog

  10. Moritz

    Flashing with an arduino pro mini (Mega328P) as an isp doesn’t work for me…

    target is an ATMEGA16A, the ArduinoPro Mini gets flashed with the ISP Sketch then i disconnect everything, wire up your isp connection add a led/resistor for LED blink test later…
    and a capacitor 10uF and 16V on the reset line and gnd of the promini…
    start the arduino suite, choose Tools-Board-Atmega 16…
    again tools install bootloader….

    Invalid device signature error :-(

    Reply
  11. Jaison

    Hello,

    This is my first time programing a stand alone microcontroller. Could you please help me with basic and getting started. I have ardiuno uno r3 i want to use it as isp n atmegs32A-pu . i have no clue to where to start with.. Can someone save me?

    Reply
  12. Pingback: Fix Isp Programmer Error Windows XP, Vista, 7, 8 [Solved]

    1. Sudar Post author

      Are you asking me how long it takes to reprogram atmega or how many time we can reprogram atmega chips without destroying them?

      For the first question the answer is less than 30 seconds. For the second question I don’t have an answer. You may have to check the datasheet of the chip.

      Reply
  13. suresh

    I have Arduino IDE 1.0.5-r2. You have mentioned in your write up your core doesn’t work for this IDE and you are working on it. Have you got the procedure /core for this IDE? I tried even though and as expected it didn’t work.My averdude.conf file does show signature of atmega16(0x1E 0x94 0x03) but boards.txt doesn’t list atmega16 board.All I could get were entries of atmega168 when I search the file by atmega16.
    I complement you for very nice write up and all the efforts you have put in.
    Suresh

    Reply
    1. Sudar Post author

      Are you using Arduino 1.0.5 or 1.5.0? My core works with 1.0.x but not on 1.5.x since Arduino changed the library format in 1.5.x

      Reply
  14. suresh

    I am using Arduino 1.0.5-r2. Wrongly I was under impression that I am using 1.5.0! After reading your very prompt reply(many thanks for the same), I retraced my steps.Final error that is popping is the following;
    C;\Program Files \Ardunio1.0.5\hardware\arduino\cores\arduino/Arduino.h:213:26 :error : pins_arduino.h: No such file or directory
    Can you please suggest remedy to ovecome this difficulty?
    suresh

    Reply
      1. suresh

        That’s unbelievable! Your replied almost instantly.
        I did some search .There is a file in the folder
        “C:\Program Files\Arduino1.0.5\hardware\arduino\cores\arduino”, named Arduino.h ,created a the same time I had installed your folder-arduino-extra-cores-master in the folder C:\Program Files\Arduino1.0.5\hardware. I coied it in the same folder and named it pins_ardino.h and tried again. Now I get the following error.
        “C:\Program Files\Arduino1.0.5\hardware\arduino\cores\arduino/main.cpp:14: undefined ref to ‘loop’ ”
        I have copied the main.cpp and is given below
        main.cpp;

        #include

        int main(void)
        {
        init();

        #if defined(USBCON)
        USBDevice.attach();
        #endif

        setup();

        for (;;) {
        loop();
        if (serialEventRun) serialEventRun();
        }

        return 0;
        }
        I can’t why the error-undefined ref to ‘loop’.
        Many Thanks for your kind attention to my problem.
        I am doing this at age(76 !) for appreciating what people (like you) are doing.
        suresh

        Reply
        1. Sudar Post author

          Hello Suresh,

          76! Wow! I wish to have the same amount of curiosity when I am your age :)

          I think I found the reason why you are getting this error. As I mentioned in my other post – http://hardwarefun.com/tutorials/use-arduino-code-in-non-arduino-avr-microcontroller you should NOT copy the arduino core into your arduino installation directory. Instead you should copy it into your sketchbook folder directory.

          Since you copied it to the arduino installation directly, I think it has overridden some of Arduino’s core files. I guess you may have to re-install Arduino to get back the correct files. After that install my arduino-extra-core to the sketchbook folder and try it again. It should work after that.

          Let me know if you are still facing any issues.

          Reply
  15. suresh

    I have reinstall arduino 1.0.5-2r. I have copied core files,as suggested in your write up. There is just one little doubt. I had placed another folder atiny in the folder -hardware inside sketch-folder.So it looks like this:
    C:\Documents and Settings\Suresh\My Documents\Arduino\hardware/atiny/ and
    C:\Documents and Settings\Suresh\My Documents\Arduino\hardware/arduino-extra-cores-master/
    circuit/atmega-16.fzz, atmega-16.png
    variants/mega16/pins_arduino.h
    boards.txt, Read.md
    Am I on right track?
    Should I try to upload Blinksketch, hoping I havenot made any error in connection?
    suresh

    Reply
    1. Sudar Post author

      Everything seems to be fine. You can make one more change. Rename arduino-extra-cores-master folder to arduino-extra-cores.

      After doing this go to Tools -> Board menu and see if Atmega 16 is displayed in the list. If it is displayed in the list then everything is installed properly and you should be able to use my extra core without any issues.

      Reply
      1. suresh

        ooops! Blinking program doesn’t show blinking even though uploading the sketech went through without hitch.
        I was confused with two different pictures in your write up
        “Ref: http://hardwarefun.com/tutorials/use-arduino-as-an-isp-programmer-to-program-non-arduino-avr-microcontrollers
        There is a little difference between two pictures-second and third picture.The second picture has a capacitor between reset and ground and pin 31 of atmega16 is connected to ground.Third picture doesn’t have these.
        I will try to upload without these two connections and hope those were the reasons.
        Many thanks again
        suresh

        Reply
        1. Sudar Post author

          The capacitor is present in both the 2nd and 3rd picture. It is not very clear in the 3rd picture, but the capacitor is there.

          You can ignore pin 31 of atmega16 if you have connected the other pin to ground.

          Are you using the blink sketch from the built-in example?

          Reply
      2. suresh

        I am sorry to overlook capacitor in picture of your circuit.
        I checked Blink sketch with another development board and it works on that board with atmega328.
        I checked/rechecked the connections and I think it is just as has been explained /gien in the picture.
        While checking the orientation of atmega16A, I noticed it is Atmega16A PU! However the program gets uploaded without any error.Could PU extension be the culprit?
        suresh

        Reply
        1. Sudar Post author

          I am not sure if there is any major difference between atmega 16A and atmega 16A PU.

          Can you post a photo of your connection and also share the code of your blink sketch?

          Reply
  16. suresh

    Here is sktech,with required modification:
    /*
    Blink
    Turns on an LED on for one second, then off for one second, repeatedly.

    This example code is in the public domain.
    */

    // Pin 13 has an LED connected on most Arduino boards.
    // give it a name:
    int led = 20;

    // the setup routine runs once when you press reset:
    void setup() {
    // initialize the digital pin as an output.
    pinMode(led, OUTPUT);
    }

    // the loop routine runs over and over again forever:
    void loop() {
    digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(1000); // wait for a second
    digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
    delay(1000); // wait for a second
    }
    Can you please let me know how to send the picture?
    suresh

    Reply
    1. Sudar Post author

      Which board are you using? It doesn’t seem like a regular Arduino.

      Also I am not sure if the capacitor is connected correctly. Kindly check it to make sure it is connected correctly.

      You have also loaded the Arduino ISP sketch into your Arduino before doing the connection right?

      Reply
  17. suresh

    I got this development from a local company EmbededMarket.com and assumed to be similar to standard Uino board.
    I magnified the image I had posted on my tablet.As it is it does give impression that capacitor’s postive is not in line of black input. When I saw magnified image on he tablet, all wholes in the next row of black input are visible;so it is not in the next row as unmagnified image gives the impression.
    As regards the third query, yes I have uploaded ArduinoISP before connecting the circuit.
    As my breadboard is rather old,I checked whether all external connections give continuity with the corresponding pins of MC.
    I am going to check all rest of MC pins have proper continuity with the rows, indicating that the breadboard is not responsible
    Well, if all these fails me,I will conclude that I might have spoiled MC with my tinkering around.
    suresh

    Reply
    1. Sudar Post author

      Sorry Suresh, I don’t have any more suggestions :(

      I suspect it could one of the following three issues, but don’t have any concentre suggestions.

      – The board has some difference with standard Uno board
      – Your IC is spolied
      – There is still some problem in the connection or the components that you are using.

      Reply
      1. suresh

        Nope.My wishful thinking is that the micro controller is good, circuit is correct.However micro controller doesn’t start for something wrong in ‘fuses’.I am getting no voltage on any pin except at pin 10. I am curious to find out whether one can read( may be averdude and…?) registers of MC. I have downloaded, installed averWin and trying to get hang of it.You can save my efforts by informing that it is not feasible.
        suresh

        Reply
        1. Sudar Post author

          I think it should be possible to read the registers of the MC using avrdude, but I am not sure.

          Either way keep me updated about your progress.

          Reply
  18. Dan

    Hey i tried your steps, yet i have been stuck in burning fuse! HELP me a bit..
    avrdude: usbdev_open(): did not find any USB device “usb”
    After selecting proper board as well ii get the above error! Please help fast!

    Reply
  19. Dan

    Got the fault! Now working!!!How can i burn a hex file compiled in atmel studio for Atmega16 using the same circuitry

    Reply
  20. suresh

    Hi Mr.Sudar,
    My study of avrdude commands is moving with snails pace.However yesterday I bootloaded using Arduino uno board as ArduinoISP and Duemilanove as target board .My MC was Atmega328 -PU; as per instructions I got avrdude.conf changed.I changed a signature for atmega328 to atmega328 -pu. It did work.
    Was the different signatures of atmega16 and atmega16A the cause for attempt failing?
    I am little confused when you have written”My Arduino extra core doesn’t need any bootloader, but only needs some fuses to be set.” How do we set these fuses, if needed, for loading the program?
    To write fuses, I may have to use my new knowledge of avrdude commands otherwise.
    Suresh

    Reply
    1. Sudar Post author

      Hello Suresh,

      I was travelling so was not able to reply earlier.

      If you are using Arduino as an ISP programmer then you don’t need the bootloader. You have to burn the fuses using the avrdude commands.

      Let me know if you are still facing any issues.

      Reply
  21. Armia

    Hey Sudar
    Thanks for your perfect description. :)
    I programed my mega16 with Arduino Leonardo via IDE. The error is : ” avrdude: stk500_getsync(): not in sync: resp=0x00 ”
    Would you please help me ?
    Thanks :)

    Reply
    1. suresh

      Dear Sudar,
      My further search resulted in the following observations.
      1. Signatures of Atmega16 and Atmega 16A are same.
      2. Embedded Fuse Calculator gives different default Low fuse vales for these two MCs-(0xE1 and 0xc1 respectively.
      3. board.txt file that is used to define atmega16 by you shows this value as 0x84.
      Another observation is that I could boot atmega328 using two development boards, Unio being host and Durmilanove as target board. I then searched and found that Dumilanove board can be replaced if one wants to bootload/program a avr micro controller, only that is needed to know SCK, MISO, MOSI ,Reset. 5v and GND pins and such a board should be listed among the boards definition.You have defined atmega16 board. Would different Low fuse values make different micro controllers?
      I would first search on internet;otherwise I would change Low fuse value by avr command line operation- I am getting to understand it.
      Suresh

      Reply
      1. Sudar Post author

        You have defined atmega16 board. Would different Low fuse values make different micro controllers?

        I am sorry. I don’t know about it. Are you able to get the fuse settings from the datasheeet?

        Reply
      1. Armia

        I don’t know, everything seems to be correct. I also defined new pins & boards file for ATmega8 and tried to program it, but again that error … !!!
        I also tried to program via Mega2560, but it didn’t work. Again that error … !
        I don’t know what’s wrong! 😐
        I uploaded ArduinoISP Sketch. Then I connected MISO to MISO, SCK to SCK, MOSI to MOSI, RESET to RESET and 5V and GND and tried to program, but it didn’t work.
        What should I do ?

        Reply
    1. musaab

      Dear Armia,

      Glad to know that it is working with you , but am facing your same problem with my arduino leonardo board , will tell me what you did so as i can do the same and solve my problem .

      Regards,

      Reply
  22. Armia

    Hi Sudar
    I was tinkering with different chips and noticed that I can’t program fuse bits, even in mega16.
    Can Arduino IDE program fuse bits?
    What’s your suggestion about it?
    Thanks alot

    Reply
  23. suresh

    Dear Sudar, Still couln’t fix the problem. I have two questions,answers may help to remove difficulty I am facing.
    1. It is not clear from your this tutorial whether you atmega on breadboard needs fuses and if so, how to install them.
    2. One is using two boards to select from TOOLS- one is atmega16(Internal 8MHZ clock ) and other Uno).While programming atmega16, which port should be used?
    My present knowledge(or NON-) indicates that the same set up can be used to read fuses, a command like
    “C:\avrdude -c avrisp -p m16 -P COM3 -U lfuse:r:i”
    I expect to face the problem of unlocking fuse settings in order to read fuses. Search is on!
    Suresh

    Reply
    1. Sudar Post author

      Here are my answers to your questions

      1) Yes, you would require to burn fuses. For Atmega 16/16A if you choose Tools -> Burn Bootloader, it will burn the fuses for you.
      2) You need to choose “Atmeta 16 (Internal 8MHz clock)”

      Reply
  24. Saurabh

    Hey Sudar,
    Will the same process work for ATmega644 too?
    I need to burn the chip and I have a few arduinos lying around. It would be amazing if I could program Atmega644 using arduino for one of my projects.

    Reply
      1. Saurabh

        I’m a rookie, and I’m trying to do this for my final year project. Can you explain me what exactly a core is?

        Reply
        1. Sudar Post author

          Core is the set of libraries that are available for each type of Arduino (Uno, Due etc).

          Arduino is developed in such a way that all microcontroller specific code are separated from the other common code. The advantage of this approach is that you can use a new model or microcontroller easily.

          Check out http://www.avr-developers.com/corefiles/index.html for more details.

          Reply
  25. Sony Arouje

    Hi Sundar,
    Thank you so much for the elaborate tutorial and the core. Every thing worked perfectly. I modified the boards.txt to deal with IDE 1.6 but he didnt like much while bootloading. Then I switched to IDE 1.0.6 and successfully burned the bootloader. Some how I didnt like IDE 1.0.6 it’s very slow to deal with. So I modified your boards.txt and added the below lines for uploading sketches to Atmega 16 using IDE 1.6.x

    #required for uploading sketches to extra core using Arduino as ISP.
    atmega16-8.upload.tool=arduino:avrdude

    #required for bootloading
    atmega16-8.bootloader.tool=arduino:avrdude

    Just a note to others, in case if the bootloader didn’t work then make sure your Breadboard is good and all the pins can communicate to your Atmega16. Yesterday night I wasted a lot of time and I couldnt figure out why the boatloading is not happening. Today morning I switched to a different breadboard and every thing worked fine. Reason my other breadboard was not good.

    Once again, thanks for your good work.

    Regards,
    Sony Arouje

    Reply
  26. Sony Arouje

    Hi Sudar,
    I need a help, I wanted to blink an LED connected to Pin 20 of Atmega16 as per your diagram. Could you please tell me how should I refer pin 20 in digitalWrite() of Arduino. Is it like digitalWrite(20, HIGH);

    Regards,
    Sony Arouje

    Reply
  27. Pingback: Bootloading Atmega16 with Arduino Uno | Sony Arouje Blog

  28. Pingback: How to solve Atmega 16A Serial write (println) hang with Arduino Uno firmware? | DL-UAT

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>