Ghetto Programming: Getting started with AVR microprocessors on the cheap.

Microprocessors are so cheap these days. If only there were a way to program them up just as cheaply…
*wavy dream-sequence lines*
In this instructable, find out how to build up a complete AVR microprocessor toolchain: compiler, programmer software, programmer hardware, and some simple demos to get your feet wet.
AVR microprocessors
From there, it’s just a hop, skip, and a jump to world domination.
The endpoint is not quite as swanky as Atmel’s suite, but it’s gonna run you about $150 less and take only a little more work to get it set up.
This instructable is based on the Atmel ATtiny 2313 chip, mostly because it’s one of the smaller chips (in size) while still being beefy enough to do most anything. And at $3 a pop (non-bulk), they don’t break the bank.
That said, most of the steps are applicable across the AVR family, so you’ll be able to re-use most everything when your programming needs outgrow the ATtiny and you reach for the $8-$12 ATmegas.
Update Aug 24, 2007: I’ve gone USB! It’s neither ghetto nor particularly deluxe, but a nice middle ground. If you’ve got a computer without a parallel port, check this out.
If you’ve got a parallel port, or are just feeling cheap, read on!

Go Order Parts!

Necessary Parts List (stuff to buy or scrounge):

Atmel ATtiny2313 chip:       $2.50 - $3Socket for chip:
$1Parallel port connector (DB25):$3
at Radio Shack or $0.95 at SparkfunHeader Pins:$1-$2
(at least one strip each male & female, maybe 2 female)
Some LEDs and resistors:     $1

= Around $10, even if you go deluxe. Half that if you can find an old parallel port cable.
A pushbutton switch or two: $1.
A piezo speaker: $1-$5
Light sensitive photocells: $2-$6
Breadboard for making complex circuits: $8-$10(?)
Other Stuff You Oughta Have
Computer: The older the better because it needs a parallel port.
Hookup wire, solder, soldering iron
Super-duper glue
Source of ~5v DC: Batteries will work, and old computer power supplies are perfect.
I get a lot of stuff from Sparkfun because they’re
fast, reliable, and fairly priced. They carry AVR chips (but seem to be out
of ATtiny13’s at the moment). They’ve got everything on the “Necessary”
list in one place, nice website.
If you’re gonna be ordering a lot of chips, you can get a deal from Digi-key or similar. For instance: ATtiny 2313 for $2.36 each. They’ve only got 27,853 more in stock, so order quick. (Make sure you get the DIP form-factor.)
Go order stuff now, and we can set up the software side while you wait.
The waiting is the hardest part.

Get and Install Software: Linux Version

If you run Windows, skip this page. Or install Linux, then come back. 🙂
The Linux AVR software toolchain used is:
1) an editor of your choice (emacs, gedit, kate, etc)
2) AVR-GCC compiler and libraries
3) AVRdude programmer
4) A nice Makefile to tie it all together
May 2008 Edit: Ubuntu has packages for the whole toolchain. Your installation is now as easy as: “sudo apt-get install avrdude avr-libc binutils-avr gcc-avr”. Bam! The versions that come with 8.04 are good all around. Woot Ubuntu!
If you want to do it “by hand”, the script below automates most of the work for you. Note that as of May 2008, it’s a year old, and doesn’t support the newer ATTinyx5 series chips. You can mess around with updated versions of all the software is you’d like. (It’s saved with a .txt extension b/c Instructables wants it. Doesn’t matter.)
You’re going to have to edit the first command in the install script depending on whether you’re using an apt-based package system or a yum-based one. Just uncomment the relevant line. It needs to make sure you’ve got some packages which are required for the compilation stage.
Have a read through the script to make sure it’s not doing anything stupid, then get root and run it and you should be golden.
It will create a directory /usr/local/AVR and install all the AVR tools there.
The last thing the script does is to add avr-gcc to your path so that you can run avr-gcc directly by adding a line to the tail of your /etc/profile.
The other file, setupParport.txt, is just a (very) simple script to set up your parallel port for user use. If you’re savvy, you can add the same commands to a boot script so that it enables the parallel port every time you boot up. Otherwise, just run it by hand.
Websites with similar, but different and possibly outdated, procedures include:, AVRWiki, and this (old) Linux Focus article.
Alternatively, I hear cdk4AVR has a complete set of compiler tools in RPM format. I haven’t tried it, but it could save you the 30 min of compiling time on a slow, old laptop.

Get and Install Software: Windows Version

The MS Windows software toolchain is based on the same compiler as Linux one, but with some optional extra GUI friendliness.
WinAVR is the compiler and programmer software. It also includes a nice programming editor, Programmer’s Notepad.
Download and install it. It’s that easy. Almost.
As the last step in setup, you’ll need to make the parallel port user-accessible. WinAVR includes a program for you to do this. If you accepted the default installation options, run C:\winAVR\bin\install_giveio.bat by double-clicking on it. A window will flash up and down, and then you’re done.

Make Programmer Cable

The cable you’re going to make is a “Direct AVR Parallel Access” or DAPA cable.I think I got the pinouts from somewhere else, but has a nice schematic of the parallel port pins for your reference.Mine goes something like this:

Parallel Port  	 AVR Function  Color2
MOSI          Orange/Grey11
MISO          Orange1
SCK           Green16
RESET         Brown18
GND           Brown/Grey

Only tricky bit here: Note that pin 1 (SCK) is on the upper-right hand side when you are looking at the solder pins from the back. It’s upper-left when you’re looking at it here, and in the circuit diagram.
Also, the guy’s website above has ground connected to 20 and 21 while mine (and others) use 18. Many of the pins connect to ground, and it doesn’t matter which of them you pick, as long as you get ground.
If you look around the web, you’ll find that most people put resistors in either the cable or the cradle (next step) to protect their computer’s parallel port from excessive voltages on the AVR chip for use when programming it in-circuit. We will be using strictly 5v here, so there’s no such worry, and I leave them out for simplicity.
However, if your chip ever comes near >5v, DO NOT USE THIS CABLE WITHOUT RESISTORS! A computer with a burnt-out parallel port is no fun. That said, I’ve been using it without incident for 6 months now.

Make the programming cradle

Now use the 20-pin socket and female headers to make a cradle which connects the pins from the cable to the right pins on the chip.
The first thing to do is superglue all the headers and the socket to the circuit board. That way, it’s easier to solder to. You can even make an extension for the header like I did if you need more room on your circuit board.
For more Detail: Ghetto Programming: Getting started with AVR microprocessors on the cheap.

About The Author

Scroll to Top