clockspeed- the meaning of #ifndef F_CPU, #define F_CPU

Status
Not open for further replies.

Nahian

Member level 3
Joined
Aug 1, 2007
Messages
64
Helped
6
Reputation
12
Reaction score
0
Trophy points
1,286
Activity points
1,604
clockspeed

hello,
what is the meaning when we write

#ifndef F_CPU
#define F_CPU 16000000UL
#endif

at begining of a program, when my µ controller is running on external or internal RC crystal of different clockspeed. Say Atmega32 running on internal 1 mhz... no fuse bit has been changed. whats the effect of writing this?[/b]
 

clockspeed

#define F_CPU is for defining clock speed of the processor.

While your micro is running at 1MHz and you are defining 16MHz make the programme run 16times slower.

Nandhu
 

    Nahian

    Points: 2
    Helpful Answer Positive Rating
Re: clockspeed

Should add that this is a program directive, not something to set fuses.

The probable reason it is being used is because somewhere in the program, there is a calculation which is dependent on the processor clock speed. This might be a delay routine or possibly setting timer values. Without it, the program would have no knowledge of the speed you are using in your hardware.

The 'UL' at the end is just to signify the value is an 'Unsigned Long' type.

Brian.
 

    Nahian

    Points: 2
    Helpful Answer Positive Rating
Re: clockspeed

thnx to both of u. I have just too many confusions about clockspeed. ya i know its not a matter of fusebit. i just wanna ensure u that me using internal oscillator of mega32.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…