After receiving my first Arduino UNO, I soon realised that it will be impractical to use an UNO for every project. As with the Microchip family of MCUs, I wanted an easy way to program stand-alone circuits and chips.

Searching the internet, it was clear that the Arduino IDE can cater for all my needs, and that no additional hardware will be required. The Arduino UNO can be programmed as an In Circuit Programmer with the supplied example sketch ArduinoISP and the UNO. There is thus no need for a separate programmer, or using AvrDude software for programming. A lot of examples on this was found on the internet.

After some testing, it was clear that programming the AtMega328P was not as easy as I thought. Programming all depended on the AtMega328P chip. Does it already contained the bootloader, or is the chip blank? Costs of a chip with bootloader is double that of a clean chip, so my first batch of chips was blank.

What is the difference, you may ask. Well, it is all about the AtMega328P oscillator selection.

Lets look at the differences

AtMega328P with bootloader

Cost of this chip is about double that of a blank chip
The config registers of the chip is set to use an external crystal as clock (16MHz)
Without an external oscillator, one can not program the chip using the Arduino as programmer
Once fitted with an external oscillator, the chip can be programmed using the Arduino as programmer

AtMega328P without bootloader

Cost is half of a chip with bootloader
The config register of the chip is set to use the internal 1MHz clock
Chip can be programmed using the Arduino as programmer, BUT the program will run 16 times slower than the code should, as the Arduino IDE compiles the code to run at 16MHz, and not 1MHz
Chip can be configured for 16MHz by uploading the Arduino bootloader.

Step 1: Designing a Programmer Shield

Designing the programmer shield, I looked at the requirements to program chips with and without bootloaders. First, I looked at the oscillator selection.


AtMega328P with bootloader

The chip needs an external oscillator to be programmed, so this must be present on the shield.

AtMega328P without bootloader

If the chip was configured to use the internal oscillator, no additional components are needed. However, if the chip was previously configured to use an external oscillator, an oscillator will be required. With an external oscillator, both types can be programmed.

It is clear that adding an external oscillator to the shield, will accommodate all types of chips. A 16MHz crystal and 2 x 15pf capacitors, or a 16MHz resonator can be used.

LED indications

The source code or sketch indicated 3 outputs that can be connected to LEDs. This indications should be present on the shield.

Resetting the programmer

With a shield placed on top of an Arduino UNO, the UNO reset button is normally out of reach. The shield should include a separate reset button.

Powering the chip to be programmed

The chip that needs to be programmed, must have power connected to it. For the supply, the +5V and 0V is taken from the Arduino UNO board. However, inserting and removing a chip from the programmer with supply on, might cause damage to the chip. For this reason, a switch was added to the shield.

I/O Port protection

The ArduinoISP shield sets certain pins as OUTPUT on the Arduino UNO. If one now connect a previously used AtMega328P to the programmer, there can be conflict between the two chip's I/O lines that can cause damage to the ports. For protection, I added 470R resistors between the programmer, and the chip to be programmed.

Reset line of chip to be programmed

To ensure a stable reset circuit for the chip to be programmed, I added a 10K pull-up resistor to the RESET line.

Programming Method

ZIF Socket

This will be an easy way to program stand-alone chips, or to burn the bootloader on new chips. I thus added the ZIF socket to the design.

Programming cable

As almost all my designs are stand-alone circuits, my programming and development is done on breadboard. Thereafter, program updates are done via programming headers on the final circuit board. For this reason, I added the programming cable to the design.

Step 2: Building the Shield

I designed a PC Board with the free version of Eagle, and the shield fits directly onto the Arduino UNO. After designing the layout of the board, I noticed that the space taken up by the ZIF socket as well as the standard programming cable leave me with two options:

- use normal 1/4W resistors, which will leave no space for labels, or
- use SMD resistors which is more work, but will leave space for the labels.

My final PCB design uses SMD resistors, soldered to the solder side of the board. I used a 16MHz resonator as oscillator, but this can easily be changed with a crystal and 2 capacitors.

The power switch is connected such as to switch off the +5V to the ZIF socket, as well as the programming headers. This give more options when doing development on stand-alone circuits. Due to the limited space for the shield, the power switch was placed where the A0 - A5 pins are located on the Arduino. As these pins are not used for programming, they were omitted.

Building the circuit is quick using the PC Board. The standard header pins used to connect the shield to the Arduino, was modified. Using needle nose pliers, the header pins were pressed flush with the black plastic, and inserted from the component side.

Finally, I added labels to the LEDs and programming header.

Step 3: Setting Up the Arduino IDE to Use the Programmer

After building the programming shield, connect it to an Arduino UNO, and connect the Arduino USB cable to the PC.

- Open Arduino IDE.
- Select File - Examples - ArduinoISP
- Upload the sketch to the Arduino.
- The programmer shield LEDs should flash rapidly, where after the OK LED will fade on/off.
- Select Tools - Board - Arduino UNO
- Select Tools - Programmer - Arduino as ISP

The shield is now ready to be used to program any AtMega328P.

Step 4: Using the Programmer Shield

To burn the bootloader to the chip:

- Insert the chip into the ZIF socket.
- Goto Tools - Burn Bootloader
- Programmer LEDs will indicate programming status
- On completion, the OK LED will again fade on/off

To burn a sketch to the chip

- Insert the chip into the ZIF socket.
- Goto File - Upload Using Programmer
- Programmer LEDs will indicate programming status
- On completion, the OK LED will again fade on/off

The same method can be used to program an AtMege328P in a stand-alone circuit (breadboard or PC board) using the programming cable. For stand-alone circuits, it is normally required that they are powered up via their own supply. If no supply is available, and the circuit does not require a lot of power, the circuit can be power from the programming shield by switching on the +5V

Always ensure that you switch off the power switch (+5V LED off) before inserting or removing a chip into the ZIF socket, or before connecting/disconnecting the programming cables to the stand-alone circuit.

<p>Hi Eric</p><p>Thanks for an excellent instructable.</p><p>Can I load the sketches on on chips (having no bootloaders) directly? In that case, can the maximum memory be increased on the boards.txt files to the value mentioned in datasheet?</p><p>Sincerely</p><p>Sanjay</p>
<p>Hi <a href="https://www.instructables.com/member/SanjayG29/" style="">SanjayG29</a>.</p><p>When uploading to a new chip, first burn the bootloader. This will load the bootloader and set the configuration fuses to the correct settings.</p><p>Once this is done, any program uploaded using the programmer, will first erase the chip (erase the bootloader, but keep config fuses), then download your own program. No extra memory is used for a bootloader.</p><p>I suggest you add an additional board to the board.txt file to get access to all available memory.</p><p>##############################################################</p><p>uno.name=ATmega328 on a breadboard (16 MHz external clock)</p><p>uno.upload.tool=avrdude</p><p>uno.upload.protocol=arduino</p><p>uno.upload.maximum_size=32768</p><p>uno.upload.maximum_data_size=2048</p><p>uno.upload.speed=115200</p><p>uno.bootloader.tool=avrdude</p><p>uno.bootloader.low_fuses=0xFF</p><p>uno.bootloader.high_fuses=0xDE</p><p>uno.bootloader.extended_fuses=0x05</p><p>uno.bootloader.unlock_bits=0x3F</p><p>uno.bootloader.lock_bits=0x0F</p><p>uno.bootloader.file=optiboot/optiboot_atmega328.hex</p><p>uno.build.mcu=atmega328p</p><p>uno.build.f_cpu=16000000L</p><p>uno.build.board=AVR_UNO</p><p>uno.build.core=arduino</p><p>uno.build.variant=standard</p><p>##############################################################</p>
<p>Thanks Eric</p>
<p>Hi Eric,</p><p>Great job! Can you send the type (+ link?) of the resonator you've used?</p><p>Thanks, Rabbit</p>
<p>The resonator used is a standard 16MHz, 3pin resonator. It is basically a 16MHz crystal with the capacitors build into the resonator.</p><p>I have uploaded a new version of the PCB file, which now makes provision for the resonator, or a standard 16MHz crystal and 2 capacitors.</p><p>This makes it easiers and cheaper to build the circuit.</p><p>Hope this will assist you.</p><p>Regards</p>
<p>Can I use ATMEGA328-PU instead of ATMEGA328P-PU on your programmer shield? I m using Arduino 1.8.1 on my MacbookPro, do i have to downgrade version of arduino? While burn bootloader on ATMEGA328-PU it shows some error massage like this rdude: stk500_recv(): programmer is not responding</p><p>avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00</p><p>avrdude: stk500_recv(): programmer is not responding.</p><p>Pls give me right solution on my mail sanjushr2006@yahoo.com</p>
<p>The ATMEGA328 has a different signature compared to the ATMEGA328p.</p><p>You will have to add the ATMEGA328 to your list of boards in the Arduino IDE..</p><p>Follow this link for more info.</p><p>http://www.digitalmisery.com/2011/11/arduino-bootloader-with-atmega328-and-atmega328p/</p>
<p>Thank you Eric for your information about the link.</p>
i believe the Resistors in connection to pins 13 - 10 on arduino are simply for protection and are not entirely necessary. I have built a programmer Shield for ATtiny's and they have worked fine without those resistors...<br>could this be the same for the ATmega328?...
<p>Here is an explanation as to why I added the four protection resistors:</p><p>Arduino has not yet been programmed with the ArduinoISP softwaer.</p><p>There can thus be any program on the Arduino when the programming shield is connected. Lets say pin 13 is an output, and set high in the Arduino code (+5V on the output). </p><p>Now, the programming shield is used to program a stand-alone chip, or project, on which pin 13 is also an output. However, this output is set LOW (0V on the output).</p><p>There is now a short circuit created between the Arduino pin 13 and the IC to be programmed pin 13.</p><p>I added the 470R resistors to limit the current in such cases to prevent damage to either pins.</p>
<p>Thanks Eric... a question about the part that has the crystal on the schematic.... if i want to program it without the crystal, would it work ok just that part cut off?... or how would the schematic look like?.. </p>
<p><u style="">Oscillator</u></p><p><u>AtMega328P with bootloader</u></p><p>The chip needs an external oscillator to be programmed, so this must be present.</p><p><u>AtMega328P without </u><u>bootloader</u></p><p>If the chip was configured to use the internal oscillator, no additional components are needed. However, if the chip was previously configured to use an external oscillator, an oscillator will be required. With an external oscillator, both types can be programmed.</p><p>It is clear that adding an external oscillator to the shield, will accommodate all types of chips. A 16MHz crystal and 2 x 15pf capacitors, or a 16MHz resonator can be used.</p>
<p>a little late for me to notice the section where you wrote up &quot;Protection for the IO's&quot;...</p><p>IMO, for that purpose, diodes may actually be better since they only let the current flow one way, but i wouldn't know which way to point it to</p>
<p>Hi</p><p>No, a diode will not be sufficient for protection, </p><p>See my explanation above.</p>
<p>Do I have to remove the ATmega IC in the Arduino UNO before attaching the shield made?</p>
<p>Hi, and sorry for my late reply.</p><p>No, you must NOT remove the ATMEGA chip from your UNO board. Your UNO board becomes the programmer for the new ATMEGA chip placed in the ZIF socket.</p>
Can you convert to pcb express file, tanks
<p>Sorry, but I only use Cadsoft Eagle.</p><p>You can download the free version of Eagle here:</p><p>https://cadsoft.io/</p>
<p>Thank you.</p>
Cant I just insert the atmega328 in uno and upload the sketch and then remove the atmega and put it on the breadboard connecting clock n power supply?
<p>Unfortunately not...<br>When you buy a new ATMEGA328p, it does not have the bootloader programmed. The blank ATMEGA328p is also configured to run at 1MHz with it's internal oscillator, and not a 16MHz external crystal.<br>One can buy pre-programmed chips with the Arduino bootloader, but they are normally double the price of a blank chip.</p>
Coding mr link
<p>The one thing nearly every one forgets is to let the reader aware of the IDE version they used. It took me a while to find the right IDE for it to compile correctly. Also when it come to libraries it again would be useful to have the exact library used, often there are different versions around, zip the wrong one and trouble starts.</p>
<p>I have been using this programming shield from Arduino IDE version 1.0.5-r2 up to version 1.6.7 without any problems.<br>However, I have some programming/verify problems using version 1.6.8 &amp; 1.6.9, and can no longer burn the bootloaders. Thus I am back using version 1.6.7.<br>Regarding the libraries, I always save the library used on each project, with all the project files. This also include PCB and SCH files and other documentation. </p>
<p>Could you post the SCH file to go with the BRD files?</p>
<p>Sorry, but I only have the circuit diagram under step 1. I did not design the PCB using the Eagle SCH file. </p>
That's OK... I think I managed to create one. I've attached my SCH and BRD which you are welcome to use if you find them useful.<br><br>My layout is admittedly significantly different from yours. Probably not any better. Since I use OSH Park for my boards, double-sided is the same as single-sided cost wise, so I went with using the back side of the board as a ground plane. I could shorten some of the routing a bit by putting traces on both sides, but I wanted to try my hand at getting it all on one side.<br><br>I also wanted to put the 5V switch and LED near each other with the switch close to the chip release lever for the ZIF and the error LED close to the reset button. I wanted the reset button also conveniently close to the edge of the board.<br><br>I hope you find these useful or at least amusing.<br>
<p>For others that are wondering about the Schematic. The top component is an Arduino Duemilanove Shield map component from a library downloaded from SparkFun Electronics called &quot;SparkFun-Boards&quot;. The component is listed as &quot;ARDUINO_SHIELDNOHOLES&quot;. The pinout for the DUEMILANOVE should be compatible with the UNO and most other Arduinos as well.</p><p><br>The 28-Pin ZIF Socket is also from SparkFUn (SparkFun-Connectors library).<br><br>The Resistors and Capacitors come from SparkFun-Passives library.<br><br>The reset switch is TACTILE-PTH from SparkFun-Electromechanical library.<br><br>The 5V switch is SWITCH-SPDTPTH from SparkFun-Electromechanical library.<br><br>The LED (standard 5MM LED package) components came from a library I downloaded from Adafruit. The Crystal (CRYSTALHC49S) also came from the Adafruit library.<br><br>I used named lines to keep the drawing somewhat clean. The names are annotated at each apparently open line end. All lines with the same name are electrically connected. Thus, even though RESET in the lower section does not show a green line to RESET on the shield, because they share the name &quot;RESET&quot; they are, in fact, connected.<br><br>Since some pins on the Arduino have multiple functions and/or special abilities (such as PWM), those names are annotated accordingly. Thus D10 which is used for D10 or SS and which has the ability to be Pulse Width Modulated (PWM) is labeled D10/PWM/SS to indicate these two uses and the special ability applied to D10.<br><br>While the author did not connect pin 7 to pin 20 (Vcc to AVcc), I went ahead and added this connection based on the recommendation from the ATMEGA data sheet which says &quot;AVcc is the supply voltage for the A/D converter... It should be externally connected to Vcc even if the ADC is not used. If the ADC is used, it should be connected to Vcc through a low-pass filter.&quot;<br><br>NOTE: There is no low pass filter in this circuit as the ADC is not used during programming.</p>
<p>I just noticed... My version does not accommodate a programming cable or pass along the serial lines (RX/TX). This isn't a problem in my case as I only need to program stand-alone chips, but it could be easily added. I might add them and publish updated files at a later date.</p>
<p>Super helpful instructable!</p><p>I have no degree in electronics nor computing and still made this work thanks to your clear explanation, Eric. As I have no experience in etching, I chose an Arduino Protoshield to build it. With a little spaghetti, I admit, but whatever, IT WORKS :)</p><p>See picture: the blue LED close to pin 3 is fading gently on the rhythm of the Fade sketch (modified: output pin 3 in Arduino IDE, pin 5 of the AtMega328)</p><p>Happy :-))) </p><p>Jan</p>
I am glad you were able to use the Instructable. Happy programming
<p>Hey,</p><p>This is very helpful, thank you for the detailed explanation. I do have a question however. I burnt bootloader into my new Atmega328P using my Arduino Uno as the Programmer, which also is used to upload sketch to my new MCU. However, I am unable to upload sketch to the MCU except using the Arduino as the Programmer. Any thoughts? I know my connection is good because I am able to upload sketch to my other MCU using computer.</p>
<p>how I can burn a .h, made in atmel studio, to my atmega328 with the arduino?<br>with this I can?</p>
<p>I am still using Win XP, so I am unable to test this using Atmel Studio. However, I am sure that when you build/compile your project, Atmel Studio will also create a .hex file. </p><p>With a hex file, you can upload the file using AVRDUDE:</p><p>avrdude -c arduino -p m328p -P com1 -b 19200 -U flash:w:.<em><strong>/FILENAME.hex</strong></em>:a </p><p>avrdude -c arduino -p m328p -P com1 -b 19200 -U lfuse:w:0xff:m</p><p>avrdude -c arduino -p m328p -P com1 -b 19200 -U hfuse:w:0xfd:m</p><p>Just replace FILENAME.hex with your .hex file name.</p>
thanx<br>I've been researching and found information similar to yours.<br>I use the Arduino as ISP recorder,<br>with your commands and avrdude I burn the .hex.<br><br>I just had not found anything about fuses modifications.<br>where they interfere?<br>sorry my english, I speak Portuguese, then it might be difficult for you to read my question.<br>you are helping me a lot.<br>att.
<p>With some shaking hands, I copied your work on a proto-shield. Thanks for that great instructable!</p>
Great job. Glad you liked the Instructable.
<p>Hi Eric Could you please post the eagle Schematic I would like to make changes to put in the crystal and caps. This would be greatly appreciated and save me having to redraw the schematic in eagle.</p>
<p>The Eagle file is available under Step 2.</p>
<p>Hi Eric Many thanks for this much appreciated</p>
<p>Hi Draige<br>Hope this image will answer your question. This is my PCB standard layout when I create a new ATMega project. I use the same pin-outs on all my projects.</p>
<p>Hi Eric,</p><p>Thanks for the fast reply.</p><p>Indeed that awnsers my question.</p>
<p>Thanks for this instructable, it is very clear and easy to understand.<br>Still I have one question about the pins on the stand alone board (AtMege328P).<br>On the picture i see you have a strip of headers connected next to the Atmega on the separate board. <br><br>My question is: to what pins are these connected? where is the reset pin connected to? </p><p>Because the order of the atmega pins don't match the cable (17:MOSI, 18:MISO, 19:SCK, 20:AVCC, <strong>21:AREF</strong>, 22:GND and 1:RESET)</p><p>I made the programmer board, Works great, thanks.<br>I would like to make the separate boards aswell :)</p>
<p>can i use this board to program my tiny 85?</p>
<p>Yes you can, but not via the ZIF socket.</p><p>Use the programming cable and connect it to the AT TINY on a breadboard.</p><p>IC pin 1 - Reset</p><p>IC pin 4 - 0V</p><p>IC pin 5 - MOSI</p><p>IC pin 6 - MISO</p><p>IC pin 7 - SCK</p><p>IC pin 8 - +5V</p>

About This Instructable



More by Eric Brouwer:Converting Camping Deep Freezer Into Fridge/Freezer Using AtTiny85 12V, 2A Uninterruptible Power Supply Easy Project - Bench Power Supply (0 .. 30V, 2 Amp) 
Add instructable to: