Ghetto Programming: Getting started with AVR microprocessors on the cheap. by The Real Elliot
Featured

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.

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 http://www.instructibles.com/id/EDRQZ56F5LD8KDX/ out.

If you've got a parallel port, or are just feeling cheap, read on!


 
Remove these adsRemove these ads by Signing Up

Step 1: 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.

Add-ons

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.

1-40 of 367Next »
s00500 says: Dec 4, 2011. 3:37 AM
Can you please post a makefile for mac?
crjeea says: Oct 1, 2011. 4:00 AM
seeing thoughs LED's with resistors soldered to them I was just thinking wouldn't it be lovely if they were sold like that (:
An LED with presoldered 1K resistor... or even a resistor built in to the LED it's self... extra just an idea
Eirinn says: Oct 22, 2011. 2:20 PM
Well... depending on the voltage you supply to the LED you'll need different resistors. That's why they don't come integrated with a resistor :)
crjeea says: Feb 20, 2013. 8:56 PM
Maybe a kind of zena LED might be a more useful idea.
I have seen LED's that can flash, think I would also like to see LED's that have pwm built in based on voltage so they can be dimmed with only two pins. Or maybe tri colour LED's that cycle through thier colours according to voltage.
kbchiew says: Aug 17, 2011. 11:12 PM
Thank you. Abit confusing here.
In the picture above, you shown PIN1= Reset.
In the listing, PIN1= SCK. PIN11 = Reset.
twenglish1 says: Nov 26, 2009. 7:53 PM
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x12 != 0x00
avrdude: verification error; content mismatch

avrdude done.  Thank you.

has anyone else had this problem?

tester272001 says: Jul 22, 2011. 8:27 PM
See the registry update I posted in the comments...
twenglish1 says: Jul 22, 2011. 10:27 PM
Thanks for the help, but I am now using a USB programmer. I haven't had any problems yet
The Real Elliot (author) says: Dec 4, 2009. 12:06 PM
I should make up an Instructable on what all the errors mean...

Verification errors mean that the chip didn't get the data right.  Check for loose connections here or there.

Also double-check the power supply that you're using for the chip.  The chips draw power in a spikey, unpredictable way, and that sometimes can cause trouble.  A simple solution that often works for me is to put a buffer capacitor across the AVR's power pins.  That is, take a capacitor of moderate size (0.1uF to 10uF?) and connect the positive end of the cap to the AVR's VCC pin and the negative end of the cap to the AVR's GND pin.

The capacitor acts as a little rechargeable battery, smoothing out the AVR's power demands. 

(Real engineers almost always start out with a buffer capacitor in their designs for reliability.  I omitted one here b/c I'm cheap and I can usually get away with it.  But you should try adding it if things go wrong.)

twenglish1 says: Dec 5, 2009. 12:00 PM
thanks, i will try that, but its weird the power supply i am using was working fine before? any idea why all of a sudden?
twenglish1 says: Dec 5, 2009. 1:18 PM
i tried adding the capacitor and i am still getting the same error, and all the connections are good
pcairic says: Dec 13, 2009. 4:47 PM
 Erase the chip before programming... Should do it.
tester272001 says: Jul 22, 2011. 8:26 PM
If you use the parallel programmer under Windows XP be sure to use the below registry hack to prevent windows from interruping your programming signals.

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Parport\Parameters]
"DisableWarmPoll"=dword:00000001

Paste the above into Notepad and saveas dapa.reg
then right click MERGE intos registy. Will save you lots of problems with using parallel ports under windows with AVRDUDE for instance.
fostersfriend says: Jun 30, 2011. 2:32 PM
please define your pin outs in the pictures and define better in board thks
The Real Elliot (author) says: Jun 30, 2011. 6:16 PM
How do you mean "better"? Is there something specific I can write that'd help?
fostersfriend says: Jul 1, 2011. 4:42 PM
Just label all the out puts on all the pictures
robot1398 says: Jun 17, 2011. 2:21 AM
can you tell how did you connect it to the 8 pin socket
jld1 says: Jun 11, 2011. 3:07 PM
I've downloaded the WinAVR just to try to play with C/C++. I don't have any uC right now but I plan to. I wrote a simple program using Programer's Notepad in C. I can't seem to compile the program? Please advise.

thanks
Joseph
matstermind says: May 12, 2011. 7:06 PM
would you happen to have a schematic of parallel port pins to microcontroller? i find your current explanation a it confusing.
shanakaplus says: Apr 7, 2011. 9:08 AM
um looking for elevator avr program. Do you have example program ?
lpciprian says: Nov 29, 2010. 6:04 PM
OMG, I tried to make this for two weeks. I finally did it! I must say that my first mistake was that I didn't use an external source for Vcc. Second: I used a too long paraller cable. After I used a power source from one of my USB's and cutting my dapa cable to about 18 cm long (it was about 1,2 meters) I finally got a succesfull firmware flashing on my attiny2313...whew! Thank you The Real Elliot for your instructable!
bonecrusher848 says: Nov 17, 2010. 3:06 PM
What does this mean?

"A Direct AVR Parallel Access, or DAPA cable, is an incredibly simple and cheap programming method. You can build one very quickly for a few bucks worth of parts, but the convenience comes with a few gotchas. The first is that you must have a parallel port on your computer; something that modern laptop and some modern desktops don’t have. But if you’ve got an old PC around that has one this will get you up and programming in no time.

In fact, the first AVR prototyping I did was with one of these cables. That is, until I discovered another gotcha. This will only program low-speed chips. If you try to run the chip’s clock at full speed (by changing fuse settings… more in Part 3) you won’t be able to use a DAPA cable to talk to it any longer. There’s also the possibility of damaging your parallel port or worse if you do something wrong. But if you want to go for it anyway, here’s how I built mine"

I got this info from here: http://hackaday.com/2010/10/25/avr-programming-02-the-hardware/
Does this mean that if i modify the speed of the internal oscillator at the first programming, the programmer won't program the chip anymore?
beehard44 says: Oct 25, 2010. 6:47 AM
i head you can burn a bootup code on an ATmega and use it as a standalone arduino
The Real Elliot (author) says: Oct 28, 2010. 10:51 AM
Very true. An Arduino is really just an AVR with some of the pins dedicated and a bootloader and some timing routines pre-configured for you in the firmware.

Only some of the AVR chips have bootloader capability, though, so you should check the datasheet to make sure. I know the Mega88 does, for instance, but the M48 doesn't.

The Tiny2313 does bootload, but you'll want to use a small bootloader like this one: http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_type=project&item_id=625
aboutyxm2005 says: Oct 8, 2010. 6:41 PM
It's pretty hard to fry them. I bet the chip is fine. Anyway, I learnt much from your essay. And I think that some IC components can be find on ChinaICMart.
Funnymonk says: Aug 17, 2010. 1:18 AM
Hello I think I've followed all of your instructions to the letter but there is no Make prgram button in tools for me. How do I fix this?
bha123 says: Mar 10, 2010. 10:20 PM
 guys where can i find these micro controller and ics actually i am IT student but for my project i need them can any body suggest where can i get them

Simpson_jr says: Jun 20, 2010. 7:53 AM
Ebay...
usman_the_great says: Jun 14, 2010. 11:51 AM
is this parralell connector work for picaxe to connect it with pc
cdousley says: Apr 30, 2010. 8:01 PM
will this program attiny13
The Real Elliot (author) says: May 12, 2010. 7:58 AM
Yup.  You just need to hook up the six programming lines to the right pins.  See the datasheet for where to route them.

www.atmel.com/dyn/resources/prod_documents/2535s.pdf

cdousley says: May 12, 2010. 2:33 PM
Thanks for the help all i need now is the ic socket
elbriga says: May 5, 2010. 6:54 PM
HI!

I think I just 'fried' 2 attiny2313 :(

The only thing not quite equal from your instructable is that my led has the resistor (330r) on the + pin of the led, so i connected the ground pin of the led to ground and the other + resistor to PD4, then the avrdude stoped working, not recognizing the chip anymore...

What could have 'fried' my AVR????
The Real Elliot (author) says: May 12, 2010. 7:55 AM
It's pretty hard to fry them.  I bet the chip is fine.

Generally, it shouldn't matter whether the resistor is on the + or - side of the LED -- it limits the total current flow just fine in either location.  Something else is going on...

Double-check your wiring?  Do you have all the programming lines going to the right places?  

Another possibility is that you've got flakey power supplied to the chip.  The solution is to buffer the power supply.  That is, place a 1uF - 10uF capacitor across the positcheap trickive and negative power rails, or even better across the Tiny's VCC and GND pins.  This will smooth out voltage spikes in the power line that might be accidentally resetting your chip.

suyog14 says: May 4, 2010. 6:12 AM
thnks for detail description but I hav to interface it wid  PIC18F4550.
Can u please fwd ckt dig+c/hex file on suyog.mahajan14@gmail.com?
Yakumo says: Apr 12, 2010. 1:12 PM
thanks for this Instructable, haven't done all of it but it was a great help making my own cradle :)

@brooklynlord
while programming getting 5V from the USB-Port is the most direct approach so I think you are talking about the running project.
well i only used atmega 168 till now but I think other chips work pretty much the same. You can power the chip with lower than 5V the only disadvantage is you can't run it at the same speed (less MHz). look at the datasheet of your processor.
bha123 says: Mar 10, 2010. 10:22 PM
 sorry to specify in banglore ,india where can i find these components
cdousley says: Mar 23, 2010. 6:50 AM
allelectronics.com
ebay
cdousley says: Mar 21, 2010. 1:12 PM
could i use this for an attiny 13
brooklynlord says: Feb 19, 2010. 8:22 PM
Can you use 4.5V instead of 5V?
1-40 of 367Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!