Thanks for the reply <3,
I use internal resonator, this is the 2nd makefile:
(Come to think of it, i think you are right on the fuse bits thing, it says in the comment that its set for 8Mhz, and isnt it 1Mhz for internal? This makefile was orginally for an ATmega16 i changed the stuff to 168 :O)
PRG = sumo_v2
SRC = sumo_v2.c utils.c
MCU_TARGET = atmega168
OBJ = $(SRC:.c=.o)
OPTIMIZE = -Os
DEFS =
LIBS =
# compile of .c auto with $(CC) -c $(CPPFLAGS) $(CFLAGS)
# compile of .cpp auto with (CXX) -c $(CPPFLAGS) $(CXXFLAGS)
CC = avr-gcc
CXX = avr-g++
# Override is only needed by avr-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override CPPFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -Wl
#override LDFLAGS = -Wl,-Map,$(PRG).map
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
AVRDUDE = avrdude # for downloading
# AVRDUDE definitions; m16 is the ATmega16;
# for "bascom" programmer, use lpt1/etc; for "avrisp" programmer, use com1/etc
AVRDUDE_PART = m168
ifndef AVRDUDE_PROGRAMMER
AVRDUDE_PROGRAMMER = bascom
endif
ifndef AVRDUDE_PORT
AVRDUDE_PORT = lpt1
endif
AVRDUDE_FLAGS = -p $(AVRDUDE_PART) -c $(AVRDUDE_PROGRAMMER) -P $(AVRDUDE_PORT)
# (this is the default rule since it's first)
all: $(PRG).elf bin
#all: $(PRG).elf lst bin
clean:
rm -rf *.o $(PRG).elf *.bin
# rm -rf *.o $(PRG).elf *.lst *.map *.bin
program: $(PRG).bin
avrdude $(AVRDUDE_FLAGS) -e -U flash:w:$(PRG).bin:r
avrdude $(AVRDUDE_FLAGS) -u -U lfuse:w:0xA4:m
avrdude $(AVRDUDE_FLAGS) -u -U hfuse:w:0xD1:m
# make sure fuse bits are set for 8MHz, brown-out detect, no JTAG, no EEPROM clear
setfuse:
avrdude $(AVRDUDE_FLAGS) -u -U lfuse:w:0xA4:m
avrdude $(AVRDUDE_FLAGS) -u -U hfuse:w:0xD1:m
# rebuild the obj files if any .h changes
$(OBJ): utils.h
# binary file (to download to robot)
bin: $(PRG).bin
$(PRG).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@
# code/asm listing
lst: $(PRG).lst
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
Im going out of town today for a few days, so if i dont reply for a while, thats why