Академический Документы
Профессиональный Документы
Культура Документы
1 Introduction
2 Required software
AVR binutils consists of essential tools as GAS assembler, linker and other utilities needed to
obtain HEX le suitable to load to AVR µC.
The great advantage is we don't have to develop our software in assembly language, but
The C Programming Language can be used. Simply install AVR-GCC compiler and AVR Libc
to allow C programming.
Use your package manager for installation, additional informations can be easily found.
Gentoo user will refer to detailed Gentoo Cross Development Guide.
The last required software tool is the downloader. It gets your program into the micropro-
cessor. I'm satised with avrdude (AVR Downloader and UploaDEr).
3 Programmer hardware
Physical program transfer must be done by some hardware programmer. There is a lot of com-
mercial programmers: ocial STK500, USBtinyISP by Adafruit Industries and lot of others...
It is easy to build your own. Buered version should be used, but I found and build
extremely simple STK200-compatible programmer for parallel port from gure 1 and I didn't
noticed any problems (I sadly can't nd author.). Keep the length of cable shorter than 1
meter. Of course, ISP header pinout should only t to your circuit. Parallel port driver should
be installed with properly adjusted permissions to /dev/parport0. In troubles or for more
details refer to manual page of avrdude.
4 Hello, world!
The blinking led is the analogy to the clasicall "Hello, world!" program in the world of µCs.
The wiring is on gure 2.
There is properly decoupled µC, power supply, switch between programing/reset and oper-
ating state, standard ISP programming connector and LED diode as output device on pin 0 of the port C.
Figure 1: STK200-compatible programmmer
Here is listing of Makele. Adjust rst three lines for your project name and target µC. The
last line is command to download the project to ash. m8 refers to µC ATMEGA8, stk200
to programmer hardware and should be adjusted too. List of possible programmers can be
obtained by
avrdude -c list
Makele is here:
1 PRG = blinking_led
2 OBJ = blinking_led.o
3 MCU_TARGET = atmega8
4 OPTIMIZE = -O1
5
6 # You should not have to change anything below here.
7
8 CC = avr-gcc
9
10 # Override is only needed by avr-lib build system.
11
12 override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
13
14 OBJCOPY = avr-objcopy
15 OBJDUMP = avr-objdump
16
17 all: hex
18
19 $(PRG).elf: $(OBJ)
20 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
21
22 clean:
23 rm -rf *.o $(PRG).elf $(PRG).hex
24
25 hex: $(PRG).hex
26
27 %.hex: %.elf
28 $(OBJCOPY) -j .text -j .data -O ihex $< $@
29
30 install: load
31
32 load: $(PRG).hex
33 avrdude -p m8 -c stk200 -U flash:w:$<
By simply typing
make
the code should be compiled. Now set your circuit to programming mode by switching
reset to ISP header and by
make install
download your program to the device. When the reset is switched to the power line, the
LED has to blink with 2 second period.
There is a lot of inspiration on the net. The most required technical informations can be
found in datasheets of used devices.