SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By The Noob
#88091
Hi, I'm following this tutorial http://www.sparkfun.com/commerce/tutori ... ials_id=93
And I cannot get my code into the MCU.
Also the link to the blink_1MHz file doesn't give any makefile.

What I'm trying to do is make a led blink. I'm new to embedded.
So I tried googling alot but it didn't help. After hours trying and researching I still didn't succeed. =(

The hardware I have is
- this programmer: http://www.sparkfun.com/commerce/produc ... ucts_id=13
- atmega168
- The circuit in that tutorial

How can I get a ledblink code to work? If you need more info just tell.
I hope someone can help me with this.

Edit: Okay so I am still trying and now I have this problem.
Makefile is in this link because I get an error when post it here in it's whole (I can post the first part of it if you want).

http://rapidshare.com/files/327101186/Makefile.html

Okay so the problem is this: I can compile my program but when I try to load it into my atmega168 using programmers notepad I get this error.
avrdude -p atmega168 -P lpt1 -c -U flash:w:blinky.hex

avrdude: Can't find programmer id "-U"

valid programmers are:
then I get a list of programmers here, an after that:
make.exe *** [program] Error 1
Can anyone please help me with this? I would greatly appriciate it!
By tetsujin
#88184
The Noob wrote: Edit: Okay so I am still trying and now I have this problem.
Makefile is in this link because I get an error when post it here in it's whole (I can post the first part of it if you want).

http://rapidshare.com/files/327101186/Makefile.html
I can't download your Makefule. Rapidshare says I need to be a premium member...
Okay so the problem is this: I can compile my program but when I try to load it into my atmega168 using programmers notepad I get this error.
avrdude -p atmega168 -P lpt1 -c -U flash:w:blinky.hex

avrdude: Can't find programmer id "-U"
The "-c" option to avrdude is used to specify the type of programmer hardware you're using. But the name of the programmer hardware is missing in that command, so avrdude thinks you've specified "-c -U", using "-U" as the name of the programmer hardware.

In this case, I think it needs to say "-c stk200" to indicate that you're using an STK200-compatible programmer on a parallel port. Most likely there's a place in the makefile that's used to indicate the programmer type - some variable that needs to be set.

I downloaded "blink_1MHz.zip" from that tutorial and it does include a Makefile... And there's a section of the tutorial that tells you how to customize it for your programmer:
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
Also, it's possible you'll need to deal with the "giveio.sys" if you're on Windows. Unfortunately it seems the link from the "Lecture 2" tutorial to information about how to use giveio.sys is broken... I'm a Linux user myself so I don't really know all the details about using giveio.sys on Windows or what versions of Windows will require you to use it - I just understand the principles of system protection that make measures like that necessary... But try to fix the programmer type in your avrdude command and see if that works. If you get the "giveio" error then you may need to install giveio.sys.


Finally, I wanted to include a bit about my background with microcontrollers: I'm really only getting started with AVR's myself, but I've been working with PICs for several years. So I'm no expert with AVRs but I'll try to help you through this process.

I originally tried to program PICs with a cheap parallel port hardware, similar in principle to the STK200 clone you're using - but I never could make it work. From what I've heard there's a lot of variation in the electrical characteristics of PC parallel ports - some of them aren't well-suited to driving circuits like cheap microcontroller programmers. There's no reason yet to believe your STK200 clone won't work for you - but if you fix the makefile, and avrdude succeeds at getting access to the parallel port, and you've made sure your ISP connection is correct but you still can't program AVRs with it, then you might consider getting a better programmer.

My recommendation at this point, if you do wind up needing a new ISP programmer would be USB Tiny ISP (I'll probably buy one of these at some point) - I can't recommend the Sparkfun Clone of USB Tiny ISP - there's a problem with their USB hardware implementation which, as far as I know, has not yet been fixed. It's still way too early to give up on the programmer you've got, though, so it's just something to think about.
By The Noob
#88194
Thanks for helping me out! It was really helpful. After hours of trying I finally got that blasted led to blink. =D

I checked the makefile to check what that -c was and I found somewhere a variable or something that had AAVRDUDE as name instead of AVRDUDE that that -c referred to. XD
So I fixed that and then I got the giveio error but that isn't too hard to fix with those instructions.

I still couldn't get the makefile from that tutorial though. Not that it even matters anymore since I have a Google makefile now, but it's still mysterious.

It is all fixed now. Thank you for your time and help.
By tetsujin
#88198
The Noob wrote:Thanks for helping me out! It was really helpful. After hours of trying I finally got that blasted led to blink. =D
Right on! You know, once you get the LED to blink it's all downhill from there. :) I was really happy when I finally got the LED to blink on my PIC 18F4550... Took me years to get that one to blink...