One of our all-time favorite chips is the ATtiny2313.
It’s a little 20-pin AVR microcontroller that we’ve used in dozens of projects, including our
high tech holiday decorations, some of our
coolest pumpkins, our (digital)
Larson Scanner, and some
wacky papercraft— to name a few. It’s one of those few chips that we used often enough to justify a custom
breakout board.
But… if there’s one thing that the ‘2313 is short on, it’s memory. With 2 kB of flash (program) memory and 128
bytes of RAM, it’s perfect for tiny single-purpose projects. But, it’s oh-so-easy to run up against that memory limit. And, that’s why we were so excited when Atmel began to announce their then-forthcoming ATtiny4313 in late 2009.
Unfortunately, it’s often a long delay between when a chip is announced and when it’s actually available through distribution. Sample quantities have been floating around for half a year or so, but– and
finally— a big box showed up in the mail, and so here they are.
Now, programming it. There are very few changes between the ‘2313 and ‘4313. Mainly, it’s what you’d expect: memory sizes (Flash, SRAM, EEPROM are all doubled), and the device signature is different.
Recent versions of AVR-GCC already support the ‘4313, and so it’s relatively straightforward to recompile an existing program (say, the Larson scanner firmware) to run on the ‘4313. There
are some minor inconsistencies between the “io.h” header files for the two chips, and those inconsistencies can cause compiling to fail. For example, the register name “WDTCSR” (for watchdog control register) works on the ‘2313, but the ‘4313 io.h file lists that same register name as “WDTCR.” So, if you run into a place where AVR-GCC is confused after switching chips, you might be able to solve the issue by comparing that register name in the “io.h” files for the two chips.
Now, for programming the chip with avrdude, things are slightly more complicated. Avrdude does not yet natively support the ‘4313, but fortunately, you can add the new chip definition by editing the avrdude.conf file on your system. (On my Mac, where I use
Crosspack as the AVR toolchain, I found that file at /usr/local/CrossPack-AVR/etc/avrdude.conf ) The ‘4313 code block can be added right below the ‘2313 code block, and you can download that code block
here (
via this mailing list post). So, a couple of steps, but works like a charm.
There aren’t a whole lot of these to go around right now, but we’ve put some of our ‘4313 chips into little dev kits that you can pick up
at our store. Let’s see how long they last. ;)