# makefile, written by guido socher # downloaded from http://linuxfocus.org/English/November2004/article352.shtml # modified 2005-02-16 by Henrik Björkman to fit my application HEADER_FILES=avr_cfg.h avr_uart.h avr_tmr0.h OBJECT_FILES=havrapp.o avr_uart.o avr_tmr0.o # Change here if you have another atmega microcontroller (MCU) MCU=atmega88 #MCU=atmega8 # Some generic macros CC=avr-gcc OBJCOPY=avr-objcopy # optimize for size: CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues #------------------- all: havrapp.hex #------------------- help: @echo "Usage: make [all]|load|load_pre|rdfuses|wrfuse1mhz|wrfuse4mhz|wrfuse8mhz|wrfusecrystal" @echo "Warning: you will not be able to undo wrfusecrystal unless you connect an" @echo " external crystal! uC is dead after wrfusecrystal if you do not" @echo " have an external crystal." #------------------- havrapp.hex : havrapp.out $(OBJCOPY) -R .eeprom -O ihex havrapp.out havrapp.hex havrapp.out : $(OBJECT_FILES) $(CC) $(CFLAGS) -o havrapp.out -Wl,-Map,havrapp.map $(OBJECT_FILES) # you need to erase first before loading the program. # this will erase and then write the software into the eeprom: load: havrapp.hex uisp -dlpt=/dev/parport0 --erase -dprog=dapa uisp -dlpt=/dev/parport0 --upload if=havrapp.hex -dprog=dapa -v=3 --hash=32 #------------------- # fuse byte settings: # Atmel AVR ATmega8 # Fuse Low Byte = 0xe1 (1MHz internal), 0xe3 (4MHz internal), 0xe4 (8MHz internal) # Fuse High Byte = 0xd9 # Factory default is 0xe1 for low byte and 0xd9 for high byte # Check this with make rdfuses rdfuses: uisp -dlpt=/dev/parport0 -dprog=dapa --rd_fuses # use internal RC oscillator 1 Mhz wrfuse1mhz: uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_l=0xe1 # use internal RC oscillator 4 Mhz wrfuse4mhz: uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_l=0xe3 # use internal RC oscillator 8 Mhz wrfuse8mhz: uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_l=0xe4 # use external 3-8 Mhz crystal # Warning: you can not reset this to intenal unless you connect a crystal!! wrfusecrystal: uisp -dlpt=/dev/parport0 -dprog=dapa --wr_fuse_l=0xee #------------------- clean: rm -f *.o *.map *.out *.hex #-------------------