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

By on March 14, 2012
Pin It

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 = 0xffuno.bootloader.high_fuses = 0xdeuno.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:

 

 

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:

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.

[Thanks to Michele Menniti]

 

From the Store

You can buy the ISP & Serial Programmer for all microcontroller Atmel ATmega‬ and ATtiny‬ in PDIP package and SMD.

About Prof. Michele Menniti

Prof. Menniti teaches Information Technology and Electronics at the University of Catanzaro (ITALY) and publishes educational articles and projects in the magazine ELETTRONICA IN

224
Leave a Reply

avatar
89 Comment threads
135 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
46 Comment authors
Michele MennitiAhmed Kamal MohamedBest posts in 2017 | Open ElectronicsBerry MarlinDattatray Patil Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Duncan
Guest
Duncan

Is there any reason why an Arduino Pro-Mini with a USB adaptor couldn’t be used for this project?

I have those and want to program some ATMEGA 328s for instant start up of program code (i.e. without the bootloader delay)

Thanks

trackback

[…] Arduino ISP (In System Programming) and stand-alone circuits | Open Electronics. Bookmark the permalink. « kougaku-navi’s fotolife – 20110424041802 Arduino Shields « Circuits@Home » […]

Michele Menniti
Guest

Hello,
You can use Arduino Pro Mini with a USB-Serial ISP Programmer for the function. But Arduino Pro-Mini must work at 5V and 16MHz. If you need help please ask.

Duncan
Guest
Duncan

Thanks

I have a 5V/16MHz Pro-Mini…

My idea was to build it into a small box with a ZIF socket on the top and a lead for in-circuit programming (If I can ever locate the 3×2 IDC connectors!!!)

If I encounter problems I’ll be in touch and I’ll send you a photo when it’s built.

Thanks again

Duncan

Michele Menniti
Guest

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,… Read more »

Duncan
Guest
Duncan

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).

Duncan

7Usam
Guest
7Usam

Great Work , but :/

i have atmega168v and 8MHz crystal and arduino ide ver 1.0

my change in board.txt

atmsa16.name=ATmega in Stand Alone (w/ Arduino as ISP)
atmsa16.upload.protocol=stk500
atmsa16.upload.maximum_size=14336
atmsa16.upload.speed=115200
atmsa16.upload.using=arduino:arduinoisp
atmsa16.bootloader.low_fuses=0xff
atmsa16.bootloader.high_fuses=0xde
atmsa16.bootloader.extended_fuses=0x05
atmsa16.bootloader.path=optiboot
atmsa16.bootloader.file=optiboot_atmega168_8.hex
atmsa16.bootloader.unlock_bits=0x3F
atmsa16.bootloader.lock_bits=0x0F
atmsa16.build.mcu=atmega168
atmsa16.build.f_cpu=8000000L
atmsa16.build.core=arduino

and start burn bootloader then output is

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
avrdude: stk500_cmd(): programmer is out of sync

what is the problem ?

Michele Menniti
Guest

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.

7Usam
Guest
7Usam

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 ?

Michele Menniti
Guest

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.

7Usam
Guest
7Usam

Thanks ;)

trackback

[…] • 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. • the +5 V pins of Arduino goes to the positive supply line of the breadboard; • pin 13 to Arduino pin 19 goes on the chip; Arduino ISP (In System Programming) and stand-alone circuits | Open Electronics […]

NukeTheMoon
Guest
NukeTheMoon

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:

uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard
##############################################################
atmsa16.name=ATmega in Stand Alone (w/ Arduino as ISP)
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.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

I first tried:

atmsa16.name=ATmega in Stand Alone (w/ Arduino as ISP)
atmsa16.upload.protocol=arduino
uno.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.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

Have any idea on what could be the problem ? :S

Guest
Guest
Guest

hi michele
does this perform with clone arduino uno ?

Michele Menniti
Guest

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.

Michele Menniti
Guest

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

NukeTheMoon
Guest
NukeTheMoon

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’d like to thank you for your quick answer and the great tutorial.

NukeTheMoon
Guest
NukeTheMoon

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:

atmsa16.name=ATmega in Stand Alone (w/ Arduino as ISP)
atmsa16.upload.protocol=arduino
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.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
atmsa16.build.variant=standard

So when I use ATmega in Stand Alone (w/ Arduino as ISP) board in tools to program i still program the UNO. Any idea why?

Michele Menniti
Guest

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;-)

Diego
Guest

Hi! in first place, congratulation for your work!

I need you to help me, i am working with atmega2313 and i connect my microcontroler according the datasheet and the pins (MISO, MOSI, SCK).
I conect all the conexions, i think that all is correct.

Also i burn the Arduino Isp in my board Arduino Uno and i downloaded a archive with boards.txt and cores, i change the fuses in the boards.txt, i think that its wrong.

I need help becouse i don’t know to do yet for this microcontroler works.

I’m sorry for my English becouse i’m spanish.

Thanks in advance.

Michele Menniti
Guest

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… Read more »

Michele Menniti
Guest

@ NukeTheMoon
Hello,
I’m sorry but these days I had to work hard and I could not do the tests that I have promised. As soon as I can to make sure you write it here for updates.

Diego
Guest

yes, i also connect the pin 10 and the resistor of 10k is between Vcc and Reset of 2313. If the resistor is between ground and reset the burn is bad. i copy you the boards.txt referent a attiny2313, maybe something is bad. attiny2313at8.name=ATtiny2313 @ 8 MHz (Oscilador interno) # The following do NOT work… # attiny2313at8.upload.using=avrispv2 # attiny2313at8.upload.using=Pololu USB AVR Programmer # The following DO work (pick one)… # attiny2313at8.upload.using=arduino:arduinoisp # attiny2313at8.upload.protocol=avrispv2 # attiny2313at8.upload.using=pololu attiny2313at8.upload.maximum_size=2048 # Default clock (slowly rising power; long delay to clock; 8 MHz internal) # Int. RC Osc. 8 MHz; Start-up time: 14 CK +… Read more »

Michele Menniti
Guest

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:

###############################################################################################
attiny2313at1.name ATtiny2313 = @ 1 MHz (internal oscillator; BOD disabled)
attiny2313at1.upload.using = arduino: arduinoisp
attiny2313at1.upload.maximum_size = 2048
attiny2313at1.bootloader.low_fuses = 0x64
attiny2313at1.bootloader.high_fuses = 0xDF
attiny2313at1.bootloader.extended_fuses = 0xFF
attiny2313at1.bootloader.path = empty
attiny2313at1.bootloader.file = empty2313at1.hex
attiny2313at1.bootloader.unlock_bits = 0xFF
attiny2313at1.bootloader.lock_bits = 0xFF
attiny2313at1.build.mcu = ATtiny2313
attiny2313at1.build.f_cpu = 1000000L
attiny2313at1.build.core = tiny

You burn tiny2313 directly without bootloader, it does not exist for this MCU.
Let me know.

Diego
Guest

My board was downloaded of http://code.google.com/p/arduino-tiny/downloads/list

Your code give me a lot of mistakes.
I don’t know that is the reason for it doesn’t work.

i give you more information:

– Software Arduino 1.0.1
– Sketch that i try to burn: Blink
– Pin 10 of Arduino to pin 1 of attiny2313
– With my board, the burn was succesful without mistakes but doesn’t work

I hope that you can help me! this is a puzzle! jeje

Michele Menniti
Guest

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

Diego
Guest

mmmm okei, i test your suggesion and i tell you with something.

certainly, where do you see the digital pin assigned a phisical pin??
Mayby, i can change the pin assigned.

Thanks!

Michele Menniti
Guest

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.

Diego
Guest

hi michele!! my attiny works yet!!! you have reason! the pins was the problem!! you are fantastic!!! thank you very much!!

Michele Menniti
Guest

Hi Diego!
I am very happy for you, congratulations!
Michele

Michele Menniti
Guest

@ NukeTheMoon: OK, I managed to make tests and to burn a ATmega328P with IDE 1.0.1. You follow these steps: 0 – Add the file boards.txt these lines: #################################################### atmega3216.name ATmega328P = 16MHz atmega3216.upload.protocol = arduino atmega3216.upload.maximum_size = 32768 atmega3216.upload.speed = 115200 atmega3216.bootloader.low_fuses = 0xff atmega3216.bootloader.high_fuses = 0xDF atmega3216.bootloader.extended_fuses = 0xFF atmega3216.bootloader.path = optiboot atmega3216.bootloader.file = optiboot_atmega328.hex atmega3216.bootloader.unlock_bits = 0x3F atmega3216.bootloader.lock_bits = 0x0F atmega3216.build.mcu = atmega328p atmega3216.build.f_cpu = 16000000L atmega3216.build.core = arduino atmega3216.build.variant = standard Save and close the file. Open the IDE 1.0.1. 1 – Set the board “Arduino UNO” and the corresponding COM / USB / DEV. 2… Read more »

Duncan
Guest
Duncan

Hi I finally found the time to build this and it seems to work fine on IDE 1.0.1. The Blink sketch was running slow and I realised that the ATmega328 was running at 1MHz. I tried burning the bootloader but it failed with the message: ***failed; avrdude: verification error, first mismatch at byte 0x0000 0xff != 0x07 avrdude: verification error; content mismatch I have Board set at ATmega328p = 16MHz and Programmer set to Arduino as ISP, then I clicked on Burn Bootloader. Am I doing something wrong or is this because I have burned the sketch first and it… Read more »

Michele Menniti
Guest

Hi Duncan, the situation can be fixed easily.
1 – Replace the value in the virtual board: eFuse = FF with eFuse = 07
2 – Save, then close and reopen the IDE 1.0.1
3 – Burn the bootloader (REQUIRED!!!)
4 – Upload blink, now everything should work.

Follow the instructions for 1.0.1 which I wrote in my last post

Let me know.
Michele

Duncan
Guest
Duncan

Hi Michele That fixed the problem and it is now working correctly. 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… Read more »

Michele Menniti
Guest

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.

Hello
Michele

Duncan
Guest
Duncan

Hi Michele Two problems: 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… Read more »

Michele Menniti
Guest

Hi Duncan,

The error “avrdude: stk500_getsync (): not in sync: resp = 0x00” indicates connection problems, double check that the wires and check the current COM port

You do not have to run “Burn Bootloader” before every upload sketches but only when you set the fuse of the micro.

You have to look “ElettronicaIn – Current Issue” in this same page, on the right frame

Michele

Duncan
Guest
Duncan

Hi Michele

I checked the wiring, I even tried a new USB cable – nothing…

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.

Duncan

Duncan
Guest
Duncan

Hi Michele 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… Read more »

Duncan
Guest
Duncan

Whoops…

That should have read…

“atmega32801.build.f_cpu=1000000L” & “atmega32808.build.f_cpu=8000000L”

(the curse of “cut and paste”)

Michele Menniti
Guest
Michele Menniti

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
##############################################################

Duncan
Guest
Duncan

Hi Michele Can I just confirm the steps involved – I think I am worried that I may overwrite the bootloader on the Arduino that is the programmer. To program a chip at 8MHz Internal Clock:- 1) Set “Board” to “ATmega328P 8MHz internal clock” 2) Set Comm Port 3) Set “Programmer” to “Arduino as ISP” 4) Click “Burn Bootloader” 5) Load the Sketch 6) Click “Upload Using Programmer” Yes? The programmer is now using a Duemilenove that blew its voltage regulator – as it is being powered only by 5V from the USB everything works fine (eventually I will replace… Read more »

melrick nicolas
Guest
melrick nicolas

where can i find the sample arduino isp sketch ???

Michele Menniti
Guest

In the list of programs included in the IDE, name ArduinoISP

Guillem Freixanet
Guest
Guillem Freixanet

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… Read more »

Michele Menniti
Guest

Hello Guillem, 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: 1 – edit the file boards.txt inserting the board for 168 16MHz (don’t change!) 2 – Upload ArduinoISP sketch in your Arduino… Read more »

Guillem Freixanet
Guest
Guillem Freixanet

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!

Michele Menniti
Guest

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
Guest
Guillem Freixanet

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!

Michele Menniti
Guest

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
Guest
Guillem Freixanet

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!!!!

Michele Menniti
Guest

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

Ian Blundell
Guest

Hi Michele

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.

Michele Menniti
Guest
Michele Menniti

Hi Ian,
which IDE version are you using?
You did both tests burn bootloader and upload sketches with the micro on-board?

Ian Blundell
Guest

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

Michele Menniti
Guest
Michele Menniti

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?

Lukas
Guest
Lukas

Dear Michele Menniti 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… Read more »

Kaledawit Esmelealem
Guest
Kaledawit Esmelealem

Hi

have you solve your problem I want to burn bootloader to blank Atmega328P-PU with Arduino uno r3 as ISP and which IDE version is compatible.
Please help me I want to make arduino in breadboard

Michele Menniti
Guest

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?

lukas
Guest
lukas

Dear Michele,

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!

Best regards,
Lukas

Lukas
Guest
Lukas

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..

thanks again,
L

Michele Menniti
Guest

Hi Lukas,
as I said these types of errors are recurring.
Thank you for the feedback.
Best regards
Michele

Juliano Polito
Guest
Juliano Polito

Another info: I’ve tried doing it using Arduino 0022 and it gives me the same error:

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override this check.

Thank you.

Michele Menniti
Guest

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… Read more »

Juliano Polito
Guest
Juliano Polito

Hi Michele, again! 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. Thank… Read more »

Michele Menniti
Guest

Hi Juliano,
I am very happy, I know that many times you something wrong in the connections.
I did not waste time, do not worry.
Best regards
Michele

melrick nicolas
Guest
melrick nicolas

where can i find the sample isp sketch ??? or pls send me the sample to my email add..
melricknicolas@yahoo.com
tnx … :)