You are on page 1of 21

Page 1 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics

25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
Counting from the dimple, pin 1 is on the left and increases down the left side of the IC. The pin numbers jump to the right side
row of pins and count up. See image from the ATmega328 datasheet below.
The ATmega328 should be in the breadboard, pin 7 (VCC) and pin 20 (AVCC) should be connected to your 5V rail and pins 8 and
22 (GND) should be connected to GND on your bread board. If you turn your power circuit on, the ATmega328 is now running,
but it has nothing to run!
Actually this is not wholly true - there is one more connection that needs to be made before the ATmega328 starts running code.
The RESET pin on the ATmega328 needs to be connected to VCC. You can either wire the RESET pin directly to 5V or you can
'tie it high' by connecting the RESET pin to VCC through a resistor. This will allow you to add a momentary reset button. What's
this? The reset line on the ATmega328 is exactly what it sounds like - it resets the micro just like the reset
computer. If you look at the ATmega328 datasheet you'll see the RESET label is written with a line above it. This is
that indicates the reset pin is active low. What is 'active low'? The RESET pin is an input. A low level on this pin will put the
into reset - i.e. the pin is activated with a low input, aka 'active low'. So unless you want your ATmega328 to stay in reset, you'll
need to pull this pin high.
Now you need a reset button. A momentary switch is a switch that is activated (or closed) while you're touching it and open when
you release the button. These are often called 'tactile switches' because they 'click' when you depress them giving the person
pressing the button some 'tactile' feedback.
This is what the schematic part looks like. Notice pins 1 and 2 are connected together. 3 and 4 are connected together. And when
you press 'de button, it temporarily connects 1/2+3/4 together.
Notice this button has five legs. If your button has five legs, just ignore the middle leg - it's not connected to anything and can be
clipped off.
To test this button, whip out the trusty multimeter and set it to the continuity setting. This is the setting on nicer, mid
multimeters that is crucial to troubleshooting and experimenting. Touch the probes together - you should hear a tone indicating that
there is continuity or a (nearly) zero resistance path between the probes. Insert the button into the breadboard and probe the two
pins on one side of the button. If you picked pins 1/2 or 3/4 you should hear a tone. These pins are permanently connected inside
switch. If you picked pins 1/3 or 2/4, you won't hear a noise - but hit the button. By hitting the button you will
connection between all four pins - and you should hear the tone! This means you have electrical continuity.
Page 2 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
The schematic shows pins 1 and 2 of the reset switch connected together (connected to ground) and pins 3/4 connected together
(connected to !RESET) . In practice, you just need the switch to work. Play with your multimeter and find two pins that don't make
noise when the button is not touched, and do make noise when the button is depressed. Use these two pins.
The schematic shown above is what we're going for. The 10K resistor 'pulls' the reset pin high during normal activity. By pulling
the reset pin high, the ATmega328 runs normally. When you push the reset switch (S2), the reset pin sees a continuous connection
to ground. Since the resistance through the depressed switch is nearly zero, it wins (compared to the resistance of the 10K resistor!)
and the reset pin is pulled low, RESET is activated and the ATmega328 goes into reset. Release the button and the reset pin is
pulled high again and the ATmega328 comes out of reset. Nifty!
ATmega328 pinout
See the dimple from the ATmega328 datasheet? Looking at the top of the IC (legs down), with the dimple to the top, pin numbers
increase starting from 1 in the top left corner. This is how every IC pin is number. However, the orientation marking varies a bit
between manufacturers and between packaging types. Look for a non-congruent marking like a dimple, small dot, white arrow, a
notched corner - anything that makes that area of the chip different from the other parts of the chip probably indicates pin 1. When
in doubt, check the datasheet.
Page 3 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
Reset wired next to a ATmega8 (same applies for the ATmega168, and ATmega328)
Learn how to use the the continuity setting on your multimeter. It will be vital to troubleshooting down the road!
Each microcontroller manufacturer has a different method to get code in the flash memory of the micro. In the past few years there
has been emphasis placed on ISP or "in system programming". ISP allows you to program the IC without having to disconnect the
microcontroller from the application. This is not trivial! History was much more painful. Atmel has designed a relatively straight
forward method that requires the control of a few pins (6 total). Because of this simple interface, the hardware programmer that is
required to connect your computer to this ISP interface is very straight forward (cheap!) as well.
The red stripe indicates the location of Pin 1
Remember how we identified pin1 on the IC from the dimple? Well connectors also need polarization so that we don't reverse the
orientation of the connector and fry things. Unfortunately the way connectors are numbered is opposite that of ICs. In the picture of
the ISP connector, you see the red stripe indicating pin 1. An IC counts sequentially down one side. Connectors on the other hand,
increase pin numbers, back and forth, as you work your way down the connector.
The programming chain looks something like this:
1. There is a free C compiler called AVR-GCC. User writes code in C and then compiles that code into HEX files
2. AVR-GCC can be installed on the Windows platform with an easy WinAVR install program
3. The user gets this HEX code onto an AVR via the ISP pins
4. Both a serial port programmer and a parallel port programmere have been designed to connect the computer port to the AVR
ISP pins
5. The computer runs a command line program to transfer the HEX file from the computer, to the serial or parallel port, and out
Page 4 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
to the AVR ISP pins
6. The micro runs the machine code (*.HEX files) once powered or reset
What's a C compiler? This is a program that inputs a program written in the C language and outputs a HEX file. We prefer to
program in C because it is easier for us than assembly and more flexible than BASIC.
What's a HEX file? This is a file that contains various hexidecimal characters. These hex 'codes' represent machine instructions that
the ATmega328 understand. This file is what gets sent down to the programmer, and the programmer loads these machine
instructions onto the ATmega328.
Before we can get too crazy, download and install WinAVR on the computer that you will be doing your code development on. If
this link goes out of date, a google search should take you straight to it. The windows install should be fairly straight forward -
follow all the defaults. WinAVR contains a version of the GCC compiler and various other tools including avrdude and
Programmer's Notepad. avrdude is a simple command line program that takes a HEX file and sends it to the serial or parallel port
for programming onto an Atmel microcontroller.
Working backwards up this list, I'll provide you with an example 'Hello World' HEX file that will prove that everything is working
correctly on your micro. With any micro controller board, the first trick is always to get an LED to blink. This is the 'Hello World'
of embedded systems. Guess what blink_1MHz.hex does?
With the blink hex file in hand, you now need to get it onto the micro. You will need to connect the AVR-PG1 (or the AVR-PG2)
to the ATmega328. The easiest way to do this is with 9 wires running from your breadboard to the 10-pin connector on the ISP
connector on the AVR-PG1/PG2.
Jamming wires into the ISP connector is not a good long-term solution but for the sake of getting the LED to blink, it'll do. I've cut
short wires and stripped both ends. One stripped end is inserted into the end of the black programming connector, the other end is
inserted into the breadboard.
Page 5 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
The AVR-PG2 parallel programmer wired into the ATmega328. I've also wired up two 0.1uF caps. These decoupling caps are
placed near the VCC and GND pins on the ATmega328 to help reduce noise into the IC. You may think you have a straight DC 5V
but not really - these 0.1uF caps help reduce ripple on the 5V line. Yes, the ATmega328 will probably run without them but they're
good to have installed.
AVR ISP Note: You really do have to wire all 4 GND pins. You cannot wire just one of the GND pins on the ISP connector.
Additionally we need an LED to control. This can be tied to any GPIO pin. PC0 looks like a good spot.
The resistor/LED order does not matter - just remember (from Tutorial 1) that you must have the resistor! The GPIO pin doesn't
actually matter. blink_1MHz.hex will toggle all the pins on all ports so you can hook the resistor to any pin. As you add more
peripheral hardware you will want to dedicate some pins for alternate use (such as TX and RX pins for serial communication).
You're getting closer! Time to program the chip!
Once WinAVR is installed, you should have a few new icons on your desktop. Programmers Notepad is a nice code editor and
highlighter.
What's a code editor/highlighter? When programming, you will need a text editor on your computer so that you can create (type)
code. Once you've created this 'code' on your computer (inside the code editor) you will pass this code to the compiler (you will
click a button that runs the compiler with the C file you've typed) and the compiler will create a HEX file (assuming there are no
problems or typos in your code). The highlighter? When creating code, it's often nice to have various parts of your program color
coded so that you can tell a common things like for( ) and #define. This highlighting helps a lot when programming.
Use whichever text tool you like. Notepad will work, but is pretty rudimentary. I also like JFE from my PIC days. Both have a
Page 6 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
'tools' option which is great but JFE is better in my opinion because it lists the C functions that you can double click on and
navigate to. If there is a way to do a similar trick in Programmer's Notepad 2, please let me know! Because Programmers Notepad
v2 (aka PN2) comes with the WinAVR installation, we'll use it!
AVR-GCC is extremely powerful, very complex, and difficult to use initially. I am used to passing a *.c file to a PIC compiler
(CC5x) and getting a HEX file back out. No fuss, no mess. Believe you me, the pain of getting AVR-GCC up and running is worth
it. AVR-GCC is a truly nice compiler, and its free. I've included a stock Makefile and blink1MHz.c file in blink_1MHz.zip to get
you started. I am by no means a Linux or make type of person. All you need to know is that when you type 'make' at the command
prompt, the compiler is going to look for a file called 'Makefile' (no file extension!) and use that file to direct how to compile your
C file.
These are the only two files you should need to get blink to compile. Open up blink_1MHz.c in programmer's notepad and click on
Tools->Make All. This is the same as typing 'make all' from the command prompt from what ever directory you saved these two
files. For example
C:\Code\Blink>make all
should compile your code as well. It's just a bit easier to do this through the Programmer's Notepad interface rather than toggling
back and forth to the Command Prompt window. Once you have successfully compiled the C file into a HEX file, you now need to
get that hex file onto the AVR. It's finally time to power up your system! The cheap AVR programmers require the target (that's
your breadboard) to provide power to the programmer (that's the AVR-PG1 or PG2). Power up your bread board - you should see
the power LED come on. From here on out, I will assume you're using the AVR-PG2 parallel port programmer.
There is only two spots in the makefile that you should be concerned about at this time. These two spots are located under the
programming options section. This makefile is huge, but scroll down to the Programming Options (avrdude) section. Now put a '#'
in front of lines you want to comment out.
If you're using the AVR-PG1 (serial port programmer) you edit like this:
#AVRDUDE_PROGRAMMER = stk200
AVRDUDE_PROGRAMMER = ponyser
# com1 = serial port. Use lpt1 to connect to parallel port.
#AVRDUDE_PORT = lpt1
AVRDUDE_PORT = COM1
If you're using the AVR-PG2 (parallel port programmer) you edit like this:
AVRDUDE_PROGRAMMER = stk200
#AVRDUDE_PROGRAMMER = ponyser
# com1 = serial port. Use lpt1 to connect to parallel port.
AVRDUDE_PORT = lpt1
#AVRDUDE_PORT = COM1
Of course the port numbers depend on your specific computer but once you get things working, you'll be set for life. Assuming
you've edited and saved your makefile, go back to PN2. With your breadboard powered, click Tools->Program. This will send the
command 'make program' to the command prompt. If everything is setup correctly, you should have successfully loaded
blink_1MHz.hex onto your target ATmega328 and your LED should be blinking.
If you get an error :
can't open device "giveio"
Then read this page. Basically you need to copy the giveio.sys file from C:\WinAVR/bin to the C:\Windows directory, then type
install_giveio.bat at the command prompt.
Typical Problems:
If you still are not able to program the AVR - this is where 99% of first time users end up. Dig in and troubleshoot.
Are the ISP connections correct? It's easy to get the ISP connector backwards. Take a look at the photos above.
Is there a loose wire? Pull out the multimeter and check that you've got 5V being delivered to the VCC and GND pins on the
ATmega328. Do the wires going into the ISP connector have a good solid connection?
Do you have your ATmega328 connected to both power and ground?
Page 7 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
Is your 5V supply outputting 5V?
Do you have the right COM port or LPT port selected in your makefile?
There is a multitude of things to check. It's hard! I know. But once you get things correctly set up, and that LED blinks - it will feel
fantastic!
Ok - I'm going to assume that you got the code correctly loaded onto the AVR and that the LED is blinking. Congratulations! You
are now well on your way to a whole world of pain! Once you get one thing working, it's hard to stop! GPS, datalogging, RF, PCB
layout - it's all just a couple hops away.
You can get all the parts for this lecture here.
Here are some additional resources for AVR programming:
l http://piconomic.co.za/fwlib/index.html
l http://www.salvitti.it/geo/sequencer/dev_tools/tutorial/GNU_C_Tutorial.html
l http://palmavr.sourceforge.net/cgi-bin/fc.cgi
We love feedback! Please report typos, comments, or recommendations to spark@sparkfun.com.
Lecture 1 - Background and Power Supply
Lecture 2 - How to Get Code Onto a Microcontroller
Lecture 3 - What is an oscillator?
Lecture 4 - UART and Serial Communication
Lecture 5 - AVR GCC Compiling
Lecture 6 - Soldering Basics
Lecture 7 - SMD Soldering
Lecture 8 - Eagle: Schematics
Lecture 9 - Eagle: PCB Layout
Lecture 10 - Eagle: Creating a new part
Common Mistakes, Tips and Tricks
Comments 88 comments
Login to post comments.
hagna | February 20, 2009 at 2:17 PM 2
on ubuntu hardy avrdude wouldn't program the micro and gave the following message: avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATMEGA168 is 1E 94 06
After I connected pin1 on the micro to the programmers RESET or SS pin avrdued was able to program it and the light blinks.
Why doesn't this tutorial say anything about connecting SS to pin1?
hagna | February 20, 2009 at 2:21 PM 2
Oh and it also works if I hold down the reset button while I run avrdude.
unebonnevie | November 2, 2008 at 9:29 AM 1
Hi,
I got the ATMEGA8 programmed with the above lab, but the LED is NOT blinking. Made sure 5V is obtained, although I get
about 5.07V of input.
Page 8 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
I get the below I did 'make program'.
avrdude -p atmega8 -P lpt1 -c stk200 -U flash:w:blink_1MHz.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ##...# | 100% 0.00s
avrdude: Device signature = 0x1e9307 NOTE: FLASH memory has been specified, an erase cycle will be perfor
To disable this feature, specify the -D option.
avrdude: erasing chip reading input file "blink1MHz.hex" input file blink1MHz.hex auto detected as Intel Hex
avrdude: writing flash (300 bytes): Writing | ##...## | 100% 0.11s
avrdude: 300 bytes of flash written verifying flash memory against blink1MHz.hex. load data flash data from input file
blink1MHz.hex: input file blink1MHz.hex auto detected as Intel Hex input file blink1MHz.hex contains 300 bytes reading on-chip
flash data:
Reading | ##...### | 100% 0.09s
avrdude: verifying ... 300 bytes of flash verified Fuses OK
unebonnevie | November 2, 2008 at 10:04 AM 1
Could the problem be that the .hex file is generated as 'Intel hex'?
From avrdude's output:
input file blink_1MHz.hex auto detected as Intel Hex
unebonnevie | November 2, 2008 at 2:33 PM 1
After a couple hours...It's turned out if I took out the switch S1, it WORKS! Why does the last image (of this tutorial) that shows
the flashing light and the ISP hook-up does NOT have the switch S1 shown in the breadboard? Why was it taken out? I use
Omron's B3F-1005 switch, and the light does not blink when I wired the switch as shown in the tutorial's schematics. I wire it as
follows: pins 1-2 to the GND and pins 3-4 connect to my ATMEGA8's pin 1. Then the 10K ohm resistor from the switch's pin 4 to
the 5V supply.
Any tips????
BenP | March 9, 2009 at 2:59 PM 1
You might have the switch in the wrong way, or it was shorted. Either way it would cause the micro to constantly reset itself. That
sounds right to me.
k3jw | June 12, 2009 at 8:58 AM 1
I had the reset line install to pin 1, once this was remove it blinked!
nas | November 3, 2008 at 1:09 AM 1
i really like your site and these great tutorials. the one problem i ran into though which i beleive needs clarification is this: "You
can either wire the RESET pin directly to 5V" i did this i wired the reset pin directly to 5V without using the switch and recieved
errors from avrdude stating that the chip wasnt responding. so eventually i just put the resistor inbetween gnd and the reset pin and
everythign worked.
ps thanks for shipping my chip so quickly
joelspark | December 4, 2008 at 10:07 PM 1
I couldn't get WinAVR/avr_dude to recognize my ATMEGA168 for the life of me with the parallel port AVR programmer. I
bought the AVRISPmkii from DigiKey and used AVR Studio 4 to program my chip after compiling from Programmer's Notepad,
and now the chip is programmed and my circuit is working.
Page 9 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
unebonnevie | November 8, 2008 at 1:46 AM 1
I found the solution. Please see http://forum.sparkfun.com/viewtopic.php?t=12789. Note that the solution is only for ATMEGA8.
Here is the solution: Just put a 1nF cap from OSC1 to ground, and a 370 ohm resistor from OSC1 to Vcc.
unebonnevie | November 4, 2008 at 10:56 PM 1
I don't still understanding why my blink program is not running as soon as I wire the switch to the circuit. Without it, my
ATMEGA8 runs the blink program fine. My circuit is exactly as shown in this tutorial. I still have the connection from the RESET
pin to the SPI programmer's pin 5; that is, all the connections for my programmer is still in place.
Any tip? Can't go to the next tutorial without having the switch installed and my blink program running :-) I really want to
understand this.
Thanks.
dondurito | February 17, 2009 at 8:04 PM 1
I don't have a LPT1(DB-25) port or a DB9 port on my new computer. All I have is USB. I opened the tower and I see 1 port
unused and it's labeled "USB". The pin diagram is of 9 pins as follows:
[::::']
Is the 9 pin USB connection the same thing as a com port? should I connect the DB25 connector to the 9 pin USB connector?
venkat | February 18, 2009 at 4:54 AM 1
HERE IN PICTURE U HAV PUT SOME YELLOW CRYTAL,BUT U HAVNT EXPLINED DUDE
Mattamatta | March 17, 2009 at 3:33 AM 1
Those are the .1uF supply bypass caps.
venkat | February 18, 2009 at 4:50 AM 1
wat the reset switch actually does? can u clearly explain the connections for the ISP?
Freethinker | February 24, 2009 at 2:46 PM 1
Ok I hope this story helps someone... So for the past two weeks I've been trying to get my chips programmed (AVRs & 8052s) but
to no avail. It kept saying something about unable to detect microcontroller. I tried four different programmers, home built and
store bought, but nothing. Couple nights ago I remembered that when I built my Frankenputer last year I didn't enable the parallel
port in the bios thinking "who uses those anymore?" yeah... Opps! But my sever pain in the neck came when I couldn't get back
into the bios to turn it on. Why? Still not completely sure but I think it had something to do with me over clocking the thermal snot
out of my CPU. So anywho, I had to reset the bios so I could get into the bios, and then turn on the parallel port. All is well now
and my blood pressure is back within a healthy range. Moral of the story... Make sure your parallel port is enabled in the bios
before the urge to chuck heavy objects at your computer sets in...
SurgicalSteel | March 27, 2009 at 3:30 PM 1
Would it be possible to get a little explanation of the code. I think I understand all the hardware stuff, but I'm not really sure how
the code is working. The only other experience I've had coding micros is with the arduino (language and hardware).
mouse-wiz | March 19, 2009 at 2:19 AM 1
Blinky blinky blinky =D
Apparently it likes the following BIOS settings: Parallel port address 378 Mode bi-directional
And despite claims that my PC is making about 378 being lpt2, the makefile still wants it to be lpt1.
Next to try to trick it into working with the USB-parallel bridge so I don't have to take the board from table with laptop to P4 box
~_~
Meir | May 15, 2009 at 1:17 PM 1
Page 10 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
Will the serial programmer(PGM-00014 & CAB-00065) work the same as the parallel one(PGM-00013 & CAB-00064)? The
tutorial gives makefile settings for both but the parts package has the parallel port version. Also, is the programmer anything more
than wires directly from pin to pin? Can I just connect the wires directly without the programmer?
My other question is about the power supply. Would a 9v battery work better to reduce noise? If it would work, can I just replace
the barrel with it and not change anything else? How long would the battery last?
Thank you for your help in advance, I'm new and trying to get started as cheap as I can :)
mjustison | April 21, 2009 at 7:47 AM 1
Would the USBtinyISP usb programmer be a good option to use over the parallel programmer? My laptop does not have a parallel
input.
Michelle | May 7, 2009 at 11:19 AM 1
I have the USBtinyISP and it seems to be working great, although I can't get my LED to blink.
Does removing the chip from my programmer and putting in on a breadboard reboot the chip?
SteffenL | May 14, 2009 at 6:56 PM 1
I followed tutorial 1 and 2 and thought I had it right - but nothing worked. I got an "avrdude: AVR device not responding" message
from both, programmer's notebook and the cmd-line. I am using the parallel programmer connected to an IBM Thinkpad.
Eventually I tried an other LPT port - and even though windows makes me believe there is only LPT1 in the system, avrdude
works with LPT3 (the LED is now blinking nicely) - but only once. I cannot reprogram the ATmega unless I reboot my laptop. I
get the same error message as before without a reboot. Does anybody have an idea what's going on? (and maybe more importantly
a solution that allows me to reprogram without rebooting)
Thanks in advance.
DanS | April 19, 2009 at 4:56 PM 1
After programming i get some errors:
avrdude: verification error, fist mismatch at byte 0x0000 0x0C != 0x00
and
avrdude: safemode: lfuse changed! Was 62, and is now fe
I am also a little confused by the switch.. It doesn't program unless I hold down the reset button. Is that how it is supposed to
function?
MarcK | June 2, 2009 at 5:30 PM 1
Before I start these tutorials, showing my ignorance, I need to know what USB programmer works with these tutorials. Does the
STK500 work for this in replacement of the AVR-PG2 Programmer or how about the USBtinyISP? It sounds like either would
work?
treepour | June 6, 2009 at 5:48 PM 1
For those asking about the USBtinyISP, YES, IT DOES WORK! That LED is blinking as I type! :)
I used the 6 pin connector so I could avoid the 4 ground wires. You'll need to reference this schematic on ladyada's site to figure
out which pin is which: http://www.ladyada.net/images/usbtinyisp/usbtinyisp2sch.png
The VCC (pin 2) and GND (pin 6) pins are on the same side that as the ribbon. So:
pin 1: MISO pin 2: VCC pin 3: SCK pin 4: MOSI pin 5: RST pin 6: GND
It's very easy to get confused at this step -- I had to double-check and rewire many times. Also, make sure you're using the
ATmega168 pinout schematic to see where the corresponding chip pins are located -- the schematics for the older chip show the
pins in different locations. So, on the ATmega168 chip:
MISO: pin 18 VCC: pins 7 SCK: pin 19 MOSI: pin 17 RST: pin 1 GND: pin 8
Page 11 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
You also need to hook up pin 20 to your breadboard VCC and pin 22 to your breadboard GND.
treepour | June 6, 2009 at 5:58 PM 1
Oh, also, if you're using the USBtinyISP, you need to use the following in your Makefile:
AVRDUDE_PROGRAMMER = usbtiny
Not sure what you'd need to set your port to on a PC, but on a Mac, this works:
AVRDUDE_PORT = usb
PSmith | June 18, 2009 at 9:10 AM 1
I've got usbtiny working on a Windows (Vista) machine, and just like on the Mac, the port should be simply "usb". It's blinking
away even as I speak.
N.Poole | November 27, 2010 at 12:53 PM 1
In my experience you can leave port = Com1 on a PC as long as you have the USBTiny driver installed and the programmer is =
usbtiny
Also, if you're doing this tutorial with an ATTINY13 just use that as the device name both in the makefile and when you initialize
AVRDUDE. The list that avrdude gives you seems to indicate that you should input "t13" but it has no idea what you're talking
about if you use that name. Just type "attiny13"
Furthermore, if you unplug your programmer and find that light stops blinking (even though you're not using the programmer to
power the target) yank out the reset wire to the ISP connector. When the power is out on the programmer (at least the usbtiny) it
pulls the reset pin low.
Alrighty, just my little chunk of advice. Have fun!
Winguyen | June 12, 2009 at 8:21 AM 1
I can't get the code to compile for me. I keep getting this error...
Compiling: blink1MHz.c a r cc c mmcu atme a1 I. d arf CPU=8000000UL -Os -funsigned-char -funsigned-
bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=blink1MHz.lst std nu M M
M .dep blink1MHz.o.d blink1MHz.c o blink1MHz.o blink1MHz.c. . fatal error. openin dependenc file .dep blink1MHz.o.d:
No such file or directory compilation terminated. make.exe: *** [blink_1MHz.o] Error 1
Process Exit Code: 2 Time Taken: 00:00
I've looked over the code and I don't see any errors. Any help would be appreciated.
Thanks
Josh | June 15, 2009 at 1:05 AM 1
In Windows Vista, I had to manually create the .dep folder in the directory I was trying to compile in. Windows explorer would not
let me do this, so I did it through the command prompt.
Winguyen | June 15, 2009 at 6:33 AM 1
What was the file you made called? I made one called .depblink_1MHz.o.d and it still doesn't work.
Josh | June 15, 2009 at 9:55 AM 1
I had to make a folder called '.dep' in the directory my .c file was. So if my code sat in C:\code\blink1MHz I needed an additional
folder that I had to manuall create . code blink1MHz.dep\'. Once that folder was there, I compiled and it created the .o.d file
Page 12 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
Josh | June 15, 2009 at 9:57 AM 1
Sorry my backslashes did not show up. I will use arrows to show sub folders instead
C: -> code -> blink1MHz I needed an additional folder that I had to manuall create . code blink1MHz -> .dep'. Once
that folder was there, I compiled and it created the .o.d file
treepour | June 14, 2009 at 7:50 PM 1
Sounds like something is going wrong with the Makefile. I'm not all that familiar with Makefiles, but it looks like it can't find a
directory/file called .dep/blink_1MHz.o.d -- does the file actually exist (it should be created by the make process itself)?
Mitzplug | July 10, 2009 at 7:15 PM 1
I gad AVR parallel port programer and I fought for hours in order to make blink that damn led. I finaly success in modifing the
BIOS parallel port configuration of my computer. Looks like it was realy important for my PC to set it to: ECP (Extended
Capabilities Mode) and Port(O/I) 378 Then only lpt3 works, dont ask me why.
pieterc | July 24, 2009 at 12:28 AM 1
Hi!
This link is old: http://www.piconomic.co.za/avr.php
Please change it to: http://piconomic.berlios.de/
Best regards, Pieter
thejam | October 13, 2009 at 7:40 PM 1
I opened up my stk200 and used the continuity test on my multimeter to make sure the pinouts were right, and I found 3 of the 4
not connected to anything.
Just wondering why all 4 need to be connected when only one is really carrying anything...
Also, the reason I was checking pinouts is that I've now gone through two different ATMega168 chips that don't respond to
anything all of a sudden.
Well, the first one did for awhile and then stopped, but it was even buggy then (things like the LED only working until I unplugged
the programmer, and then not working until the shield around the pins on the programmer were grounded. Something I found out
by accident when I went to plug it back in.).
The second one doesn't work at all. I get zero response.
I thought at first all these problems were due to the fact that I received a 5v wall wart, and with the 5v regular there wasn't enough
overhead, so my voltage rail was really around 4.75v. So I just received a 9v wall wart and it's a solid perfect 5v all around now.
Still no help, however.
Any thoughts?
HebrewHammer | October 21, 2009 at 9:06 PM 1
OK, I've been trying to figure it out and I can't. Why is there a resistor before the switch connected to RESET? I know it is to "pull
RESET high", but how does the resistor do that? Why can't you just replace the resistor with a wire? Thanx!
Bonedog | February 10, 2010 at 2:20 PM 1
The resistor is there to limit the current to ground. Otherwise you would be shorting the power supply. Ohm's Law is: voltage /
resistance = current, or: voltage / current = resistance. So you figure the 10K ohm resistor would limit the current flow through the
resistor to 0.5 milliAmps (0.0005 A). This is important as the resistor is most likely a 1/4 watt resistor. The wattage (heating effect)
through the resistor is Volts x current = 5 x .0005 = 2.5 milliWatts, much lower than the 250 mW rating of the resistor.
Mangis | November 3, 2009 at 7:07 AM 1
Hello,
Would this all work with ATMEGA8? i'm wondering because it's cheaper and easier to get here, in Lithuania :P
Page 13 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
Pearce | November 3, 2009 at 3:30 PM 1
Yes, it will work with the ATMEGA8
hm | November 15, 2009 at 12:31 PM 1
You are GREAT! This tutorial is great too! Today I made my very first LED blink after 9 hours of constant work and destroying 3
ATMega16 micros! But the last one, by configuring the correct Fuse Bits was correctly programmed!
I am running way beyond this tutorial now, implementing all my simulated Proteus AVR projects in the real world and it is so
much fun and amazing!
egor7 | November 15, 2009 at 2:00 AM 1
All work's fine, thank you.
prkarls | December 14, 2009 at 9:51 PM 1
The 10kOhm resistor is in place to limit the current I=(5V/10000Ohm) when the push button is closed. If it were not there the 5V
rail would be shorted directly to ground when the push button is closed.
bill8 | December 20, 2009 at 3:40 PM 1
I was unable to unzip your blink_1MHz.zip file using WinZip 14. Error states "Cannot open file: it does not appear to be a valid
archive."
Does the link in the tutorial still have the blink_1MHz.c and Makefile?
Technologikall | December 26, 2009 at 12:33 PM 1
Hi I have a problem. When I download the link for the files, I don't get a makefile, I only get a file alled blink_1MHz. Where did
the makefile go to?
Tanksal | December 29, 2009 at 1:18 AM 1
I'm running Windows 7, and when trying to load the code to the microcontroller, I got the following error: can't open device
"giveio"
I clicked the link provided in the lesson, but the link was broken. I then used the Windows Explorer GUI to copy
C:\WinAVR\bin\giveio.sys to C:\Windows\giveio.sys, went to command prompt, and entered: install_giveio.bat
It outputs the following: Copying the driver to the windows directory target file: C:\Windows\giveio.sys The system cannot find
the file specified. Remove a running service if needed... Installing Windows NT/2k/XP driver: giveio Installing giveio from
C:\Windows\giveio.sys... install failed (status 6): The handle is invalid.
starting giveio... start failed (status 6): The handle is invalid.
ERROR: Installation of giveio failed
Does anyone have an idea of what I'm doing wrong?
EEStudent | December 31, 2009 at 7:36 PM 1
These tutorials are great. Thank you very much.
cjh08052 | January 16, 2010 at 11:04 AM 1
For the most part I got everything working. I was wondering how long it takes to upload a program to your device? I'm using a
home-built serial programmer based on the AVR-PG1B schematic. I did have to substitute some of the components and was
wondering if that is the root of my slow uploads or if this is just the norm?
;-> (cjh)
cjh08052 | January 17, 2010 at 9:30 AM 1
Page 14 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
Update;
I just pulled out an old laptop that has a com-port and everything works as I would have expected. I guess I'm having issues with
my USB-2-serial cable.
;-> (cjh)
thatdinosaurguy | January 21, 2010 at 2:11 PM 1
I'm going to buy the kits for lecture 1 and 2, but I have a question. What if my computer doesn't have parallel or serial ports? I'm
sure I can get USB adapters, but will they be recognized properly and be able to send it to the micro?
James1111 | January 26, 2010 at 11:30 PM 1
I am having trouble loading code onto Atmega168. I am using Serial Programmer. Code compiles fine, but when I go to load code
onto AVR, I get the following error:
"make.exe" program avrdude -p atmega168 -P COM1 -c ponyser -U flash:w:blink_1MHz.hex
avrdude: AVR device not responding avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to
override this check.
avrdude done. Thank you.
make.exe: *** [program] Error 1
Process Exit Code: 2 Time Taken: 00:01
Anyone have a solution to this problem??
cjh08052 | January 27, 2010 at 12:58 PM 1
Two things to check (in case you haven't already).
1. Make sure the power is on (for the AVR)
2. Double check that you're using the right com-port (you're output states 'COM1'). If you're using a USB-to-serial cable,
double check which com-port it was assigned in the system-settings.
Hope this helps.
;-> (cjh)
James1111 | January 29, 2010 at 12:08 AM 2
I added a 20Mhz crystal and it worked. When it started it was not running off the 20Mhz crystal, but rather the 1Mhz
default...wierd huh?
It now works and I am able to reprogram it now without any problems, and edit the fuse bits to use it at 20Mhz!
Serial com works no problem.
Bonedog | February 10, 2010 at 2:44 PM 1
First off, I too am a rank beginner with the Atmega168, et. al. But I just wanted to share what I might use as a blink.c code to
simplify the delay piece:
include include
// delay.h is a standard avr-libc library module
int main (void) { // set PORTC pin 1 (PC0) for output DDRC = 0x01;
while (1) { // set LED off PORTC = 0xfe;
_delay_ms(250);
// set LED on
Page 15 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
PORTC = 0xff;
_delay_ms(250);
}
return 1; }
Bonedog | February 10, 2010 at 2:53 PM 1
Ye gads! I forgot about the stripping of characters here. The include lines should read: include avr/io.h with 'less than' before and
'greater than' symbols after the avr/io.h. Same with the util/delay.h. Oops!
JohnS. | March 9, 2010 at 8:10 PM 1
Programmed a 328 with the AVR pocket programmer.
N.Poole | November 27, 2010 at 12:58 PM 1
Programmed a Tiny13. That pocket programmer is a killer buy, works great.
driver13 | March 13, 2010 at 12:13 AM 1
I've got it so close I can almost taste (okay, see) the LED blinking, but it comes out with:
avrdude: Device signature = 0x1e950f avrdude: Expected signature for ATMEGA168 is 1E 94 06 Double check chip, or use -F to
override this check
I'm using a 328 instead of the 168. Does anyone know how to either modify the code so it looks for the 328's signature or use the -
F check override? Any help would be much appreciated.
RocketTaco | July 13, 2010 at 12:05 AM 1
I'm guessing you've got this by now, but I'll leave this note for others. I got the same error.
Open the makefile, and find the line AVRDUDE I FLASH. You can append AVRDude command-line options to this line and
they will be run automatically when you choose Tools > [WinAVR] Program. Add -F to the end of this line and it will force the
write.
As far as I can tell there's no reason you can't use 168 code on a 328 (same chip, more memory) but AVRDude doesn't like it.
Zan | March 24, 2010 at 11:43 AM 1
What if my PC haven't paralel port ? Can this work for my and how? gvozdan@gmail.com
CleverAlias | April 3, 2010 at 6:56 PM 1
I'm trying to program the ATmega328P using this process, and have not had success yet. I had to add a PCI card to get parallel and
serial ports, and haven't been able to verify those ports yet. The XP device manager claims the parallel port is functioning and
located at lpt3.
I've checked voltages and SPI connections at least 4 times, and have tried a few variations of lpt port and MCU name in the
makefile, but still am getting the "AVR device not responding" error.
I can't tell if there is any major difference between the ATmega328P and the 168 that is the default in the makefile. Any ideas?
CleverAlias | April 3, 2010 at 11:33 PM 1
For what it's worth, the I/O range for the parallel port is B8A8-B8AF, I guess not the typical address for an LPT port from reading
the other posts.
CleverAlias | April 4, 2010 at 8:51 PM 1
Page 16 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
It turns out that if you dig into the avrdude documentation, the ports lpt1, lpt2, and lpt3 are hard-coded to addresses 0x378, 0x278,
and 0x3BC. My PCI parallel port is not at any of those addresses.
The command line interface allows for this case, so change line 204 in the makefile to the address of your port
AVRDUDE_PORT = 0xB8A8
I'm not sure if it makes a difference, but I ended up with line 43 in the makefile as:
MCU = atmega328p
instead of 168
Hopefully this helps those who follow after.
JeffC | April 15, 2010 at 11:34 PM 1
If you're using the USBtiny pocket programmer for the tutorial, do not include the -B 1 command line prompt at this stage: the
microcontroller's not fast enough to keep up with the programmer using the -B 1 switch.
In the makefile, I have these settings:
MCU name
MCU = m328p
Programming hardware: alf avr910 avrisp bascom bsd dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
AVRDUDE_PROGRAMMER = usbtiny
com1 = serial port. Use lpt1 to connect to parallel port.
AVRDUDE_PORT = COM6
(I'm not sure avrdude looks at the com port for a the USBtiny programmer.)
Also, wiring up the 10 pin connector is kind of a bear. I used the 6 pin instead. Note that the connector is keyed. If you hold the
connector so the holes are facing you, here are the pin numbers:
6 4 2 5 3 1
where the key protrusion is on the bottom, below pin 3. The pins are as follows:
1 - MISO 2 - VCC (+5 volts) 3 - SCK 4 - MOSI 5 - RST 6 - GND
genii6 | April 15, 2010 at 6:13 PM 1
Will this work with a home made DAPA parallel port programmer as described in this link:
http://www.arduino.cc/en/Hacking/ParallelProgrammer
genii6 | April 19, 2010 at 12:51 AM 1
I can verify that the parallel port programmer works. Tips on building it yourself. The cable should not be too long and I had to
remove the resistor at pin 11 of the DB25 connector. I downloaded the ISP programmer windows software to test it out. If you are
using avrdude, the following command should work:
avrdude -p atmega8 -P lpt1 -c dapa
This tells avrdude to identify your device. By default, a virgin atmega8 should have its fuse bits set to run at 1Mhz. You could try
adding the 16 Mhz crystals and .22 caps as well if things don't work.
Khalid | June 2, 2010 at 3:48 AM 1
Just a question; how would you program the ATmega if you don't have a parallel (printer) port on either your desktop or laptop?
csquare | July 4, 2010 at 8:19 PM 1
Is there any way to get the computers serial port to program the atmega328 via a .hex file?
Page 17 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
msundst | July 17, 2010 at 8:03 AM 1
my laptop doesnt have a printer port. how do i use usb to program?
Bartvoordummies | August 12, 2010 at 4:00 PM 1
Great tutorials, and dito comments. They've made me able to let the LED blink, via USB and @ 16 MHz. As a next experiment I've
recently tried to programmed another simple thing (I try to activate one pin via a switch, once activated another pin needs to burn a
LED for a couple seconds).
So I've edited the Blink1Mhz file and sa ed it as i dschakelaar. hen " a ed as" the makefile ou e supplied in the same folder
and edited it actuall ust chan ed ar et link1Mhz to Target Tijdschakelaar). Thinking this would do all I got was: Did not
find rule to make Tijdschakelaar.elf.
What could be the problem? Probably something dead obvious. Greetz from Belgium.
pieterc | August 16, 2010 at 2:43 AM 1
The Piconomic FWLIB has been revised and updated. The following link is old:
http://piconomic.berlios.de/avr uickstart_guide.html
It is now hosted at: http://piconomic.co.za/fwlib/avr uickstart uid_e.html
Enjoy! Pieter
CVBruce | August 30, 2010 at 12:52 PM 1
For development on Mac OS X, you can download CrossPack for AVR instead of WinAVR. It can be found at
http://www.obdev.at/products/crosspack/index.html
CTC-001 | September 21, 2010 at 11:14 PM 1
I am stuck trying to use avrdude from the command prompt to 'check in' with the atmega 328 (or is this the Atmega328P? It says P
on the chip but not on the sparkfun product page) Whichever one it is, the DIP is on the breadboard and wired for power and wired
to the 6 pin programming header via USBtinyISP. Everything seems to be in place exactly perfectly, avrdude says 'hello' to the
USBtinyISP but not to the chip. What is the exact command line to get avrdude to 'register' with the chip?
skatefriday | September 29, 2010 at 8:16 PM 1
I initially hooked up the pins on the connector in reverse. If you look at the schematic and then look at the picture of the connector
with the blue text pointing out the pin locations the schematic is the reverse of the picture if you are holding the connector in your
hand with the red strip oriented up.
At any rate, if I hook it up as in the picture, not as in the schematic, I get 0v on the reset pin into the atmega328. If I remove the
reset pin wire from the connector I get 5v going into the reset pin on the atmega328.
Did I fry the pocket programmer? Would it really be that easy to fry?
So I can't program the mcu because it's being held in reset. Any reason why the connector connections would pull that line low? I
know, a short to ground, but this is a brand new unit received in the mail from sparkfun a couple days ago.
skatefriday | September 30, 2010 at 8:57 AM 1
After probing the connector pins to figure out exactly where 5v was and then reconnecting all the wires, I was able to program the
atmega328 with
avrdude -p m328p -c usbtiny -U flash:w:blink.hex
skatefriday | October 5, 2010 at 10:56 PM 1
If you have 5v before the 10k resistor at the reset switch, but 0v after the resistor is it fair to say there's a short in the circuit on your
breadboard someplace? I have a two 8 bit shift registers hooked up to the avr and a bunch of leds hooked up to the shift registers.
Note that when the programmer is hooked up and supplying power to the avr, it runs, but when it's not hooked up, the reset line
goes low after the resistor, but not before but the end result is that avr is in reset.
Page 18 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
zombi | November 9, 2010 at 8:33 PM 1
These tutorials are great, thanks for making them (I bought the kits for the first few from Sparkfun)
My blinking LED worked first time :D There is one step missing from the tutorial - the first line of the makefile needs to be altered
- change MCU name to match the micro you have. MCU = m328p worked for me with the micro provided in the kit. (Run make all
and program after this change)
I would also like more explanation about the "decoupling" caps added in the photo that are not shown in the schematic - or even a
link or search term so I could learn the purpose of these caps.
DerVundrPlumbs2 | November 14, 2010 at 12:08 AM 1
It took me four hours but finally got this going. I originally tried on my LPTless laptop using a USB to parallel port dongle through
a virtual machine (long story) but could not get it to work. I then added a PCI parallel port to my desktop figuring that the
Programmers Notepad was looking for a specific address and this did not work either with lpt1. I had been over and over the
wiring, so I went into device manager (devmgmt.msc at command line) and opened the PCI parallel port device. Under the
resources tab it lists the IO location so I specified the starting location ("0xec00") instead of "lpt1" as the value for
AVRDUDE_PORT in the make file. I also changed the MCU value to "m328p" to match my chip as suggested in other posts.
Have to remember this is all case sensitive. Finally works. Hopefully this will help someone else now that parallel ports are hard to
come by on modern machines.
nmushov | November 15, 2010 at 9:23 PM 1
I'm waiting on my parts to start this tutorial so I cant test the voltages, but I'm confused on the RESET section. If there's a 10k
Resistor between the 5V supply and Reset pin, wont the Reset pin see a significantly lower voltage than 5V? I'm new to all this,
just trying to understand. Thanks!
nmushov | November 15, 2010 at 9:34 PM 1
Does the reset pin just care if there's some voltage there? So it doesnt reset if it see's some voltage, but when the reset button is
pushed, the voltage drops to zero on the reset pin, because there's a clear path to ground?
N.Poole | November 27, 2010 at 1:09 PM 1
Yeah guys, the reset pin is active low. So in the digital world, for all intents and purposes high is anything just below 5v (or 3.3v if
you're running a 3.3 system) and low is anything just above 0v. Where they meet? That varies from chip to chip (there's a tut on it
in the new bite-sized primers section) You seem to understand pretty well whats going on: The pin sees about 4-5v so it's "ON" but
when you push the button it grounds the incoming voltage and the pin gets about 'nothing' volts.
What you're doing though is forgetting that the point of the switch ISN'T to route the RST pin to GND, it's to route the voltage off
of the resistor to GND (Before it can reach the pin to pull it up) So when you push the switch you're sinking not only the chip to
GND but also the system voltage, and what do you get when you ground the system voltage without a resistance? That's right: a
short! So the resistor is there so that when you reset the IC, it doesn't short your supply. Sure, the IC would reset without it, but
things might spark when you pushed the button, lol.
Cheers!
ashcan | December 4, 2010 at 3:04 PM 1
I bought the kit for the tutorial and made it painlessly up to the point of programming the 328. No blinky, inconsistent messages
(which should have been a clue itself), and a bad link for the 'read this page' for the giveio problem. Frustration starts here.
Granted, this is a basic embedded tutorial, but a little more detail beyond some trial suggestions for the 'What now, when things
don't work?' would be nice, so here's some:
First, I did some web surfing. (Actually, first, I copied the giveio thing and installed it, but I don't know if that had any signficant
impact on my results or not.) The ATmega328P is programmed using an SPI (Serial Peripheral Interface) connection. This is well-
documented in ATMEL application (app) note 910(http://www.atmel.com/dyn/resources/prod_documents/doc0943.pdf). From
that, I learned that the information flowing from the laptop to the 328 is mostly controlled by SCK (pin 7 on the ICSP connector of
the Olimex (AVR-PG2/STK) programmer) and MOSI (pin 1), so I started there. The guts of the Olimex connector are shown in:
http://www.olimex.com/dev/pdf/avr-pg2b.pdf. Extra points for getting the data sheet on the 74HC244 inside it. I
worked backwards through the 74HC244, and saw that SCK is driven from DB-25 pin 6 and MOSI from pin 7. I've got an
oscilloscope, so I probed these two pins looking for signs of life, pulling my ground reference from pins 18-21 (I used 19, IIRC).
No joy when I hit 'Program' from Programmer's Notepad. LPT1 wasn't playing. If I didn't have the o-scope, I'd have hooked up my
trusty voltmeter (or a pulse catcher, if I had one). I ran across some programs on the web that turn the parallel pins on or off for
debugging, so these could be used to see if your PC actually drives the parallel port from LPT1. They'd be handy with the
voltmeter, but with the oscilloscope I didn't need them. Per some of the other commenters' suggestions, I tried lpt2 and lpt3, but
Page 19 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
still got nothing. I don't have a lot of patience for trial-and-error debugging anyway.
I got WinAVR loaded onto my Gateway laptop, model M685-E, running Windows XP (Service pack 3), and using the parallel port
on its docking station. The BIOS setting (F2 on power-up) for my parallel port was set to AUTO. I'm not quite sure what AUTO
means, but given the choices of AUTO, ENABLE, or DISABLE, I changed it to enable. I was also given four choices for MODE.
Given that I needed to hear back from the 328 on MISO, I didn't even bother trying 'output-only'. 'Bi-directional' didn't result in any
output either, but I got wiggles using LPT1 for both 'EPP' and 'ECP'. The BIOS addresses were both 378 and I didn't feel the need
to change them. Further creative scoping showed the wiggles included the $AC53 string used to put the 328 into programming
mode, so my port problems were apparently fixed. Next, it was time to hook the hardware back up.
Per the app note, the 328 is designed to set all its port pins as inputs while it's in reset mode, readying it to receive programming
commands. Note that reset means pin 1 is grounded (Can we get the Sparkfun folks to correct the chip pinout picture in this tutorial
so RESET has a line over it, please?). For those looking at the Olimex schematic, pin 5 does not appear connected at first glance.
But if you look at IC1B, outputs Y2,Y3, and Y4 are wired to a little diamond/circle doodle with '(5)' above it. This notation is used
sometimes in schematics to denote a connection when drawing a wire might make the schematic harder to read. For the unwitting,
it ticks another point on the frustrate-o-meter. So according to this, the 328 reset is driven from DB-25 pin 9. All goodness so far.
While we're looking at this schematic, also note ICSP pins 4,8, and 10 aren't connected to anything. In fact, the wires are physically
cut off inside the Olimex programmer (The one I just got, anyhow). Despite the bold note in the tutorial about the ground pins, it
just ain't true (or at least it isn't for me). Pin 6 is the only one that counts. So ultimately, you need six wires, not nine.
Looking further at the Olimex schematic, notice that the power for the IC comes from the ICSP connector (through a diode). This
makes it possible for the IC to operate at (and output) a different voltage than the parallel port that's driving it. This is NOT trivial.
The wiggles from my parallel port were around 3 volts. I guess I shouldn't be surprised; manufacturers of systems with parallel and
serial ports (especially laptops) have notoriously played fast and loose with port signal voltages for years, and you can't count on
them.
I was operating the 328 (and ICSP pin 2) at 5 volts. There was a .25-volt drop across the diode, so the 74HC244 was operating at
4.75 volts, which was still significantly higher than its 3-volt inputs. Chips like this have a defined minimum input voltage before
they recognize the input as a logic '1' (It's on the datasheet). The higher the operating voltage, the higher the minimum input '1'
voltage. Below this voltage, all bets are off, which I think contributed to my inconsistent initial results.
I have a dc supply, so I skipped lecture 1. The 328 is designed to operate at voltages down to 1.8 volts, so I simply turned my
supply voltage down (4.3 volts, in my case), to get the 74HC244 operating voltage more in-line with its inputs. Blinky blinky.
Smile. Obviously, you folks with the 7805's can't simply turn down your voltage like I did (if that's truly your problem). There are
ways to bias the 7805 to get something other than 5 volts from it, but the LM317 is better suited to being used in a variable supply.
If you check out the schematic for this kit, you'll see it's set up roughly the same as your 7805, but instead of grounding it directly,
there's some resistors there to control it (some folks use a trim pot): http://www.sparkfun.com/products/114
Last note to all you who have been fortunate enough to be mesmerized by your new blinky: I turned off the laptop and the blinky
stopped blinkying. I'd left the programmer attached, so turning off the computer also turns off the parallel port (duh). Seeing zeros
on the parallel port forces the programmer to hold the 328 in reset mode, preventing it from running. If you yank the reset line from
the programmer to port 1 on the 328, it blinkys again.
JonathanP | January 30, 2011 at 3:20 PM 1
Windows 7
Install WINAVR
Look at your PATH variable
I spent hours trying to figure out why I couldn't ping a network address from the command line, when I finally decided to look at
my PATH variable. What was there?
C:\WinAVR-20100110\bin;C:\WinAVR-20100110\utils\bin
The installer seems to have removed every other part of my PATH variable.
I would recommend making a copy of your PATH before installing WINAVR.
Good tutorial! I finally got the ATmega328 working with this program before moving onto the next tutorial where I fried it. But,
got it all working on a new chip.
Hope the PATH advice helps.
FoxxCommand | February 15, 2011 at 5:44 AM 1
AAARRRRHHHH! How do I use the Pocket AVR Programmer with this?!?!?!
msundst | February 19, 2011 at 12:51 PM 1
Page 20 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm
How do we do this with USB? Please HELP!!!
J.R. | March 4, 2011 at 4:24 PM 1
For those having trouble with "giveio" in Windows 7, see this website.
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=88034
Basically it says, copy the 'giveio.sys' to 'c:/windows/system32', and then run 'install_giveio.bat' as an administrator. (run as admin:
right click on command prompt and click run as admin)
!LH@N | March 10, 2011 at 5:49 PM 1
Hi! I am still getting the message "cant open device giveio", I ran install_giveio.bat several times, but to no avail, I always get an
error message! By the by the website you have provided for solving this problem doesn't work anymore!
Page 21 of 21 Beginning Embedded Electronics - 2 - SparkFun Electronics
25-03-2011 file:///C:/Users/Viswa/Desktop/Atmega%208%20Burner%20Kit.htm