2
\$\begingroup\$

I had purchased an ATMEGA 16 microcontroller and chaged its fuse bits settings and used internal caliberated RC clock with 1000000. Changes done in make file and F_CPU. But it do nothing.

Programme for LED Blinking

#define F_CPU 1000000UL
int main(void)
 {
   DDRC=0xFF;

  while(1)
       {
        PORTC=0xFF;
   _delay_ms(1000);
    PORTC=0x00;
    _delay_ms(1000);

    }
 }

At the same time the following programme works fine.Can somebody helps me out please its urgent.....Did I forgot something to do..... These problems are same while using external 16Mhz crystal. Programme for LED Glowing.

#define F_CPU 1000000UL


int main(void)
 {
   DDRC=0xFF;

  while(1)
       {
        PORTC=0xFF;
   }
 }
\$\endgroup\$
5
\$\begingroup\$

I am surprised that this compiles at all, as you are missing two #include:

#define F_CPU 1000000UL

#include <avr/io.h>
#include <util/delay.h>

int main(void)
 {
   DDRC=0xFF;

  while(1)
       {
        PORTC=0xFF;
   _delay_ms(1000);
    PORTC=0x00;
    _delay_ms(1000);

    }
 }

Note that F_CPU must be defined before the #include - that can be done in code as shown or in the makefile.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.