AVR ATmega - Pre-requisites

0.Contents

1.Atmel-ICE Development tool for Debugging and Programming AVR & SAM.

Atmel-ICE Development tool for Debugging and Programming

2.Pololu USB AVR Programmer

Pololu AVR USB Programmer Pololu AVR USB Programmer

3.Fuses configuration


ATmega328 @1MHz Internal RC oscillator.

Fuses : EXTENDED = 0xFF, HIGH = 0xD1 & LOW = 0x62.


ATmega328 @8MHz Internal RC oscillator.

Fuses : EXTENDED = 0xFF, HIGH = 0xD1 & LOW = 0xE2.


ATmega328 @8MHz to 20MHz External oscillator.

Fuses : EXTENDED = 0xFF, HIGH = 0xD1 & LOW = 0xFF.

4.Makefile


This Makefile is for ATmega328 @8MHz and Pololu USB AVR Programmer.

DEVICE		= atmega328
CLOCK		= 8000000
PORT		= /dev/cu.usbmodemXXXXXXXX
PROGRAMMER	= avrispv2
RFUSES		= -U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h
WFUSES		= -U lfuse:w:0xe2:m -U hfuse:w:0xd1:m -U efuse:w:0xff:m
OBJECTS		= $(SOURCES:%.c=%.o)
SOURCES		= main.c

AVRDUDE = avrdude -F -c $(PROGRAMMER) -P $(PORT) -p $(DEVICE)
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)

all: main.hex

.c.o:
	$(COMPILE) -c $(SOURCES)

.S.o:
	$(COMPILE) -x assembler-with-cpp -c $< -o $@

main.elf: $(OBJECTS)
	$(COMPILE) -o main.elf $(OBJECTS)

main.hex: main.elf
	avr-objcopy -j .text -j .data -O ihex main.elf main.hex
	avr-size --format=avr --mcu=$(DEVICE) main.elf
	rm -f $(OBJECTS) main.o

flash: all
	$(AVRDUDE) -U flash:w:main.hex:i
	rm -f main.hex

rfuse:
	$(AVRDUDE) $(RFUSES)

wfuse:
	$(AVRDUDE) $(WFUSES)

clean:
	rm -f $(OBJECTS) main.hex main.elf

disam: main.elf
	avr-objdump -d main.elf

5.Externals Links

12.2015