I have written the code below in order to make an ATMEGA168A blink a small led:
#include <avr/io.h>
#include <util/delay.h>
#define F_CPU 1000000UL
int main(void)
{
DDRB = 0b00000010;
PORTB = 0b00000000;
while(1)
{
PORTB ^= 1 << 1;
_delay_ms(1000);
}
}
The compiler is giving me a warning as follows:
Warning #warning "F_CPU not defined for <util/delay.h>"
Here is where this warning comes from (delay.h)
#ifndef F_CPU
/* prevent compiler error by supplying a default */
# warning "F_CPU not defined for <util/delay.h>"
# define F_CPU 1000000UL
#endif
What am I doing wrong here? Is my declaration incorrect?
while(1)
anywhere except for private experimentation, that code will deadlock at some point. Its OK if you only do hobby-projects but dont get accustomed to it!