Arduino ISP (In System Programming) and stand-alone circuits

We use an Arduino to program other ATmega without bootloader . This technique allows you to use all flash memory for code and make boards using new ATmega, cheaper than those with bootloader.

The qualities that have made the success of Arduino are undoubtedly the open-source software, many libraries, a good hardware and a virtually infinite Reference that explains each possible use of the platform.

But if we use Arduino for a specific use, we can integrate it into a specific circuit and program the micro in a way that performs a single firmware. We may so remove the bootloader and leave to the firmware the entire program memory.

The ATmega328 has 32 Kbytes of flash, that when the chip is mounted on Arduino are not all available, as a portion is reserved to the bootloader, the purpose of which is to communicate with the IDE Arduino to load programs (sketch) to be performed. The same bootloader, on each power on or reset of Arduino, verifies the presence of a sketch in flash memory and executes it. The bootloader occupies a space of 512 bytes, in the case of Arduino UNO.

Well, in a stand-alone application the bootloader no longer needed.

The configuration of the micro ATmega328P needs, in addition to the power (+5 VDC to pins 7 and 20, GND to pins 8 and 22), a 16-MHz crystal between pins 9 and 10, two 22 pF ceramic capacitors from between these pins and GND, a 10 k Ω resistor between pin 1 and +5 VDC for pull-up the reset line.

Programming ATMEGA in stand-alone

Anyone knows that it is necessary program Arduino uploading a sketch via USB, using the software called IDE and the operation is quite simple.

We can see a screenshot of the IDE with an Arduino sketch loaded and UNO during the receipt of the sketch (notice the yellow LED on).

The technique will test allows the use of a board Arduino as ISP Programmer.

We start with the list of required materials:

• Arduino UNO / Duemilanove (will be used as a programmer);

• ATmega328P chip (chip to be programmed);

• Breadboard and jumper;

• a crystal of 16 MHz, two ceramic capacitors from 22 pF, a resistance of 10 K Ω 1/4 W, a resistance of 560 Ω 1/4 W LED 3 or 5 mm;

• seven male-male jumper wires.

A resistance of 120 Ω 1/4 of watts, and an electrolytic capacitor or tantalum from 10 uF 10 ÷ 16 volts.

Now we prepare our target circuit and first of all insert the chip on the Breadboard, these are the connections to make:

• through the jumper to be Breadboard connect pins 7 and 20 of the chip to the positive supply line (+5 volts);

• in the same way we connect the pins 8 and 22 of the chip to the ground line supply (GND);

• connect pin 1 of the chip to the +5 V line through the resistor of 10 k Ω;

• insert the crystal to the pins 9 and 10 of the chip;

• insert the two 22 pF ceramic capacitors; both must have a leg connected to GND, while the other will serve to connect a capacitor to pin 9 and the other to pin 10 of the chip;

• insert one end of resistor 560 Ω at the pin 19 and the other end into an empty spot on the breadboard, and to this end we connect the anode LED(the longer pin) , whose other end (cathode) goes to GND;

At this point we can connect to the Arduino Breadboard using jumper cables under the following matches:

• Arduino pin 10 goes to pin 1 of the chip;

• Arduino pin 11 goes to pin 17 of the chip;

• pin 12 of Arduino is connected to pin 18 of the chip;

• pin 13 to Arduino pin 19 goes on the chip;

• the +5 V pins of Arduino goes to the positive supply line of the breadboard;

• any of the three GND pin of Arduino goes to the ground line of the breadboard.

Now look the software to reveal the “trick” that sends a sketch, using the IDE, to the chip on the Breadboard, bypassing Arduino that will play the role of Programmer ISP.

What we need to do is create a virtual board, starting from the original (corresponding to the model we are using Arduino) and making some simple but essential changes. We must first locate the file that is boards.txt containing all information relating to the various boards that the IDE shows us when we execute the command Tools->Board. Typically this file is located in the folder of the IDE software, the path X: \ mypath \ arduino-xxx \ hardware \ arduino, where X is the letter that indicates the logical drive and myPath the folder or location containing the program (xxx indicates the version of the program).

Now open the file with Notepad and see a long series of lines arranged in groups separated by a line consisting of a repetition of the symbol “#”,each group representing a different board. The lines are identified by the initial code, the same for all, but different for the board, the name that will appear in the submenu Tools->Board is inserted in the first row in the group.

The code is represented by the word “uno” which is at the beginning of each line.

The line containing the word “name” (usually the first) is followed by “=” and then the name that the board will have in the IDE.

Other information that concern us are:

• uno.upload.maximum_size = 32256: Sets the maximum capacity of flash memory that we can use in practice from 32 Kbytes of Flash which has the total ATmega328P we must subtract the space occupied by the bootloader, for the Arduino UNO is 512 byte;

• uno.bootloader.low_fuses = 0xff; uno.bootloader.high_fuses = 0xde; uno.bootloader.extended_fuses = 0x05; these three lines are the “fuse”, are used to set the behavior of the chip and are expressed with hexadecimal values;

• uno.build.f_cpu = 16000000L: This line must correspond to the clock frequency for which the chip has been set, by means of the fused, expressed in Hz, 1 Hz 6,000,000 correspond to 16 MHz, precisely the frequency of the quartz or, more precisely, the present external oscillator to Arduino UNO; this value is used as a reference for timing controls of the software, such as delay () and millis ().

And now we create our own virtual board, writing these lines of code:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

atmsa16.name=ATmega inStand Alone(w/Arduino asISP)

atmsa16.upload.protocol=stk500

atmsa16.upload.maximum_size=32768

atmsa16.upload.speed=115200

atmsa16.upload.using=arduino:arduinoisp

atmsa16.bootloader.low_fuses=0xff

atmsa16.bootloader.high_fuses=0xdf

atmsa16.bootloader.extended_fuses=0x05

#### atmsa16.bootloader.extended_fuses=0x07

atmsa16.bootloader.path=optiboot

atmsa16.bootloader.file=optiboot_atmega328.hex

atmsa16.bootloader.unlock_bits=0x3F

atmsa16.bootloader.lock_bits=0x0F

atmsa16.build.mcu=atmega328p

atmsa16.build.f_cpu=16000000L

atmsa16.build.core=arduino

Following the approach of the file will separate this group of lines to those of other boards, inserting a line of “#”.The end result should be:

We note that are varied: the code (atmsa16 instead of uno), the maximum_size (brought to its maximum capabilities of Flash, since we do not reserve space for the bootloader), then there a new line (atmsa16.upload.using = arduino: arduinoisp) that allows us to understand the IDE that will program the chip in stand-alone and not on the Arduino. Another new line is preceded by some “# # # #” that disables it, the reason is easily explained: the extended_fuses is set to 0x05, and in some special cases, during the transfer of the sketch could be an error bound the setting of this value.As we shall see later, simply change the following two lines of code:

1

2

&lt;em&gt;# # # # Atmsa16.bootloader.extended_fuses = 0x05&lt;/em&gt;

&lt;em&gt;atmsa16.bootloader.extended_fuses=0x0&lt;/em&gt;7

thus activating the value 0x07 instead of 0x05, it will work out. Of course, this change should not be made before, but only if you get the error.

Program the micro

At this point we are ready for the final step: send our sketches to the chip mounted on the breadboard and then will test the operation separating it from Arduino.

To read the new board in the file, the IDE must be restarted, so if this program was open, when editing the file boards.txt must close it and restart it. To verify that our modification is successful, it is sufficient now run the command Tools->Board and check if there is now our “stand-alone” board, otherwise we should close the IDE and check the file boards.txt, because certainly we made ​​a mistake.

The technique used to send the sketch to the chip in stand-alone mode is very simple: First select the Arduino board that we are using as a programmer (eg Arduino Duemilanove or UNO) , just as we do for normal use of Arduino. Then select the Arduino serial port (the COM for Windows users) and recall from the IDE the sketch ArduinoISP, execute this command by clicking the Upload button on the IDE. After several seconds of the three flashing LEDs and Arduino to the breadboard of course (at the moment is physically connected to pin 13 of Arduino that, as we know, check out one of the three LEDs on the board) on the IDE will come the message “done uploading “.

Arduino is ready to play the role of Programmer ISP, select, now, our board IDE “ATmega Stand Alone (w / Arduino as ISP)“, without changing the COM.

We load the sketch “blink” and execute it again by clicking the Upload button on the IDE: LEDs and Arduino breadboard flash again, this time for a much shorter period, after which the IDE will show the message again “Done uploading”.

So our ATmega328P chip was programmed without having to physically fit on Arduino and now lives its own life. It is then ready to be mounted in the circuit which it is intended.

Of course, the chip can be reprogrammed at will with any kind of sketch.

Troubleshooting

At this point we have to solve three types of problem that may occur when we send the sketch to the chip stand-alone. The problems of’extended_fuses and of autoreset may occur on either Arduino Duemilanove or Arduino UNO, without that you can establish a certain rule.We must also emphasize that the remedies that will illustrate to 100% solve the problems, but must be applied only if the problem occurs.

We start from the situation that may occur if we use a blank chip, the Atmel set the fuse to make the chip work at 1 MHz with the internal oscillator. If we send a sketch directly, happens that the chip in stand-alone ignores the external crystal and times will be staggered: for example, the LED blink with the sketch will last about 16 seconds instead of 1 second. Simply, we set the fuse, the operation can be done easily by loading the bootloader on the chip before sending the sketch.

Before explaining this simple maneuver quickly clarify two points: the bootloader is sent once a chip virgin and will only serve to set the fuse, then it will become useless and the sketch overwrite it, if we had to first load the sketch, noticing the error, and then load the bootloader, no problem: the chip is set and we just have to resubmit the sketch. The simple steps that are going to describe will return very useful for cases where we wanted to prepare a blank chip to work directly on Arduino; is a good idea to have in the house a spare chip with bootloader of our board, so if you were unfortunately damaged the original, a simple substitution solves this problem immediately.

Here are the steps to follow:

• prepare and connect the Breadboard Arduino as discussed previously;

• We open the IDE and select the model we are using Arduino and port to which it is connected;

• upload the sketch ArduinoISP to Arduino;

• now execute the command Tools->Burn Bootloader w / Arduino as ISP;

• After about a minute we loaded into the stand-alone chip the bootloader of Arduino boards (you may have noticed that in the IDE we’ve set our Arduino board).

As mentioned, the chip can be quickly mounted to receive the Arduino sketch, or leave it on the breadboard and repeat/execute the operation of sending the sketch stand-alone, this time the Blink will work perfectly.

Of course, other errors may occur, do not worry, keep reading this section and of course everything will be resolved.

So let the problem of ‘extended_fuses: the rows of our virtual board we expected a double value for this cast, because it can happen (even though it is quite rare) that some boards do not succeed in this program merged with the value 0x05. During the upload of the sketch on the chip with stand-alone mode, the IDE will display an error message (written in red on a black background) that will indicate the need to use the value 0x07, if it appears that in practice warning means that we must close the IDE, open the file boards.txt and activate the relevant line, simultaneously disabling the other (with 0x05), as explained above. At this point we can repeat the test. We clarify that if the error occurs on a given board will always occur on this board, so the variation of the files should be done only once and permanently.

And now we see the problem, more frequent, about autoreset. When the serial chip (FT232RL on Duemilanove or ATmega8U2 of UNO) receives a signal from the USB port, sends the reset pulse to ATmega328, who then prepares itself to receive Data. This operation corresponds to the one you make every time you press the button “RESET” on the Arduino.

If the data do not arrive or if the reset was made manually, the sketches in flash memory chip ATmega328 is executed. When Arduino is used as ISP Programmer can happen that, if the autoreset is sent too early, the upload operation fails. In this case the IDE returns the following error: “avrdude:stk500_getsync (): not in sync: resp = 0x15“.

The problem is solved by blocking the Autoreset. The 120 ohm resistance must be connected between the RESET pin of Arduino and +5 V, while the 10µF capacitor is connected with the positive pole to the RESET of Arduino and negative to GND.

With a jumper cable connect on Breadboard the RESET signal of Arduino.

The methods described should be used only if absolutely necessary.

Important note: the need to connect these components only when needed, is dictated by the fact that to load a sketch on the Arduino should autoreset, otherwise the upload will fail and we will get the error avrdude: stk500_getsync (): not in sync: resp = 0x00 – avrdude: stk500_disable (): protocol error, expect = 0x14, resp = 0x51, so if you see this error, know that you just have to “liberate” the pin “RESET” Arduino from the link with the Anti- autoreset.

You can follow these instructions for connections to the ZIF: – connect pins 7 and 20 of the ZIF to the positive supply line (+5 volts) of your Arduino PRO-mini – in the same way we connect the pins 8 and 22 of the ZIF to the ground line supply (GND); – connect pin 1 of the ZIF to the +5 V line through the resistor of 10 k Ω; – insert the 16MHz crystal to the pins 9 and 10 of the ZIF; – insert the two 22 pF ceramic capacitors; both must have a leg connected to GND, while the other will serve to connect a capacitor to pin 9 and the other to pin 10 of the ZIF. At this point you can make your ISP connection with 6 wires: – pin 10 of Arduino goes to pin 1 of the ZIF; – pin 11 of Arduino goes to pin 17 of the ZIF; – pin 12 of Arduino is connected to pin 18 of the ZIF; – pin 13 to Arduino pin 19 goes on the ZIF; Now read carefully this article and the instructions for software

Good luck! ;-)

Prof. Michele Menniti

PS: The Magazine “Elettronica In” in the current issue, has presented an excellent project for the construction of an ISP Programmer for Atmel mcu:

I read through the article earlier – presumably I need to use a different piece of code for the Pro-Mini rather than the examples that begin “uno.—“?

I have to admit to being a little confused at this point – but it may become clearer when I actually have everything ready and have my brain aligned with Arduino again (I only “play” with it now and again).

Hi 7Usam, IDE 1.0 has a ArduinoISP defective, the new versions (1.0.1-rc1 & rc2) should solve the problem, but they are still beta versions. If you can do a test with IDE 002 or 0023. A note on your virtual board: you have to set HFuse = “DD” and eFuse = “FC” or “04”. You can also work without 8MHZ crystal, with the internal oscillator: E2 = LF, HF = DD, EF = FC (or 04). Let me know the news.

Hi Michele i just remove the resistor and led from pin 19 then burn bootloader using ide ver 22 then work it :) , can i burn bootloader of usbasp to my stander alone chip using same method ? , i test other chip that have not a bootloader of arduino …. just for test uploading simple program like blink then uploading is done ! and the blink is work in that chip but slow , so why we burn bootloader on chip ?

EXCELLENT! :D if you use a resistor with value 680ohm or greater, you can also leave the LED on pin 19. By way ISPs can program any MCU AVRDUDE.COND recognized by the IDE, but you need the “core” for his family. If you burn bootloader, you’ll also change the fuses on the MCU, and set the exact frequency. After this you can schedule a firmware and you’ll see that the LED flashes properly. If you program a MCU, without setting the fuse with burn bootloader, the oscillator works badly. Unfortunately I do not know USBASP.

Hi, I got an error when i try to program my controler on breadboard with blink example. C:\Users\Maxime\Desktop\arduino-1.0.1-windows (1)\arduino-1.0.1\hardware\arduino\cores\arduino/Arduino.h:213:26: error: pins_arduino.h: No such file or directory Here is my board code:

Hello, I have always worked with IDE 0022. In ArduinoISP IDE 1.0 did not work, but IDE 1.0.1 should work properly even if the procedure is different. Tomorrow I install IDE 1.0.1 on my PC, I’ll give you some tests and news.

Now I noticed that, in your board, the “x” in the extended fuse byte is not x but a different character, why? Also on the board you have previously used the line: uno.upload.maximum_size = 32768 must be atmsa16.upload.maximum_size = 32768

The different character was an error from a copy paste, I have no idea why the character changed. Also I’m new to the arduino environement, I used to program PICs controlers but I wanted to try arduino for it’s vast variety of shields and libraries so forgive my stupid mistake.

I forgot to use the line atmsa16.build.variant=standard, that my code seems to need to work which yours doesn’t#, maybe because of the version.

I thought the whole ISP programmation was working but i just realised it doesn’t. When i launch a code to program on the stant alone controler (after i programmed the UNO in ARDUINO ISP) it program the UNO and not the controler on breadboard.

I passed the whole day trying to figure out the problem… I’m using those board config:

Hi, IDE 1.0.1 works differently than IDE 0022, it provides directly to program Arduino via ISP, so you should NOT add the line “arduinoisp”, but you must refer to the original board dell’IDE1 .0.1. Yesterday I did not test because I thought you had solved the problem. Tomorrow I will do some tests and I hope to show you the solution. Stay tuned;-)

Hello Diego, Thanks! You also connected to pin 10 of Arduino reset pin of 2313? You have connected the 10K resistor between pin and GND reset 2313? At what clock frequency you want to work on 2313? If the chip is a virgin before I suggest you try the original fuses (Low = 64, DF = High, = Extended FF), without using the crystal and external capacitors. If you do not have a bootloader for the 2313 test you by sending it directly to the sketch, but this can not change the values ​​of the cast, which is why you must use the original ones. Hola! PS: I am Italian, your English is fine as well, is like mine :-)

You’re right, I made a mistake in his haste, the r10k goes between reset and Vcc. You also connected to pin 10 of Arduino reset pin of 2313? Your board is completely wrong! If your tiny2313 is a virgin and if you’re using Arduino as programmer uses this board:

OK, then use the last board of the core but WITHOUT replacing anything. My suggestions are for the 0022 IDE, as I said the other user I have not done tests with IDE 1.0.1 Tiny2313 on the digital pin 13 corresponds to the physical pin 16, that’s where you connect the led through a R330-560ohm

Inside the tiny folder \ cores \ tiny here is the file that contains the pins.arduino.c pinature of tiny2313; values ​​”dxx” represent the digital pins, connecting the LED to a pin and uses in its digital pin blink.

1 – Set the board “Arduino UNO” and the corresponding COM / USB / DEV. 2 – Set the programmer “Arduino as ISP” 3 – Open the sketch “ArduinoISP” present in the samples and make upload to Arduino UNO 4 – Now open the sketch “blink” 5 – Set the board “ATmega328P 16MHz” 6 – Run the command File – Upload Using Programmer

If you want to load the bootloader instead of the sketch, you must only follow the steps 1-2-3, then: 4 – Run the command Tools – Burn Bootloader.

Keep in mind that: the micro leaves the factory to 1MHz, if you want to use it clocked at 16MHz must set the fuse, the only way to set the fuse is loaded BEFORE the bootloader and then send the sketch. Good luck!

I took the opportunity to look up Fuses but could not understand much of what I read. Is there a SIMPLE explanation somewhere that you could reccomend that would explain what they are and how to set them?

If I want to run an ATmega328 without any external oscillator components (for an application that is not time-critical) can I just burn the sketch onto a blank chip without burning the bootloader first – as I mistakenly did before? I didn’t try unplugging the crystal to see if it continued working at 1MHz (8MHz with 1/8 prescaler set???).

Very good! The topic of fused is not difficult to understand but it is difficult to explain. I have published two articles on Electronics In Numbers (June and July / August 2012), in particular in the June, I explained very well the use of fused and lock bits. I recommend reading them.

You can work at 1MHz or 8MHz but you ALWAYS burn the bootloader first and then the sketch.

1) The programmer seems to have stopped working. I tried to burn another sketch over the Blink sketch. On plugging in the ATmega328 the LED on Pin 19 (digital 13) blinks at the one second rate of the Blink sketch and continues to do so after I hit Upload using Programmer – nothing changes. The IDE then reports “avrdude: stk500_getsync(): not in sync: resp=0x00” and the ATmega328 continues to run the Blink sketch.

Do I have to run “Burn Bootloader” before each and every upload of a sketch or something?

2) I did a Google search for “Electronics in Numbers” but nothing showed up – can you provide a link to this please?

Then I had a flash of inspiration. I seperated the programmer from the Arduino and reprogrammed the Arduino with the Blink sketch – that worked ok. I then uploaded the ArduinoISP sketch again, reconnected the programmer and everything is working again.

Do you have any idea what may have caused the Arduino to mess up its stored program?

Given the trouble I am having understanding all of this in English, I don’t think your articles on Fuses are going to help me much in Italian – thank you anyway.

I have been programming ATmega328 chips for standalone projects at 16MHz (external crystal oscillator) without any problems but now I need to do some for Internal Oscillator at 1MHz and at 8MHz..

Obviously I need to create two new entries in the “boards.txt” file (I was going to call the entries “atmega32801” & “atmega32808” and use “atmega32801.build.f_cpu=1000000L” & “atmega32801.build.f_cpu=1000000L” respectively), but I am totally confused about what settings to use for the fuses and other things.

Also (I don’t actually need to do it yet) is it possible to program the chips without a bootloader to free-up space or am I doing that already with “maximum_size=32768” and the references to the bootloader apply to the Arduino boad that is acting as the programmer?

Hello Duncan, these boards allow you to program the micro and 1MHz to 8MHz with IDE 1.0.1 with the normal mode. The cast are already designed to use the entire flash memory for the application. But the first thing to do is always to load the bootloader, to set the fuse, then you can load the firmware, which will erase the bootloader. Let me know how the tests will be Michele ############################################################## mega3208.name=ATmega328P 8MHz internal clock mega3208.upload.protocol=arduino mega3208.upload.maximum_size=32768 mega3208.upload.speed=115200 mega3208.bootloader.low_fuses=0xe2 mega3208.bootloader.high_fuses=0xdf mega3208.bootloader.extended_fuses=0x07 mega3208.bootloader.path=optiboot mega3208.bootloader.file=optiboot_atmega328.hex mega3208.bootloader.unlock_bits=0x3F mega3208.bootloader.lock_bits=0x0F mega3208.build.mcu=atmega328p mega3208.build.f_cpu=8000000L mega3208.build.core=arduino mega3208.build.variant=standard ############################################################## mega3201.name=ATmega328P 1MHz internal clock mega3201.upload.protocol=arduino mega3201.upload.maximum_size=32768 mega3201.upload.speed=115200 mega3201.bootloader.low_fuses=0x62 mega3201.bootloader.high_fuses=0xdf mega3201.bootloader.extended_fuses=0x07 mega3201.bootloader.path=optiboot mega3201.bootloader.file=optiboot_atmega328.hex mega3201.bootloader.unlock_bits=0x3F mega3201.bootloader.lock_bits=0x0F mega3201.build.mcu=atmega328p mega3201.build.f_cpu=1000000L mega3201.build.core=arduino mega3201.build.variant=standard ##############################################################

Hello Michele, I’m working on a project in which I need to upload a program into brand new ATmega168V-10PU microcontrolers (that I’ve got straigth from Atmel). I have the arduino UNO with ATmega328 and the IDE using is 1.0.1. In order to do that I followed exactly what it’s explained in this page. I built the exact same circuit with the 16MHz crystal oscilator. Then I modified boards.txt (here I started to have doubts because my microcontroler is different to the one used here so I didn’t no what to change), then I upload the sketch ISP to the arduino UNO, next I set arduino as ISP and finally I load the blink example and tryied to programe my new ATmega168V-10PU microcontroler. It’s been a complete nightmare, because it doesn’t work. Giving messages like ” not sync”, “signature problemes”, … I’ve been trying to understand what may be going on and I have some ideas. Maybe it’s because this microcontroler are initially set to work with 8MHz inside oscilator, or maybe it’s because I’m using a 16MHz external oscilator while this microcontrolers can work up to 10MHz. Or maybe it’s because the boards.txt or the bootloader need to be different with this kind of microcontroler. I need some light here. Thanks a lot for your help!!!

by the way, I forgot to tell you that I’m using the windows version of arduino.

And last, I tryied to modify the fuse byts but non of this work for me… I’m not an expert and maybe I did it wrong.

please do not write many times the same post, you need patience, the answer comes.

The micro ATMEL leave the factory to work at 1MHz. To make them work at 16MHz is necessary to set the correct fuses. This operation can be done with the Arduino IDE, burning the bootloader in the micro, using a specific board. The board you find in this blog in response to Rohan. Here is the sequence of operations to do:

Thank you so much Michele for your answer, right now I’ll try what you say. However I still have two questions: 1- do I have to put the 16MHz oscillator in the pcb or any other oscillator? 2- what is the 168 bord that I have to use? And what changes do I have to do to it to adapt the fuse byts?

Thanks so much! I’m not a micro expert so your help is very important to me!

The tutorial of this blog is well done and correctly explain all these things before, you have to study it well, otherwise it becomes difficult to help you. You have to read the tutorial well, then you have to read my post updated to version 1.0.x IDE, then you have to read my post about the ATmega168 at 16MHz, you’ll see that everything will be clear

Guillem Freixanet

August 4, 2013 at 11:16 PM

I read all your posts before writing anything, but I’m not sure I can use the atmega 168 since my micros are 168V and they can only work up to 10MHZ and and also I’m not sure if the signature is the same. Isn’t it necessary that the burnimg micro and the programing one (arduino) are working at the same speed? Thank you so much Michele!

The 168V model has the same fuse 168 to 16MHz (high fuse 0xDF means 8MHz or higher) but can not exceed 10MHz clock, I suggest you use an 8MHz quartz and two 15-18pF capacitors, so you have good compatibility with the times of the IDE.

Best regards

Guillem Freixanet

August 5, 2013 at 9:29 PM

Finaly! today I’ve had been able to burn the bootloader into my micro!!! :-) thanks a lot for your help! Last question: now if I want to program, let’s say the blink example, it says to me that arduino can’t find pins_arduino.h… is it because the pins are differently numerated than with Atmega 328? thanks a lot!!!!

Very well! To upload a sketch you always have to select the board to program the micro and you have to use the technique ISP and ISP connections. But you do not have to click on the UPLOAD button, you must instead use the command File – Upload Using Programmer and everything will be fine. But let me know if the timing of the blink are correct (1 second on, 1 second off). Best regards

I must be missing something, I can burn the bootloader no problem but when I try to upload a sketch ArduinoISP tries to upload using serial coms, it does not pull the reset on the breadboard and attempt to use the same method as it does when I burn the bootloader. How do I ensure that the sketch can be downloaded without rewiring the breadboard. I want to use in circuit programing not in circuit serial programming.

IDE version 1.01, I found the problem the Sketch was set at 19200 and the board is 115200, correcting enabled me to upload a sketch. but now I have to burn the bootloader each time before it will run the sketch correctly although there are no errors reported by averdude. Thanks Ian

I’ve never had problems with the baud rate. However, when you upload a sketch with the technique ISP bootloader is automatically deleted. You need to burn the bootloader just to change the fuses to the micro, then you can load the sketch as many times as you want. Are you following the additional info that I wrote in the post for version 1.0.1?

I am sorry to bother you, my problem seems much more basic than all the questions that you have had to answer here. I just started with the Arduino Uno R3 (and have no useful knowledge in electronics whatsoever). I work with IDE 0022 on a MacBook Pro and wanted to burn the bootloader on a ATMEGA328P-PU on a breadboard (my goal is to get sketches like blink on it, but it seems that I am far from it). I have tried many tutorials and collected all kinds of error messages, but since I like your tutorial the most, I decided to ask you the following questions:

1) first of all: can I use your tutorial with my gear or am I already wrong here? 2) using your first approach (ignoring the 10uF cap) produces the error message :

Hi Lukas, you can burn the bootloader with your configuration. You must not use the 10μF capacitor and even the 120ohm resistor. You have to follow the Tutorial main, it’s for version 0022. The error you get depends certainly in connections. You want to email me a photo of your connections between Arduino and breadboard? Some boards choose to burn the bootloader?

Miraculously, after changing the cables and redoing all the connections, it works just fine. I am not sure what really changed, but I am most happy that it works. Thanks a lot for your help and all the effort to bring your knowledge to newcomers like me!

Just found out what most probably was the problem (in case someone might use this): the microcontroller was not pressed hard enough into the breadboard, hence not all the legs had good contacts to the board. Most probably a beginners mistake..

Hello everyone, I appeal to all those who write to me. I can not give you an answer if you do not give me at least the following information: 1 – operation that you’re trying to do (burn bootloader, upload sketch) 2 – the IDE version you are using (0022 or 1.0.1) 3 – rows of virtual boards you are using (for uploading sketch) Moreover, 80% of problems are caused by incorrect connection, should be carefully monitored. Finally you must remember that this tutorial is based on IDE 0022, if you use 1.0.1 (1.0 is inappropriate!) Please refer to my post directed @ NukeTheMoon. Thanks to all Michele Menniti

Solved it. After a good night sleep, I realized it was a connection problem. Basically I could not see that one of the crystal’s leg was not on pin 10, but on pin 11. I was 4 a.m. I’m really sorry for that, hope I did not take any of your time.

I could now burn the bootloader and upload a sketch. I need to test it yet, but I’m very confident. And just for the info, although I tried with both 1.0.1 and 0022, after seeing the connection problem I did the upload using 1.0.1.

Hi, I have been successfully using your directions to program some Atmega328P (PDIP) on a few prototype boards. I would like now to use the same method on an Atmega328P TQFP on a custom PCB powered at 3.3V. The GND, Reset, SCK, MOSI and MISO pins can be wired to my Arduino Uno board, the target chip’s reset pin is tied to the 3.3V through a 10K resistor and I have a 16Mhz crystal with 2x22pf caps . Is there any reason I could not program the chip ? Anything I should do differently?

Also, I noticed that I had to install the bootloader first in order to use the external crystal. I’m not sure I can burn the bootloader with this setup. Any suggestions ?

Hi Michel, You may NOT program a circuit powered at 3.3 V with Arduino, which runs at 5V, will almost certainly damage it a result of differing logic levels. Then you must to use an adapter of logic levels or even the simple voltage dividers, to be implemented with two resistors.

It ‘s normal that you had to first load the bootloader in your micro, in fact this is the only type of operation that allows you to modify its fuse.

Thank you for the advice, I should have though about it as it totally makes sense. On top of it, I also realized that I cannot drive the chip at 16Mhz under 3.3V. I think I need to ssomewhat rethink my plans… Regarding the bootloader, thank you for confirming.

TDG has a standard connector ICSP. For connections, you follow the attached figure. CN1 ISP Programmer is your TiDiGino. ICSP is your Arduino UNO ARDUINO The free wire connects pin 5 of ICSP connector of TiDiGino to digital pin 10 of Arduino UNO. For the software follow the instructions of the video. good luck Michele

Hello I would like to program a atmega168 chip by following your method. Right now I have arduino mega 2560 to be used as ISP. Can you please say if I need to change any value of the code that I have to paste in the boards.txt like “upload.maximum_size” or any fuse value? (as it has 16KB of memory instead of 32KB of the atmega328) And do I need to do anything else as I would be using Mega as ISP?

Hello Rohan you must describe me how you want to set the clock of the micro ATmega168, otherwise I can not give you a correct answer. Arduino MEGA is fine as ISP programmer, but the connections are different, are well described in the opening lines of the sketch Arduino ISP

What files of the IDE need changing? Is there another programmer (hardware) that is better for this? What is the use of FT232RL USB to Serial break-out board from Sparkfun (http://www.sparkfun.com/products/718), and is it necessary?

Also, what else do I need (hardware and/or software) to connect the ATmega32 to a computer to

1. upload Arduino sketches onto it, and

2. be able to use the Serial.read and write commands?

I have the latest Arduino version- 1.0.5

I’m kinda new to Arduino so it would be great if you could tell me the step by step process and the necessary hardware pin connections too. Can you help?

a micro AVR can be programmed with an ISP programmer (what you already have) or using the Arduino sketch ArduinoISP or through a USB-to-serial converter (such as Sparkfun). But in the latter case the micro must have on board a firmware called “bootloader”.

To program a micro AVR via ISP technical and Arduino IDE requires two basic things:

1 – the technical characteristics of micro, written to the file AVRDUDE.CONF

2 – a “core” specific to the IDE. The core contains all the information that allows the dialogue between IDE and micro.

Hello Michele, I’m working on a project in which I need to upload a program into brand new ATmega168V-10PU microcontrolers (that I’ve got straigth from Atmel). I have the arduino UNO with ATmega328 and the IDE using is 1.0.1. In order to do that I followed exactly what it’s explained in this page. I built the exact same circuit with the 16MHz crystal oscilator. Then I modified boards.txt (here I started to have doubts because my microcontroler is different to the one used here so I didn’t no what to change), then I upload the sketch ISP to the arduino UNO, next I set arduino as ISP and finally I load the blink example and tryied to programe my new ATmega168V-10PU microcontroler. It’s been a complete nightmare, because it doesn’t work. Giving messages like ” not sync”, “signature problemes”, … I’ve been trying to understand what may be going on and I have some ideas. Maybe it’s because this microcontroler are initially set to work with 8MHz inside oscilator, or maybe it’s because I’m using a 16MHz external oscilator while this microcontrolers can work up to 10MHz. Or maybe it’s because the boards.txt or the bootloader need to be different with this kind of microcontroler. I need some light here. Thanks a lot for your help!!!

I have set up everything as described above. I am using an ARDUINO MEGA as ISP to program a 328 chip on breadboard with 16mHz crystal. I bought the 328 chip from market and flashed the bootloader (as it was virgin!). Now when I try to upload the Blink sketch an error message pops up saying

In file included from Blink.ino:10: E:Installed Softwaresarduino-1.0.5hardwarearduinocoresarduino/Arduino.h:213:26: error: pins_arduino.h: No such file or directory

Ans: I used Arduino Mega 2560 to load the bootloader in the Atmega328.

Q: Which board are you using to load the sketch?

Ans: I’m using the same Arduino Mega to load sketch.

Q: Which bootloader do you have loaded in the micro?

Ans: I have no idea which bootloader I flashed but I can say exactly what I did to flash bootloader in new chip. Here is what I did:

1. Loaded the Arduino ISP sketch from example.

2. Flashed it into the Mega.

3. Then Tools>Board>Atmega in Stand Alone.

4. Tools>Serial Port>COM8 (its the COM port for the Mega)

4. Then Tools>Programmer>Arduino as ISP

5. Then Tools>Burn Bootloader

I flashed the bootloader in this way 3-4 times and everytime the led flashed, that you told to connect to pin 19 of the 328 chip with a resistor. After burning bootloader it said “Uploading Bootloader Complete”.

With this operation, the stand-alone micro 328P is loaded Arduino UNO bootloader. Then mount it on Arduino UNO, Arduino UNO connects to the USB port, select Arduino UNO and the new USB port and make a normal UPLOAD, in this way should work.

Hi David, I see too much confusion in your messages and in the errors. You must completely erase IDE 0022 and works only with IDE 1.0.1. I need info: Which Arduino board are you using as a programmer? Which micro are you planning? Which clock must have the micro after programming? What virtualboard are using, in the file boards.txt? You must re-check all connections well. Best regards

Unfortunately you can’t program an ATmega16 with virtualboard ATMEGA328P (atmsa16.build.mcu = ATMEGA328P). To program a micro must have the core for Arduino, so you have to look on the Internet if it exists. Otherwise you can program the micro only using the software ATMEL STUDIO 6.

Best regards.

davidhengo

September 25, 2013 at 4:43 PM

your right! after hours of internet surfing i found this web page, where explained me a lot questions that i had.

Hello, the instructions that are in the blog related to the IDE0022. If you read the post you’ll find the upgrade instructions for IDE 1.0.x There are significant changes that affect the board and the virtual IDE commands. Best regards

I am following the first approach. Every thing worked fine up till uploading an ISP program to the microcontroller on the Arduino board. Further while trying to upload on the the Microcontroller on the bread board I m getting ‘ Error compiling’ saying with further description as ‘C:Program Filesarduino-1.0.1-windows(1)arduino-1.0.1hardwarearduinocoresarduino/Arduino.h:213:26: error: pins_arduino.h: No such file or directory ‘. The microcontroller on the Arduino board is Atmega328P-PU while that on Breadboard is ATmega328-PU. Firstly, I thought this may be due difference in the device signatures but not sure as the error description does not say so. I didnot alter any of the Device signatures therefore. Am not getting whats the exact matter is. I am using IDE version 1.0.1

Hi , the instructions are for IDE0022, if you are using IDE1.0.x look in my post, I explained the differences. The ATmega328 is very different from the P type and its programming must change the configuration file AVRDUDE and create a specific board. It is NOT a very simple operation.

Hi, Thanks for the immediate and kind response. I some how solved the above mentioned problem, for that I copied the file(notepad format) named ‘ pins_arduino ‘ in location ‘C:Program Filesarduino-1.0.1-windows(1)arduino-1.0.1hardwarearduinocoresarduino’. and got a clear way up till oading program onto the breadboard microcontroller. On uploading the blinking program I got the message ‘ Done uploading ‘ without any errors. But on setting the preferences in the file menu, I saw in the comment menu ‘ avrdude device signature=0x000000 avrdude Yikes! invalid device signature and it tells to double check the connections and to override ‘ something ‘ with _F something sort of that and the microcontroller on bread board does not blink the LED connected to the pin 19 although I have got the message ‘ Done uploading ‘ without any errors. So please suggest some solution I am not getting what exactly the problem is.

HI, I’ve already given you the answer, the 328 and 328P are micro different from them, but unfortunately it is not easy to provide all the numerous steps to solve the problem. I recommend having a search on the net. I am sorry.

Hi Michele, Thanks for the previous help. I want to know , if all the arduino boards with different micros have the same bootloader or the different bootloader, if they have different bootloaders, in what aspects the bootloaders are different

Hi, The bootoader is specific for each type of MCU, but is not necessary. It only need if you want to update the firmware via serial communication. The technique ISP allows you to upload a firmware in the micro even without the bootloader. Instead it is essential to get the core; the core is a set of information about each type of MCU and serves to allow proper interfacing with the MCU Arduino IDE.

Chirantan Kansara

January 13, 2014 at 8:41 AM

so in this reference I would like to ask, is it possible to upload a program in MCU ARM (anytype) through Arduino UNO which has ATmega 328?

Sir, recently got success in bootloading the previously discussed ICs. Thanks a lot for your kind help and guidance. Please let me know if I can interface a sensor whose output is 4-20 milliamps to ATmega 328 ADC channel or i will need any sort of conversion.

OK, It is not possible to read to a variation in the current Arduino, you must convert it into voltage variation, perhaps by running current through a precision resistor and applying Ohm’s law.

Chirantan Kansara

February 23, 2014 at 12:19 PM

Thanks… your suggestion and guidance has always helped me to improvise. I have to connect xbee module to arduino without using xbee shield, I know that xbee works on 3.3v and its power supply should regulated from arduino 5v to 3.3v but do i need to regulate the arduino’s Tx and Rx lines to 3.3v so that they can be connected to arduino or thay can be directly connected to the xbee module. if they have to be regulated to the 3.3v then what should be the approach for doing so.

Guest

November 1, 2014 at 4:45 AM

hi is it work with clone arduino-uno ??

Vitor

January 19, 2014 at 5:04 PM

Hello Michele Menniti, Thanks for your very good post. I can use your tutorial but i have a Arduino Mega. I can use a Arduino Mega for this tutorial? I need change something in board.txt or i can use your example? I will use a ATmega328 for my standalone

Hi Vitor, you can use to program the Arduino MEGA ATmega328P in stand-alone mode. You do not have to change the file boards.txt. You just have to change the ISP connections: MEGA pin 53 to pin 1 of 328 MEGA pin 52 to pin 19 of 328 MEGA pin 51 to pin 17 of 328 MEGA pin 50 to pin 18 of the 328 Best regards

Hi, you can use IDE 1.0.5 r2, hardware connections are the same, if you want to burn the bootloader also the software instructions are the same. If you want to program ISP direct you must follow these steps:

1 – Set the board “Arduino UNO” and the corresponding COM / USB / DEV. 2 – Set the programmer “Arduino as ISP” 3 – Open the sketch “ArduinoISP” present in the samples and make upload to Arduino UNO 4 – Now open the sketch “blink” 5 – Set the board “ATmega328P 16MHz” 6 – Run the command File – Upload Using Programmer

If you want to load the bootloader instead of the sketch, you must only follow the steps 1-2-3, then: 4 – Run the command Tools – Burn Bootloader.

Keep in mind that: the micro leaves the factory to 1MHz, if you want to use it clocked at 16MHz must set the fuse, the only way to set the fuse is loaded BEFORE the bootloader and then send the sketch. Good luck!

Hi Michele, thanks for the speed response to my question. There is only one doubt: if I only want to burn the bootloader, how I set the fuses ? How can I calculate the right fuses to set ? Thanks againg for your help !

Good morning sir, Sir, Thank you for spending you valuable time for me. before this I have written some many embedded master for help but none of them replied . you are first master who had given a valuable time for me.

Rafa Botero

October 18, 2014 at 6:09 AM

Hi Michele, I just wanted to thank you, because All your instructions worked like a charm. I Built an Arduino Standalone on a breadboard with an AtMega328p, I had the clock (speed) issue and solved it with your instructions, creating a new Board. I used the Arduino UNO R3 as the ISP and Arduino 1.06 IDE to burn the bootloader . Everything worked perfect !!!.

I just have a couple of questions. Is there any advantage of keeping the bootloader in the Arduino Standalone ?

The upload speed parameter (upload.speed) of the virtual board, will affect the load of future sketches ? or is it required only to burn the bootloader ?

Hi Rafa, the bootloader in a stand-alone circuit is only needed if you plan to do updates via serial port, otherwise it is useless. The upload is only used for serial communication, in the ISP programming is unused.

Hi Som, please refer you to Arduino Reference on-line, about the family command Serial. 1 – The value of .begin must equal to value Serial Monitor 2 – The .print (or .println) should be placed in loop, not in setup.

Hi Zubin, yes, it is possible, do not need an additional core. I devoted to this topic several pages of my book “Arduino e le tecniche di programmazione dei microcontrollori ATMEL”. This book is written in Italian but is full of images.

I have tried two methods on two different computers and two different target ATmega328P’s, same result. 1. Build and test Breadboard Arduino UNO to ensure Blinky works. This is done by inserting the AT328P into an UNO board and uploading. 2. Connect Arduino USB2Serial to PC. 3. Open IDE (v.1.6.7) 4. Ensure USB2serial appears as a port. 3. Connect USB2serial to breadboard, Tx/Rx to Rx/Tx and all other connections. 4. Select UNO as target 5. Upload It takes a while to fail but does every time.

Neither could I but after much frustration and diagnostics I found the problem! Turns out that I had one bad cap at the xtal. Strange because the MCU would run if programmed elsewhere but would not upload new sketches in standalone mode. Got it working now.

Mike Murphy

January 13, 2016 at 3:14 PM

Make any sense to you?

Mike Murphy

January 8, 2016 at 10:31 PM

Just tried it with v1.0.5

Same result.

Error is avrdude: stk500_getsync(): not in sync: resp=0x00

Che

July 24, 2016 at 7:38 PM

avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03

I tried a lot if things for days but I keep getting this error. I don’t know what to do…Off course that I made all of your suggestions but again the same error.

Hi, this error indicates an incorrect dialogue between the programmer and the micro, usually when loading via the serial port. It is almost always preceded by a triple distanced flashing LED TX serial programmer. Possible causes are: the use of a wrong board, the selection of a COM that is not the one associated to the device connected to the PC, the inversion of the TX / RX signals. Best regards

Michele thank you very much for answering. I am using Arduino Yun as a serial programmer which works fine as stand alone unit. But when I use it as a serial programmer something bad is happening because Tx LED doesn’t flash at all, which I can not understand because everything is absolutely fine(COM, board selected etc…) and checked many times. Only one thing you mentioned is now bothering me: inversion of TX/RX which I didn’t already took to consideration because I thought it is the same as for example on Uno. (I uploaded ArduinoISP on Yun so I can use it as serial programmer) – Maybe I should check ArduinoISP sketch to see configuration of Rx/Tx ports? Regards

You may not use Arduino as a serial programmer without removing his chip. Unfortunately I read a lot of confusion but I do not have much time to fix your problem. I advise you to write to the Arduino Forum. Best regards.

Sorry I confused you. I am using Arduino Yun to burn bootloader on Atmega 328P which I placed on Arduino Uno board but I am getting error I posted in the first post. That thing drives me nuts because I tried so many things and no result just: avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03

Hi, I built standalone ardiuno using atmega328p, then loaded boatloader using ardiuno as isp, everything works fine as long as I use the same pins to upload new code. The problem is then I wanted to upload code using usb to serial ic (ftdi sparkfun basic ) but it was not working so I checked sparkfun basic on ardiuno pro mini and it worked perfectly. I checked 100n cap(DTR) for reset and that was good to. Finally I plugged my atmega328p into arduino uno board and it would not upload using arduino build in atmega16u2 . I live in South Africa and atmega328p are not cheap already have done this to two chips and have no idea how to remove bootloader without icsp. Not going to buy one because they are stupid expensive here. Please can you help me get serial working.

Hi, if you want to use the serial upload via bootloader, it’s important to run the burn bootloader via the Arduino IDE, so the fuses are set as Arduino UNO (FF-DE-05). If you have done this the serial communication with Sparkfun FTDI has to work. Attempts to reverse the signals tx and rx. You added quartz with the two capacitors? You have set in the IDE Arduino UNO? If it does not work even add a photo of the connections between ftdi and standalone and write what error shows IDE. Kind regards. Prof. Michele Menniti

Thank you Prof. for replying to my question, I am almost certain that it is a fuse issue. I say this because I was able to program the atmega328p from my arduino in my breadboard using the Sparkfun FTDI (Implying tx,rx and external oscillator are sound). I am currently reading up on away to reset all fuses back to their pre-bootloader state using the adruino as an ISP (since this is my only way of accessing the mirco), if you have any advice I would appreciate it.

Hello Michele, I am working with 328P/16hz/5v, I had programmed it in arduino uno board,but when I put this in my standalone board it won’t work,I had checked everything in hardware is ok,pin to pin. whenever i touch the crystal it started for a while again after reset it goes in not working condition.I had changed crystal,chip everything.please is there any change to config to do, because chip provider claimed chip had bootloader inbuilt in chip.Please guide me

My guess is the problem is not in circuit, but in program,I had programmed 328P with arduino uno and trying to use in stand alone,don’t know is their any change to be made in programme so that ist can work in stand aolne mode.

If you use a micro with pre-loaded bootloader, you can program it directly into the Arduino socket, instead of the original; it will work properly in stand-alone mode. If you have programmed the microcontroller via ISP, then the bootloader has been erased, but in this case the fuses must be changed. I wanted to see the circuit in the picture to check if the crystal and the two capacitors were mounted near to the micro, as well as the C6 capability. If it’s all ok check the values of the capacytors and replace the crystal.

The crystal and the capacitors are distant from the reference pins, even the condenser on the power pin 7. Also on the two IN / OUT pins of the 7805, you must have 100nF decoupling capacitors. However, follow the suggestions in my previous post.

Berry Marlin

July 13, 2017 at 4:43 AM

Hi, my name is marlin. Good article, this is very interesting and can increase my knowledge. thank you for sharing. always success

i read all your comments here but unfortunately cannot find a solution for my problem and hope you can provide any support please .

i have HC-05 Bluetooth module connected to atmega328p loaded with uno bootloader on a breadboard .

i can upload any sketch to the atmega fine , i uploaded the arduino-isp sketch to the atmega with success ,

now the issue occurred , when connecting another atmega328p to this atmega for programing (miso,mosi,sck,reset), i received : avrdude: Device signature = 0x000000 avrdude: Yikes! Invalid device signature. Double check connections and try again, or use -F to override this check.

i checked the connection , the connection is ok , also the same happened if i tried to burn the bootloader .

i tried many boards with many config , but the same .

noting that if i do the above with arduino uno board connected with usb with the same wiring and the same chip , everything is going fine .

If I do not see how you made the connections between the arduino programmer and the micro stand-alone I can not understand what is happening; there are many error factors: virtual board, IDE set badly, IDE command executed, connections, stand-alone with wrong mergers …

Hi, The error you get is usually due to ISP connection problems or the absence of external quartz. The image is correct, if in reality it is the same, then there may be several problems: incorrect fuses, incorrect virtual board, incorrect IDE command, micro bricked, real loss of the signature. Unfortunately, the question becomes complex and is not on a blog that can be solved. The only possibility is to write on the official Arduino Forum, where you can open a specific thread. Best regards.