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!

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.


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.

<p>Atmegas and attinys are microcontrollers, not microprocessors.</p><p>Microcontrollers contain things needed for basic operation, like adc and memory.</p><p>Microprocessors only have the bare bones: the CPU and stuff.</p>
can you please put a schmatic
I _could_. But then you'd only know how to hook up one particular chip out of the whole AVR family. What you really need to know is that the pin on the programmer labelled MOSI connects to the pin on the chip labelled MOSI, etc. And then that works for _every_ chip. <br> <br>But I'll see if I can whip up something helpful and graphic. <br> <br> <br> <br> <br> <br> <br>
Can you please post a makefile for mac?<br>
seeing thoughs LED's with resistors soldered to them I was just thinking wouldn't it be lovely if they were sold like that (:<br>An LED with presoldered 1K resistor... or even a resistor built in to the LED it's self... extra just an idea
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 :)
Maybe a kind of zena LED might be a more useful idea.<br>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. <br>
Thank you. Abit confusing here.<br>In the picture above, you shown PIN1= Reset.<br>In the listing, PIN1= SCK. PIN11 = Reset.<br>
avrdude: verifying ...<br /> avrdude: verification error, first mismatch at byte 0x0000<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x12 != 0x00<br /> avrdude: verification error; content mismatch<br /> <br /> avrdude done.&nbsp; Thank you.<br /> <br /> has anyone else had this problem?<br /> <br />
See the registry update I posted in the comments...
Thanks for the help, but I am now using a USB programmer. I haven't had any problems yet
I should make up an Instructable on what all the errors mean...<br /> <br /> Verification errors mean that the chip didn't get the data right.&nbsp; Check for loose connections here or there.<br /> <br /> Also double-check the power supply that you're using for the chip.&nbsp; The chips draw power in a spikey, unpredictable way, and that sometimes can cause trouble.&nbsp; A simple solution that often works for me is to put a buffer capacitor across the AVR's power pins.&nbsp; That is, take a capacitor of moderate size (0.1uF to 10uF?)&nbsp;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.<br /> <br /> The capacitor acts as a little rechargeable battery, smoothing out the AVR's power demands.&nbsp; <br /> <br /> (Real engineers almost always start out with a buffer capacitor in their designs for reliability.&nbsp; I omitted one here b/c I'm cheap and I can usually get away with it.&nbsp; But you should try adding it if things go wrong.)<br /> <br />
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?<br />
i tried adding the capacitor and i am still getting the same error, and all the connections are good<br />
&nbsp;Erase the chip before programming... Should do it.
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.<br><br>[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Parport\Parameters]<br>&quot;DisableWarmPoll&quot;=dword:00000001 <br><br>Paste the above into Notepad and saveas dapa.reg<br>then right click MERGE intos registy. Will save you lots of problems with using parallel ports under windows with AVRDUDE for instance.
please define your pin outs in the pictures and define better in board thks <br>
How do you mean &quot;better&quot;? Is there something specific I can write that'd help?<br>
Just label all the out puts on all the pictures
can you tell how did you connect it to the 8 pin socket<br>
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.<br><br>thanks<br>Joseph
would you happen to have a schematic of parallel port pins to microcontroller? i find your current explanation a it confusing.
um looking for elevator avr program. Do you have example program ?
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!
What does this mean? <br> <br>&quot;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&rsquo;t have. But if you&rsquo;ve got an old PC around that has one this will get you up and programming in no time. <br> <br>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&rsquo;s clock at full speed (by changing fuse settings&hellip; more in Part 3) you won&rsquo;t be able to use a DAPA cable to talk to it any longer. There&rsquo;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&rsquo;s how I built mine&quot; <br> <br>I got this info from here: http://hackaday.com/2010/10/25/avr-programming-02-the-hardware/ <br>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?
i head you can burn a bootup code on an ATmega and use it as a standalone arduino
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.<br> <br> 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.<br> <br> The Tiny2313 does bootload, but you'll want to use a small bootloader like this one: <a href="http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_type=project&item_id=625">http://www.avrfreaks.net/index.php?module=Freaks%20Academy&amp;func=viewItem&amp;item_type=project&amp;item_id=625</a><br>
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 <a href="http://www.seekic.com">IC components</a> can be find on <a href="http://www.chinaicmart.com">ChinaICMart</a>. <br>
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?
&nbsp;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<br /> <br />
is this parralell connector work for picaxe to connect it with pc
HI!<br /> <br /> I think I just 'fried' 2 attiny2313 :(<br /> <br /> 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...<br /> <br /> What could have 'fried' my AVR????<br />
It's pretty hard to fry them.&nbsp; I&nbsp;bet the chip is fine. <br /> <br /> 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.&nbsp; Something else is going on...<br /> <br /> Double-check your wiring?&nbsp; Do you have all the programming lines going to the right places?&nbsp;&nbsp;<br /> <br /> Another possibility is that you've got flakey power supplied to the chip.&nbsp; The solution is to buffer the power supply.&nbsp; That is, place a 1uF - 10uF capacitor across the positcheap trickive and negative power rails, or even better across the Tiny's VCC&nbsp;and GND&nbsp;pins.&nbsp; This will smooth out voltage spikes in the power line that might be accidentally resetting your chip.<br /> <br />
thnks for detail description but I hav to interface it wid&nbsp; PIC18F4550.<br /> Can u please fwd ckt dig+c/hex file on suyog.mahajan14@gmail.com?<br />
thanks for this Instructable, haven't done all of it but it was a great help making my own cradle :)<br /> <br /> @<a class="entryListTitle" href="../../../member/brooklynlord/" rel="nofollow" style="line-height: 16.0px;padding-right: 4.0px;padding-left: 0.0px;">brooklynlord<br /> </a>while programming getting 5V from the USB-Port is the most direct approach so I think you are talking about the running project.<br /> 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.<br />
&nbsp;sorry to specify in banglore ,india where can i find these components
Can you use 4.5V instead of 5V?
Btw, you can use a resistor to shrink the batter voltage from anything thats higher than 5vs to 5v.<br /> <br /> Just a reminder, as i was looking everywhere for 2v batteries :)
You can get the parallel port connector from The Shack :<br /> <br /> http://www.radioshack.com/product/index.jsp?productId=2103239<br /> <br /> You can clearly see the pin numbers on the connector.<br /> <br /> Will be trying this out and ill report back with some pictures =)<br />
or from an old printer cable (who doesn't have 20 of them lying around)<br />
Just in case that one person is running USB and never got a taste for a parallel connector.<br />
So I've run into a problem getting the code to upload to the chip, and I see that at least five other people have had the same problem-<br /> they get an error message that says something like <br /> <br /> &gt; &quot;make.exe&quot; all<br /> make.exe: *** No rule to make target `all'. Stop.<br /> <br /> &gt; Process Exit Code: 2<br /> <br /> but it wasn't exactly like that... i think it had &quot;LED_Demo.c&quot; in place of &quot;all&quot; or &quot;make.exe&quot;<br /> well, whatever it was, it seemed like the computer wasn't registering the chip, even though it was plugged in and supplied with 5v... and I swear I wired this thing up just like you said to.<br /> <br /> so i saw some comments later on that said that there was something wrong with the makefile and that I should find and match LPT output addresses with the code... but I don't really know what that means, and I saw a link to an AVRfreaks forum entry where someone uploaded a new makefile, but the link to that makefile is now defunct... <br /> what should I do now? can someone supply a new makefile?<br />
also, I don't know where this avrdude stuff is coming from... the WinAVR that I downloaded came with programmer's notepad and it doesn't say anything about AVRs... is this a problem?<br />
can i use it for atmega8535 ?&nbsp;
wow.. i love micro controllers.. they have almost endless possibilities!<br />
To squeeze the form factor down, I tried using a wire wrap socket. It worked out well!<br /> <br /> http://www.flickr.com/photos/hillwalker/4086680979<br /> <br /> <br />
That's hot!&nbsp;&nbsp;&nbsp;And I love your demo of the two carriers.&nbsp; Great stuff!<br />
Oh boy! I found the ATtiny2313 for $1.55 =D&nbsp;
hi<br /> <br /> Thanks a lot for this Tutorial.<br /> Well, I have a little problem. So i dont understand wich Pins from the ppc are coming to the Attiny. <br /> <br /> Which PPC&nbsp;Pin is coming to the Miso?&nbsp;I think its the Pin 11 but i m not shure. When Miso is 11, Mosi is 2 form the ppc?<br /> The green cable, thats the first pin form the ppc an the 19th from the Tiny?<br /> <br /> Pin 1 from the Tiny, the Reset, which one frome the ppc is that?&nbsp;An the GND???<br /> <br /> And which pins are the + and the - frome the 5 Volt Batterie?<br /> <br /> <br />

About This Instructable




More by The Real Elliot:Clean and Grease your Skateboard Bearings Quickie PCB Production (with Bonus NiCd Battery Charger) Stop using Ferric Chloride etchant!  (A better etching solution.) 
Add instructable to: