A while back, I posted up a quick and dirty âel cheapoâ method of getting started programming the Atmel AVR series chips: Ghetto Programmer (version 1.0)
Since then, Iâve vamped, re-vamped, and otherwise improved my setup. Thought itâd be nice to document it.
The goal was to get a flexible, compact, portable, use-anywhere, AVR-based microcontroller prototyping environment. On the cheap(ish).
So without further ado, hereâs the Ghetto Development Environment (GDE) (version 1.2).
Step 1: The Kit
The basic kit contains the following stuffs:
USB programmer. Because you want to be able to program microcontrollers from your laptop anywhere. And because USB is a very handy source of +5v.
Programming cradles. One for each kind of chip youâre playing with. For me, that means one with 8 pins (ATtiny13, 15), one with 20 pins (ATtiny 2313), and one with 28 pins (ATmega8).
Blinkenlights. When somethingâs wrong with your code, nothing clears it up like sticking lights in to diagnose. Plus, the LED blinker program is the âHello Worldâ of microcontrollers.
Breadboard. Itâs a development kit, after all.
Step 2: The USB Programmer
In Ghetto Programmer (v.1.0) I used a parallel port programmer. Itâs great because itâs simple and cheap and fast. But my laptop doesnât have a parallel port.
I played around with making serial port programmers for a bit, but honestly theyâre just as complicated as the USB version and even serial ports are becoming scarce.
Indeed, my laptopâs only really got USB. So USB it is. Looking around, the USBTiny programmer is pretty simple and works with the free GNU/AVR-GCC tools.
Do it yourself or buy a kit?
The DIY way is good if you can already program an ATTiny2313 (with parallel programmer) and have a 12MHz crystal sitting around. USBTiny Page lays out the basics.
He terminates the programming cable with a parallel port, but Iâd finish it up in a standard 6-pin header if I were starting afresh. (Why? Because itâs standard.) Here are his pin-outs, and check the image below for the cable layout.
PD3 â MISO
PD5 â Reset
PD6 â SCK
PD7 â MOSI
If you make your own, please learn from my experience and put it into a nice plastic box. If you donât, itâll fail eventually when the 12MHz crystal breaks off. Which is why I now useâŚ
The quick-and-elegant way is Ladyadaâs USBtinyISP kit. Itâll set you back $22, but you get a nice PCB, pre-programmed ATTiny2313, and a clean box with nice cables. Raw parts are like $15-16 anyway, and you donât have to call up Digikey and then worry about programming up your own 2313. Takes 30 min â 1 hr to solder it all together.
Splurge. Trust me.
(No affiliation, satisfied customer)
And just saw this link: Ladyadaâs AVR Tutorial which seems pretty good to me.
(And do note that Ladyadaâs design and the original USBTiny use different USB product identifier codes â youâll have to find the ID strings and re-compile avrGCC if youâre switching between the two. I think thereâs instructions on the respective webpages.)
In case youâre on a Ubuntu Linux system and using the USBTiny programmer, hereâs the commands thatâll get the whole toolchain up and running:
sudo apt-get install build-essential avr-libc binutils-avr gcc-avr avrdude
(tested on Hardy Heron)
If you have an AMD64 arch, you may also need: byacc libusb-dev flex bison libc6-dev
and then to compile AVRdude by hand:
(
wget http://download.savannah.gnu.org/releases/avrdude/avrdude-5.5.tar.gz
tar xvzf avrdude-5.5.tar.gz
cd avrdude-5.5
## Patch needed for AMD64:
wget http://savannah.nongnu.org/patch/download.php?file_id=14754
patch -p1 < avrdude-5.5.usbtiny.64bit.patch
./configure
make && make install
sudo avrdude -p attiny2313 -c usbtiny ## to test
)
If you see something like âavrdude: AVR device initialized and ready to accept instructionsâ then youâre done.
For more details, click: Ghetto Development Environment Using Microcontrollers