I've a external 4Mhz Xtal. here's my test: #include void delay_ms(unsigned short ms) { unsigned short outer1, outer2; outer1 = 200; while (outer1) { outer2 = 1000; while (outer2) { while ( ms ) { ms--; asm volatile("nop"); } outer2--; } outer1--; } } int main(void){ unsigned short duration=5000; //SET OUTPUT PINS DDRD |= (1 << PD6); DDRD |= (1 << PD5); DDRD |= (1 << PD4); while (1) { PORTD |= (1 << PD6); delay_ms(duration); PORTD &= ~(1 << PD6); PORTD |= (1 << PD4); delay_ms(duration); PORTD &= ~(1 << PD4); } return 0; } And makefile: bkw@snigel:~/tmp/code$ cat Makefile MCU=atmega16 F_CPU=4000000 F_OSC=4000000 CC=avr-gcc OBJCOPY=avr-objcopy # optimize for size: CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues all: test.hex test.hex : test.out $(OBJCOPY) -R .eeprom -O ihex test.out test.hex test.out : test.o $(CC) $(CFLAGS) -o test.out -Wl,-Map,test.map test.o test.o : test.c $(CC) $(CFLAGS) -Os -c test.c #erase the AVR before it is programmed load: test.hex clean: rm -f *.o *.map *.out