im very new to Atmegas ant AVR Programming, so i hope you would forgive me this noob question: I have got this code, which runs perfectly at 1MHZ, but if i fuse the Atmega to internal 8 MHZ while changing the F_CPU Frequency to 8 MHZ as well, the LED is flashin way to fast, it seems that the C Compiler is ignoring my new Frequency. Could someone help me ;)?
#define F_CPU 8000000UL
#include <util/delay.h>
#include <avr/io.h>
int main(void)
{
while(1)
{
//TODO:: Please write your application code
/* set PC0 on PORTC (digital high) and delay for 500mS */
PORTD &= ~_BV(PD5);
_delay_ms(500);
/* PC0 on PORTC (digital 0) and delay for 500mS */
PORTD |= _BV(PD5);
_delay_ms(500);
}
}
it is compiles with these commands:
avr-gcc -g -Os -mmcu=atmega8 -c test.c
avr-gcc -g -mmcu=atmega8 -dF_CPU=8000000UL -o flash.elf test.o
avr-objcopy -j .text -j .data -O ihex flash.elf flash.hex
A BIG Thank YOU for your time and help ;) Delay.h: http://pastebin.com/wzppfma3