# Wzorcowy makefile DEVICE = atmega88 # jak wywołać programator AVRDUDE = avrdude -c bascom -P lpt1 -p $(DEVICE) # opcje kompilacji COMPILE = avr-gcc -Wall -Os -I. -mmcu=$(DEVICE) -DF_CPU=12000000 OBJECTS = main.o # symbolic targets: all: main.hex .c.o: $(COMPILE) -c $< -o $@ .S.o: $(COMPILE) -x assembler-with-cpp -c $< -o $@ .c.s: $(COMPILE) -S $< -o $@ # programowanie procesora flash: all $(AVRDUDE) -U flash:w:main.hex:i # odczyt fusebitów fuse_rd: $(AVRDUDE) -D -U lfuse:r:lf:b -U hfuse:r:hf:b cat lf cat hf # Fuse low byte: # 0xef = 1 1 1 0 1 1 1 1 # ^ ^ \+/ \--+--/ # | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz) # | | +--------------- SUT 1..0 (BOD enabled, fast rising power) # | +------------------ CKOUT (clock output on CKOUT pin -> disabled) # +-------------------- CKDIV8 (divide clock by 8 -> don't divide) # # Fuse high byte: # 0xdb = 1 1 0 1 1 0 1 1 # ^ ^ ^ ^ \-+-/ ^ # | | | | | +---- RSTDISBL (disable external reset -> enabled) # | | | | +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V) # | | | +-------------- WDTON (watchdog timer always on -> disable) # | | +---------------- SPIEN (enable serial programming -> enabled) # | +------------------ EESAVE (preserve EEPROM on Chip Erase -> not preserved) # +-------------------- DWEN (debug wire enable) fuse_wr: $(AVRDUDE) -D -U lfuse:w:0b10111111:m -U hfuse:w:0xdd:m clean: rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o # file targets: main.bin: $(OBJECTS) $(COMPILE) -o main.bin $(OBJECTS) main.hex: main.bin rm -f main.hex main.eep.hex avr-objcopy -j .text -j .data -O ihex main.bin main.hex disasm: main.bin avr-objdump -d main.bin cpp: $(COMPILE) -E main.c