Today let us learn how to program the ATtiny2313 using the Arduino Microcontroller Platform. Let's Get Started...!!
For this you will need:
- ATtiny2313 of course
- Arduino (Any Model)
- USB Cable for Arduino
- 16 MHz Crystal Oscillator.
- Jumper Wires
For testing purposes, you will need a LED and a 150-220 Ohm Resistor.
Step 1: Getting the Required Files...
Programming the ATtiny2313 requires extra hardware files. Click the link given below to go to the web page of the files and download it.
ATTiny Core is the best hardware files to program any of the ATtiny ICs.
Unzip the file and copy the ATTinyCore-master and paste it in the hardware folder of your Arduino IDE.
Note: Make sure you close the IDE before you paste these files. If not closed, the files may not function temporarily ar the IDE may crash.
Step 2: Getting Your Arduino Ready....
Firstly connect the Arduino to the Computer and upload the ArduinoISP sketch which is available in the Examples.
Note: Make sure the Programmer Option in the Tools is set to AVRISP mkll.
Now set your Programmer Option to Arduino as ISP.
Go to the Tools Menu and change the Board as ATtiny 4313/2313.
Now go to the Tools again to see 4 additional options. Set it as shown:
- Initialize Secondary Timers: "no"
- B.O.D.: "B.O.D. Disabled"
- Chip: "ATtiny2313"
- Clock: "16 MHz (external)"
Step 3: Getting the Connections Right...
Connect the ATtiny2313 to the Arduino as shown in the Second Picture. Also, connect the Crystal to pin 4 and 5 of the ATtiny2313
Note: Upload the ArduinoISP sketch before you make the above connections.
Step 4: Uploading the Sketch...
Firstly, Burn the Bootloader into the ATtiny2313. This can be done by clicking on the Burn Bootloader option in the Tools Menu.
After it says done, you are ready to upload sketches to the 2313. Just open any code and Upload it.
Note: Not all sketches work on the ATtiny. They have their own limitations. For further information, please read the ATtiny2313 Datasheet.
First, try the Blink Sketch. Refer the Pin Diagram for the Arduino Pin Number on the Arduino...
Step 5: Yes, You Did It....!!
Now you can play with the ATtiny2313. Implementation of the ATtiny in other projects becomes easy. Now you can Program any ATtiny IC with this method. Remember, few ICs have lesser clock speeds. Overclocking the IC damages it. So, Take Care about it....
If you want to use your Arduino as a Microcontroller platform again:
- Change the Board option in your tools menu to the Board you have
- Change the Programmer Option from Arduino as ISP to AVRISP mkll
Now you are free to use your Arduino and your ATtiny...
Note: Disconnect the ATtiny before performing the above changes.