For this step of our tutorial, we’ll be making the connections from our Arduino to our µcontroller. For this, we will be using a circuit made for flashing the AVRs used in arduinos. Luckily, Atmel makes it very easy to program all their chips using ISP (In-System Programming, in which we connect the programmer to the chip via wires), and it’s a similar process for all. We just need to worry that the files we use to flash are made for the particular chip.
So, if you look closely to the image, you’ll see that you need:
- Your AVR (in this case, ATMEGA168)
- 2 capacitors (18-22 pF)
- 10 μF Capacitor (Arduino Uno)
- 16MHz crystal
- Leds and resistors
Now we can begin the assembly. Be careful on the wiring of your AVR. The schematic above shows how to connect the ATMEGA168. If you’re trying to program another chip, you should read it’s datasheet and find the following pins, and connect to the Arduino pins shown:
- 10: slave reset (also connects with a resistor to the VCC)
- 11: MOSI
- 12: MISO
- 13: SCK
For instance, if you’re using an ATMEGA328, you should connect:
- Arduino : AVR
- 10 : 1
- 11 : 17
- 12 : 18
- 13 : 19
Once all that is is place, we can start the programming stage. We open the Arduino IDE, and go to Tools > Board and choose our version of Arduino. After that, go again to Tools > Programmer and check AVRISP mk2. This tells the Arduino that we’ll program the AVR using the arduino itself.
Now, File > Examples > ArduinoISP. This will load the sketch that makes our Arduino act like a AVR programmer. Check and upload this sketch. If you are using an Arduino Uno (in my case, an Arduino Diecimila), you should now put the 10 μF capacitor between RESET and GND. Look out for the polarity if you’re using a electrolytic capacitor. The – sign goes to GND. This will prevent the Arduino reset problem.
If all goes right, you have your Arduino programmer working as of now. Go to the next part to use it.