Quick Navigation All projects Hardware Links Top projectsAlan numitron clock Clapclap 2313/1386 SNES Pi Webserver USB Volume/USB toys Smokey amp Laser cutter WordClock ardReveil v3 SNES Arcade cabinet Game boy projects cameleon Home Presence Detector GitHubAlanFromJapan Contact me![]() Who's Alan?Akizukidenshi Elec-lab Rand Nerd Tut EEVblog SpritesMods AvrFreaks Gameboy Dev FLOZz' blog Switch-science Sparkfun Suzusho Datasheet Lib Reddit Elec Ermicro Carnet du maker (fr) |
ATtiny2313Last update: Sat Jan 10 23:04:53 2026
ATtiny 2313Memo fact sheet
Projects using Attiny2313RapideUSB II, Clapclap 2313, Home Presence Detector, Guitar Rod of Command, ...Pin Layout
ATMEL ATTINY2313
+-\/-+
RESET PA2 1| |29 VCC
RX (D 0) PD0 2| |19 PB7 (D 16)(SCK)
TX (D 1) PD1 3| |18 PB6 (D 15)(MISO)
(D 2) PA1 4| |17 PB5 (D 14)(MOSI)
(D 3) PA0 5| |16 PB4 (D 13) (PWM OC1B)
INT0 (D 4) PD2 6| |15 PB3 (D 12) (PWM OC1A)
INT1 (D 5) PD3 7| |14 PB2 (D 11) (PWM OC0A)
(D 6) PD4 8| |13 PB1 (D 10) (AIN1) [Comparator-]
(PWM OC0B)(D 7) PD5 9| |12 PB0 (D 9) (AIN0) [Comparator+]
GND 10| |11 PD6 (D 8)
+----+
Pin configurationTaken from Atmel Attiny 2313 pdf page 48 - Switching between input and output![]() Alternate development tool : WinAVRMeans, you get bored of trying to make that 2313 work with Arduino software, or you get desperate that the "blink" program once buit is 790 bytes%20 (while max is 2048)!! Ok, then you have to turn to assembler, not big deal. FYI the same program is archieved in 100 bytes%20, means roughly a factor 7 in size ... wow.
ProgrammerPololu, half the price of the official ATmel tool (1995 JPY at Switch-science.com).Things to know:
Things to know when programming your ATtiny 2313
//factor settings is to divide internal clock 8MHz by 8. //don't, and just run at 8 MHz (set the clock divider to 1 so no effect) CLKPR = (1<<CLKPCE); CLKPR = 0; // Divide by 1 Sample codesTimer interrupt
Pretty long example but it shows a simple PWM AND TIMER at the same time (uses the 2 timers in the end). It was REALLY hard to find a simple example of timer interrupt on the net, the "hello world" sort of. Here I made it from info of here and there and of course the not-so-clear documentation of AVR (but when you know what you search, ok it's a good one). Note: timer0 is 8bit and timer1 is 16bits, and when using the overflow interrupt (time it takes to become 0xFFFF) timer1 is 256 times longer than timer0 ! Obvious but hey, I had to think a little to understand it. // // test of timed interrupt on attiny 2313 AlanFromJapan http:kalshagar.wikispaces.com/ // // Inspirations : http:cappels.org/dproj/1_kHz_Signal_Source/1_KHz_Sine_Wave_Generator.html http:www.daqq.eu/index.php?show=prj_sanity_nullifier http:pichonjulien.blogspot.com/2009/10/pwm-avec-un-attiny2313.html // // includes #include PWM with ATTiny2313http://pichonjulien.blogspot.com/2009/10/pwm-avec-un-attiny2313.html#include Basic sample : interrupt comparator hello world on attiny2313//Minimal sample of Comparator interrupt on attiny2313 // includes #include I2C TWIAs a masterUsed in the Guitar Rod of Command project.Holy Graal http://www.instructables.com/id/I2C_Bus_for_ATtiny_and_ATmega/ Note the following :
As a slaveUsed in the Laser cutter project as the LCD controller.
Things to know :
Infraredhttp://openlgtv.org.ru/wiki/index.php/Using_a_generic_microcontroller_board_as_an_LG_service_remoteWith Arduino IDE
CoreHere http://hci.rwth-aachen.de/tiki-download_wiki_attachment.php?attId=769&page=luminetBoards.txtAppend following text:############################################################## attiny2313.name=My Arduino w/ ATTINY2313 attiny2313.upload.protocol=hidspx,-d1 attiny2313.upload.maximum_size=2048 attiny2313.upload.speed=19200 attiny2313.bootloader.low_fuses=0xe4 attiny2313.bootloader.high_fuses=0x9d attiny2313.bootloader.extended_fuses=0xff attiny2313.bootloader.path=attiny2313 attiny2313.bootloader.unlock_bits=0xFF attiny2313.bootloader.lock_bits=0xCF attiny2313.build.mcu=attiny2313 attiny2313.build.f_cpu=8000000L attiny2313.build.core=attiny2313 |
|
All content on this site is shared under the MIT licence (do what u want, don't sue me, hat tip appreciated) electrogeek.tokyo ~ Formerly known as Kalshagar.wikispaces.com and electrogeek.cc (AlanFromJapan [2009 - 2026]) |
|