Programming an ATMEGA328P-PU on a breadboard with Arduino ISP
The objective here is to setup an ATMEGA328P-PU chip on a breadboard, and program it via an Arduino operating as an in-system programmer. I subsequently built a DIY shield version of this project in LEAP#099 ATmegaISPShield.
See more links and references at the end, but these videos cover at all very well:
Arduino as ISP
Arduino on a Breadboard
Julian’s Ardutorials: Arduino as an ISP
Wire up according the schematics attached. The ATmega168/328-Arduino Pin Mapping page is a good reference for understanding how the chip pins relate to familiar Arduino functions.
Setup the Arduino ISP. In this case I’m using an Arduino Uno as the programmer:
Tools > Board > Arduino Uno
Tools > Port > (correct port for Arduino Uno)
- Upload Examples/ArduinoISP sketch to Arduino Uno
Programmer > Arduino as ISP
Next burning the bootloader. A bootloader may already be present on the chip in which case this may not be necessary. But if in doubt, burn it again:
Tools > Burn Bootloader
Now the system is ready for uploading a sketch.
- Open desired sketch
File > Upload Using Programmer(or shift-click the normal upload icon)
Crickey, it works.
NB: in the picture, digital pin 9 (chip pin 15) is wired to a LED for a test scketch
Programming in-circuit via ICSP header
This approach can also be used to program chips on a board with an ICSP header.
The conventional arrangement of the ICSP pins is as follows. Although the pin numbering approach may vary, the functions should be in these positions:
The 5V power pin should only be connected if one wants to power the target board via the header. If the board is already powered, it should not be connected.
Whether the target host can or should be powered via the header depends largely on the design of target circuit.
Here’s a circuit (actually LEAP#368 GranularSynth) being programmed via an ICSP header:
Credits and References
- LEAP#099 ATmegaISPShield - a DIY shield version of this project
- Atmel ATmega328P Product Info
- ATmega168/328-Arduino Pin Mapping
- Arduino as ISP
- Arduino on a Breadboard
- Building an Arduino on a Breadboard
- Nick Gammon’s How to make an Arduino-compatible minimal board
- Using an Arduino as an AVR ISP
- From Arduino to a Microcontroller on a Breadboard
- AVR Programming - great little guide to avr ISP
- 1-Day Project: Build Your Own Arduino Uno for $5