PurpleJesus

STK500 & Dragon

10 posts in this topic

Thought I'd throw this out there to those of you wanting to get into microcontroller programing on the fairly cheap...

Atmel is selling the STK500 starter kit bundled with the AVR Dragon (a usb & other kinds of programmer) for $49 bucks usd.

about the stk500: http://www.atmel.com/dyn/Products/tools_ca...sp?tool_id=2735

about the Dragon: http://www.atmel.com/dyn/Products/tools_ca...sp?tool_id=3891

I got mine from digikey it includes all the cables and stuff you need to start out of the box. Just give it 12 volts or so from somewhere.

and it includes two microcontrollers to play with/burn up.

Where I got mine:

http://www.digikey.com/scripts/DkSearch/dk...933&Site=US

Moderators: this was my best guess where to put this... move it if you can think of somewhere better.

0

Share this post


Link to post
Share on other sites

Ah, wow.. I picked up the STK500 & 501 (surface mount programmer) with 3 microprocessors for around $100 off ebay a while back.. I set it up and upgraded the firmware and then played with the test program a bit but haven't really done much else. I should dig it out and make something cool.

0

Share this post


Link to post
Share on other sites

It's not as flexible, but the Arduino board looks really cool. It's open source (schematic and toolchain) and there's a really active community around it.

0

Share this post


Link to post
Share on other sites

Ohm -- I totally agree. Although the Arduino doesn't support use of the AVR's more advanced features (namely interrupts), it is still a really great tool to have in your hardware hacking toolbox -- you can get a simple prototype system up and running in literally minutes.

Once, after spending about three hours hardware hacking an optical mouse PCB, I implemented an interface to pull back the coordinate data from the mouse in about twenty minutes using the Arduino, and it worked on the first shot. Also, the Arduino interprets 3.3V logic inputs correctly, which saves some additional interfacing headaches.

And they're cheap, too (I got mine from SparkFun's ding/dent section for like $12). There are also variations available with a Bluetooth interface (at tinker.it), and the same folks are working on an Ethernet-enabled version as well.

So, although I wouldn't recommend basing all your hardware hacks/inventions around the Arduino, it's a worthwhile time-saving tool.

Also, if you're just getting into hardware/uC stuff and you're trying to decide between PIC or AVR, I'd say go with AVR. I've been programming for the PIC for a couple of years now and find that my creativity is constantly limited by the lack of a free C compiler for the PIC.

Edited by parnekin
0

Share this post


Link to post
Share on other sites
Ohm -- I totally agree. Although the Arduino doesn't support use of the AVR's more advanced features (namely interrupts), it is still a really great tool to have in your hardware hacking toolbox -- you can get a simple prototype system up and running in literally minutes.

Once, after spending about three hours hardware hacking an optical mouse PCB, I implemented an interface to pull back the coordinate data from the mouse in about twenty minutes using the Arduino, and it worked on the first shot. Also, the Arduino interprets 3.3V logic inputs correctly, which saves some additional interfacing headaches.

And they're cheap, too (I got mine from SparkFun's ding/dent section for like $12). There are also variations available with a Bluetooth interface (at tinker.it), and the same folks are working on an Ethernet-enabled version as well.

So, although I wouldn't recommend basing all your hardware hacks/inventions around the Arduino, it's a worthwhile time-saving tool.

Also, if you're just getting into hardware/uC stuff and you're trying to decide between PIC or AVR, I'd say go with AVR. I've been programming for the PIC for a couple of years now and find that my creativity is constantly limited by the lack of a free C compiler for the PIC.

I'll have to give that shot... Right now I am still reading the books trying to figure out what's going on.. (Embedded C Programming and the Atmel AVR 2nd edition) Does anyone know when I want to read up on something; why work always picks up and I 'm too tired to think when I get home?... geeses..

I like that board. it looks like a good tinker/quick proto thing.. will check into getting a few for the collection at that price..

. Wont hurt the wallet to fry a few of em... which I have a habit of doing when I am learning.

I'm glad to hear you suggest the AVR over PIC.. I chose the AVR 'cause the instruction set looked kinda like the old 6502 set, which I am intimately familiar with from my C=64 days.. (I miss that machine; sometimes)

0

Share this post


Link to post
Share on other sites

Oh boy, another 6502 coder :) My first machine (and only machine for 10 years) was a C64. I even recently wrote a 6502 emulator. Not a terribly useful skill anymore though.

0

Share this post


Link to post
Share on other sites
I'm glad to hear you suggest the AVR over PIC.. I chose the AVR 'cause the instruction set looked kinda like the old 6502 set, which I am intimately familiar with from my C=64 days.. (I miss that machine; sometimes)

Writing assembler for the PIC is annoying. The memory space is banked so that you have to twiddle bits in a status register to access different parts of the memory space, and some registers carry over between banks, and other registers don't, and it's all a big pain. There are nice C compilers out there that absolve you from dealing with the memory banking (mostly), but -- like I said -- they aren't free (well not legally free anyway).

I guess it's the architecture that requires the banking of the memory space, but man it's annoying. I'd have just increased the instruction word size to 16 bits instead of 14 and included the entire address in the opcodes.

0

Share this post


Link to post
Share on other sites

I've got the Arduino board and its pretty nifty. I'm a noob with this stuff, but its pretty fun to code for.

0

Share this post


Link to post
Share on other sites

Ohm:

Glad to hear I wasn't the only one with his head in the C=64 for many years... 6502 emulator? you must have been missing the good-ol'-days. I'd like to see it.

Edited by PurpleJesus
0

Share this post


Link to post
Share on other sites

I know this is an old thread.. but I got back to playing with the STK500 the other day on linux and thought I'd give anyone the makefile changes that I finally got to work with avr-gcc & avrdude on linux.

It was interesting to figure out.. and way simpler then I thought it'd be..

Just change the source name to whatever your source is and type: 'make install' and it'll compile and burn to the STK500 in one step. It made my life easier.

btw: my STK500v2 is on port ttyS0... so this file is configured for that; easy change though... the avrdude -B flag turned out to be the magic fix for verification issues.

 ##This one seems to work for me... 


######### AVR Project Makefile Template #########
###### ######
###### Copyright © 2003, Pat Deegan, ######
###### Psychogenic Inc ######
###### All Rights Reserved ######
###### ######
###### You are free to use this code as part ######
###### of your own applications provided ######
###### you keep this copyright notice intact ######
###### and acknowledge its authorship with ######
###### the words: ######
###### ######
###### "Contains software by Pat Deegan of ######
###### Psychogenic Inc (www.psychogenic.com)" ######
###### ######
###### If you use it as part of a web site ######
###### please include a link to our site, ######
###### [url="http://electrons.psychogenic.com"]http://electrons.psychogenic.com[/url] or ######
###### [url="http://www.psychogenic.com"]http://www.psychogenic.com[/url] ######
###### ######
####################################################


##### This Makefile will make compiling Atmel AVR
##### micro controller projects simple with Linux
##### or other Unix workstations and the AVR-GCC
##### tools.
#####
##### It supports C, C++ and Assembly source files.
#####
##### Customize the values as indicated below and :
##### make
##### make disasm
##### make stats
##### make hex
##### make writeflash
##### make gdbinit
##### or make clean
#####
##### See the [url="http://electrons.psychogenic.com/"]http://electrons.psychogenic.com/[/url]
##### website for detailed instructions


####################################################
##### #####
##### Configuration #####
##### #####
##### Customize the values in this section for #####
##### your project. MCU, PROJECTNAME and #####
##### PRJSRC must be setup for all projects, #####
##### the remaining variables are only #####
##### relevant to those needing additional #####
##### include dirs or libraries and those #####
##### who wish to use the avrdude programmer #####
##### #####
##### See [url="http://electrons.psychogenic.com/"]http://electrons.psychogenic.com/[/url] #####
##### for further details. #####
##### #####
####################################################


##### Target Specific Details #####
##### Customize these for your project #####

# Name of target controller
# (e.g. 'at90s8515', see the available avr-gcc mmcu
# options for possible values)
################################################ #
############################################### #
################################################ #

#F_CPU = 8000000 #clock speed
MCU=atmega16
Dude_MCU=m16 #dude likes it different for some reason.
#So change both of these if you plan to use make install or make writeflash.


# Name of our project
# (use a single word, e.g. 'myproject')

PROJECTNAME=program
# Source files
# List C/C++/Assembly source files:
# (list all files to compile, e.g. 'a.c b.cpp as.S'):
# Use .cc, .cpp or .C suffix for C++ files, use .S
# (NOT .s !!!) for assembly source code files.
######################################################### ##
#PRJSRC=blinky.c myclass.cpp lowlevelstuff.S
PRJSRC=madblink.c


# additional includes (e.g. -I/path/to/mydir)
INC=

# libraries to link in (e.g. -lmylib)
LIBS=

# Optimization level,
# use s (size opt), 1, 2, 3 or 0 (off)
OPTLEVEL=s


##### AVR Dude 'writeflash' options #####
##### If you are using the avrdude program
##### (http://www.bsdhome.com/avrdude/) to write
##### to the MCU, you can set the following config
##### options and use 'make writeflash' to program
##### the device.


# programmer id--check the avrdude for complete list
# of available opts. These should include stk500,
# avr910, avrisp, bsd, pony and more. Set this to
# one of the valid "-c PROGRAMMER-ID" values
# described in the avrdude info page.
#
AVRDUDE_PROGRAMMERID= stk500v2

# port--serial or parallel port to which your
# hardware programmer is attached
#
AVRDUDE_PORT=/dev/ttyS0

AVRDUDE_BAUDRATE = 115200
AVRDUDE_BITCLOCK = 4



####################################################
##### Config Done #####
##### #####
##### You shouldn't need to edit anything #####
##### below to use the makefile but may wish #####
##### to override a few of the flags #####
##### nonetheless #####
##### #####
####################################################


##### Flags ####

# HEXFORMAT -- format for .hex file output
HEXFORMAT=ihex

# compiler
CFLAGS=-I. $(INC) -g -mmcu=$(MCU) -O$(OPTLEVEL) \
-fpack-struct -fshort-enums \
-funsigned-bitfields -funsigned-char \
-Wall -Wstrict-prototypes \
-Wa,-ahlms=$(firstword \
$(filter %.lst, $(<:.c=.lst)))

# c++ specific flags
CPPFLAGS=-fno-exceptions \
-Wa,-ahlms=$(firstword \
$(filter %.lst, $(<:.cpp=.lst))\
$(filter %.lst, $(<:.cc=.lst)) \
$(filter %.lst, $(<:.C=.lst)))

# assembler
ASMFLAGS =-I. $(INC) -mmcu=$(MCU) \
-x assembler-with-cpp \
-Wa,-gstabs,-ahlms=$(firstword \
$(<:.S=.lst) $(<.s=.lst))


# linker
LDFLAGS=-Wl,-Map,$(TRG).map -mmcu=$(MCU) \
-lm $(LIBS)

##### executables ####
CC=avr-gcc
OBJCOPY=avr-objcopy
OBJDUMP=avr-objdump
SIZE=avr-size
AVRDUDE=avrdude
REMOVE=rm -f

##### automatic target names ####
TRG=$(PROJECTNAME).out
DUMPTRG=$(PROJECTNAME).s

HEXROMTRG=$(PROJECTNAME).hex
HEXTRG=$(HEXROMTRG) $(PROJECTNAME).ee.hex
GDBINITFILE=gdbinit-$(PROJECTNAME)

# Define all object files.

# Start by splitting source files by type
# C++
CPPFILES=$(filter %.cpp, $(PRJSRC))
CCFILES=$(filter %.cc, $(PRJSRC))
BIGCFILES=$(filter %.C, $(PRJSRC))
# C
CFILES=$(filter %.c, $(PRJSRC))
# Assembly
ASMFILES=$(filter %.S, $(PRJSRC))


# List all object files we need to create
OBJDEPS=$(CFILES:.c=.o) \
$(CPPFILES:.cpp=.o)\
$(BIGCFILES:.C=.o) \
$(CCFILES:.cc=.o) \
$(ASMFILES:.S=.o)

# Define all lst files.
LST=$(filter %.lst, $(OBJDEPS:.o=.lst))

# All the possible generated assembly
# files (.s files)
GENASMFILES=$(filter %.s, $(OBJDEPS:.o=.s))


.SUFFIXES : .c .cc .cpp .C .o .out .s .S \
.hex .ee.hex .h .hh .hpp


.PHONY: writeflash clean stats gdbinit stats

# Make targets:
# all, disasm, stats, hex, writeflash/install, clean
all: $(TRG)

disasm: $(DUMPTRG) stats

stats: $(TRG)
$(OBJDUMP) -h $(TRG)
$(SIZE) $(TRG)

hex: $(HEXTRG)

writeflash: hex
$(AVRDUDE) -B $(AVRDUDE_BITCLOCK) \
-b $(AVRDUDE_BAUDRATE) -c $(AVRDUDE_PROGRAMMERID) \
-p $(Dude_MCU) -P $(AVRDUDE_PORT) -e \
-U flash:w:$(HEXROMTRG):i

install: writeflash

$(DUMPTRG): $(TRG)
$(OBJDUMP) -S $< > $@


$(TRG): $(OBJDEPS)
$(CC) $(LDFLAGS) -o $(TRG) $(OBJDEPS)


#### Generating assembly ####
# asm from C
%.s: %.c
$(CC) -S $(CFLAGS) $< -o $@

# asm from (hand coded) asm
%.s: %.S
$(CC) -S $(ASMFLAGS) $< > $@


# asm from C++
.cpp.s .cc.s .C.s :
$(CC) -S $(CFLAGS) $(CPPFLAGS) $< -o $@



#### Generating object files ####
# object from C
.c.o:
$(CC) $(CFLAGS) -c $<


# object from C++ (.cc, .cpp, .C files)
.cc.o .cpp.o .C.o :
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<

# object from asm
.S.o :
$(CC) $(ASMFLAGS) -c $< -o $@




#### Generating hex files ####
# hex files from elf
##### Generating a gdb initialisation file #####
.out.hex:
$(OBJCOPY) -j .text \
-j .data \
-O $(HEXFORMAT) $< $@

.out.ee.hex:
$(OBJCOPY) -j .eeprom \
--change-section-lma .eeprom=0 \
-O $(HEXFORMAT) $< $@


##### Generating a gdb initialisation file #####
##### Use by launching simulavr and avr-gdb: #####
##### avr-gdb -x gdbinit-myproject #####
gdbinit: $(GDBINITFILE)

$(GDBINITFILE): $(TRG)
@echo "file $(TRG)" > $(GDBINITFILE)

@echo "target remote localhost:1212" \
>> $(GDBINITFILE)

@echo "load" >> $(GDBINITFILE)
@echo "break main" >> $(GDBINITFILE)
@echo "continue" >> $(GDBINITFILE)
@echo
@echo "Use 'avr-gdb -x $(GDBINITFILE)'"


#### Cleanup ####
clean:
$(REMOVE) $(TRG) $(TRG).map $(DUMPTRG)
$(REMOVE) $(OBJDEPS)
$(REMOVE) $(LST) $(GDBINITFILE)
$(REMOVE) $(GENASMFILES)
$(REMOVE) $(HEXTRG)



##### EOF #####

and a simple program for the ATMEGA16

// Madblink.c
//PurpleJesus
//Scrolls the LED's back and forth on port D while changing the speed from fast to slow...
#define F_CPU 4000000
#include <avr/io.h>
#include <util/delay.h>

int i; // loop;
int main (void)

{
// set PORTD for output
DDRD = 0xFF;
int dir = 1;
int dot = 0;
int min = 10;
int speed= min;
int max =10000;
int step = 25;

while(1)
{
PORTD = ~(1 << dot);
_delay_loop_2 (speed);
dot = dot + dir;
if ((dot > 6) | (dot < 1)) dir = - dir;
speed = speed + step;
if (speed >= max)
{
speed = max;
step = -step;
}

if (speed <= min)
{
speed = min;
step = -step;
}
}
}


0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now