file: http://darcs.erazor-zone.de/avr/avr-gcc/avrledtest/Makefile
MCU=atmega8 CC=avr-gcc OBJCOPY=avr-objcopy # optimize for size: CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues HEXLOAD=/usr/sbin/hexload all: avrledtest.hex avrledtest.hex : avrledtest.out $(OBJCOPY) -R .eeprom -O ihex avrledtest.out avrledtest.hex avrledtest.out : avrledtest.o $(CC) $(CFLAGS) -o avrledtest.out -Wl,-Map,avrledtest.map avrledtest.o avrledtest.o : avrledtest.c $(CC) $(CFLAGS) -Os -c avrledtest.c load: avrledtest.hex $(HEXLOAD) -I avrledtest.hex clean: rm -f *.o *.map *.out
file: http://darcs.erazor-zone.de/avr/avr-gcc/avrledtest/avrledtest.c
#include <avr/io.h> int main(void) { unsigned char w; unsigned int w2; /* enable PD5 as output */ DDRD=255; while (1) { for(w=0;w<8;w++) { PORTD=(1<<w); /* led on, pin=0 */ for (w2=0;w2<50000;w2++); for (w2=0;w2<50000;w2++); } } }
Well, the Makefile is used to compile your C-source just by typing 'make' as you can see, that will create the avrledtest.hex by executing:
$(CC) $(CFLAGS) -Os -c avrledtest.c
$(CC) $(CFLAGS) -o avrledtest.out -Wl,-Map,avrledtest.map avrledtest.o
$(OBJCOPY) -R .eeprom -O ihex avrledtest.out avrledtest.hex
Additionally you can use 'make load' for uploading your firmware to the device.
Thats quite an easy AVR program, it uses the 2 loops, the while-loop is a simple infinete loop, the next one (for-loop) is used to shift the PORD and other 2 simply slow down the whole thing.
2004-2005 © Alexander 'E-Razor' Krause