Vous êtes sur la page 1sur 4

27/4/2014 Programming Attiny2313 with Arduino Uno

http://www.ernstc.dk/arduino/2313.htm 1/4
Programming Attiny2313 with Arduino Uno
The 2313 processor is a 20 pin chip with 17 I/O pins, it do not have a ADC (analog/digital converter)
It can be configured to run at 1 MHz and 8 MHz without External Crystal/Resonator
A comparison of the Tiny-family
2313 pinout Connection to Arduino
Download the Tiny-core here: code.google.com/p/arduino-tiny/
Follow the instructions in the readme.txt file
Connect your Arduino to the Attiny according to the picture to the right
connection to Arduino:
Arduino Attiny2313
13 19 PB7/SCK
27/4/2014 Programming Attiny2313 with Arduino Uno
http://www.ernstc.dk/arduino/2313.htm 2/4
12 18 PB6/MISO
11 17 PB5/MOSI
10 1 PA2/Reset
5v 20 VCC
GND 10 GND
Upload the ArduinoISP to the Arduino dont't connect the capacitor yet.
More information on this step
Note: the ArduinoISP has some issues in ver. 1.00
See this fix for a solution
Connect a 10 F capacitor from reset to ground on the arduino (negative side to ground)
If you are using a Duemilanove use a 120 ohm resistor from reset to Vcc
Open the blink sketch from the examples->Basic->Blink
Select Attiny2313: Tools->Board-> Attiny2313@1MHZ
Select ArduinoISP: Tools->Programmer->Arduino as ISP
Upload your sketch: Select File->Upload using programmer
Connect a LED with resitor to pin PB4 (physical pin 16)
Now you should have a blinkining Led on your Attiny 2313
Note the factory default is 1MHz, if you want to run it @ 8MHz, use: burn bootloader.
Select board -> Attiny2313@8MHZ
Select ->Tools->Programmer->Arduino as ISP
select ->Tools->Burn Bootloader
Note: this step do not burn a bootloader to your chip, it is only used to set the fuses to another clock-speed.
When you use it in your project, it will be a good idea to connect A 0.1 uF across VCC and GND as close
to the processor as possible, and a 10 K ohm resistor from RESET to VCC.
Communication with Attiny2313
It is always nice to be able to get debug information from your tiny.
On an Arduino you are used to use Serial.print() for this purpose.
Luckily you can use this on Attiny as well.
Actually you have more options:
TinyDebugSerial - comes with the core files (only output from attiny)
SoftwareSerial - use the SoftwareSerial library (Input/output attiny)
TinyKnockbang - use TinyISP(only output fram attiny)
RELAY_SERIAL - use TinyISP(Input/output attiny)
A more detailed explanation: here
A solution for the missing ADC
Atmel has some application notes on how to make a cheap ADC, using the comparator On the Attiny2313.
For example:
http://www.atmel.com/Images/doc0942.pdf
Sadly they don't provide any programming examples. But I recently found an easy solution
http://learn.adafruit.com/photocells/using-a-photocell
The sketch in the buttom of this page use a digitalRead() to measure the time in a rc-network.
In the example they use a photoresistor, but you can substitute this with a potentiometer.
I tried it With a 10 kOhm potmeter and a 0.1uF capacitor, which gave me readings between 0 and 600
In the sketch PIN 2, is PD2 on Attiny2313 - physically pin #4
Physical/logical pin numbers.
F.ex. pin 13 in the blink example is the physical pin 16
See the cheet sheet
27/4/2014 Programming Attiny2313 with Arduino Uno
http://www.ernstc.dk/arduino/2313.htm 3/4
// ATMEL ATTINY2313
//
// +-\/-+
// (D 17) PA2 1| |29 VCC
// RX (D 0) PD0 2| |19 PB7 (D 16)
// TX (D 1) PD1 3| |18 PB6 (D 15)
// (D 2) PA1 4| |17 PB5 (D 14)
// (D 3) PA0 5| |16 PB4 (D 13)*
// INT0 (D 4) PD2 6| |15 PB3 (D 12)*
// INT1 (D 5) PD3 7| |14 PB2 (D 11)*
// (D 6) PD4 8| |13 PB1 (D 10)
// *(D 7) PD5 9| |12 PB0 (D 9)
// GND 10| |11 PD6 (D 8)
// +----+
//
// * indicates PWM port
Coding Badly's ArduinoTinyISP
Avrdude tutorial
Avrdude, when using ArduinoISP
avrdude -P COM20 -b 19200 -p t2313 -c avrisp
Upload using TinyISP
-p attiny2313 -c stk500v1 -P COM3 -b19200 -Uflash:w:Blink.hex:i
Links regarding Attiny 2313 and Attiny85
IR-library for the Tiny's
38 KHz timers ATtiny84/85
Using the reset pin, and HV programmer
Optiboot 8Mhz
Arduino as ISP (ver 1.0) changes in sketch
Reducing baud rate in Arduino 1.0
27/4/2014 Programming Attiny2313 with Arduino Uno
http://www.ernstc.dk/arduino/2313.htm 4/4
Pin numbers
missing entry in avrdude.conf
Issues Arduino 1.0
Programming the Att2313 with Duemillanove
Using Arduino as seriel/USB controller
Tiny core release
About TinyTuner
Arduino as ISP (Playground)
Disabling reset
PeterVH Leonardo as ISP
Software serial receaive only
Arduino 1.0 and ISP not working
NG timer - PWM attiny85
Fix for Tiny > 4kb
AREF on attiny's
Attiny85 Remote control
ISP Attiny85
38Khz timer 84/85
Sleep demo code
TinyTuener2
Tom Carpenters Tiny Core
Coding Badly experimently Tiny Core
Tiny13 and KnockBang
Tiny core and version 1.5
Servo library for Tiny (by tylernt)
Other Arduino links:
Standalone Arduino
Standalone Nick Gammon, and chip-detector
Standalone Arduino 8mhz bootloader
Nick Gammon fuse calculator
ArduinoToBreadboard
More Standalone Arduino
328 vs 328p
Level shifting (SD Card)
PWM frequence Library
LM317 as LED driver
IR 38 khz generating
Disassemble Arduino code