Atmega frequency

Hi all,

I tried to find an anwser to my question in the forum, but I didn't find it !
When you use an atmega328 either with 3.3v power supply or 5v, the main frequency is either 8Mhz or 16Mhz.

is It possible to catch this information in the Software ? The aim is to use it for calculation, for example to set an appropiate value for Timers ? is there a value somewhere ?

Thanks

flylowgofastturnleft:
When you use an atmega328 either with 3.3v power supply or 5v, the main frequency is either 8Mhz or 16Mhz.

That’s not true. The frequency depends on the fuse setting and the oscillator used on the Arduino board.

With 16 Mhz the AVR controller must use a voltage in the range 4.5…5.5V, or the controller might not work correctly.

With 8 MHz the AVR controller may be operated with less voltage, i.e. 3.3V (while 5V would also be OK).

So the fuse setting and the crystal oscillator or ceramic resonator on the board decides which voltage you may use with the board.

The actual frequency for which you compiled your program is available in the F_CPU macro.
This is taken from the board setting you chose before compiling.

jurs:
That's not true. The frequency depends on the fuse setting and the oscillator used on the Arduino board.

Yes, you're right, you're more accurate, but I just want to retreive the frequency, so I will use F_CPU macro.

Is there a way to know all other macro ?

Thank you

flylowgofastturnleft:
Is there a way to know all other macro ?

If you're using the IDE, then all of the source code is presently on your computer. You could just open it up and look.

Delta_G:
You could just open it up and look.

you're not very talkative, will I have to beg for more accurate information, or you don't know the answer ?
I tried by myself, but there are thousands of files !!

flylowgofastturnleft:
you’re not very talkative, will I have to beg for more accurate information, or you don’t know the answer ?
I tried by myself, but there are thousands of files !!

There are tons of different macros in those files. You asked if there was a way to know all of them. I am not going to pour through the source code and post them all here for you if that’s what you want. If you want to see them all, then look through the source. Think about creative use of search functions on your computer and you can probably greatly reduce the amount of work.

Delta_G:
There are tons of different macros in those files. You asked if there was a way to know all of them. I am not going to pour through the source code and post them all here for you if that's what you want. If you want to see them all, then look through the source. Think about creative use of search functions on your computer and you can probably greatly reduce the amount of work.

Ok, I found F_CPU is a parameter that you give as input for avr-g++.
I'am just surprise ATMEL didn't give more detail in documentation !!

thanks for your help