ATmega168 runs on 16MHz???

Hi !

I have just finished the library for PING sensor and I've got the measurement of the distance very accurate! It took me some time, but it was worth of it.
So, My problem was that I received the wrong distance measurement, although my algorithm seemed to be good. So, in my algorithm the sound speed is constant, the distance is constant and the only remaining factor that influences my calculation is time. (in my case)Time is derived from the system clock and 64 prescaled. So, the documentation says that ATmega168 runs on 20MHz. My tick lasts 64/20000000...easy to count the time.

Back again: I tried to solve the problem and...the sensor works perfectly if the frequency is 16MHz!!!

Do We use the ATmega168 on 16MHz? Is It possible at all to "slow down" the processor according to what we need?

Please answer, cause it confuses me a bit:)

Thank's a lot,

Vladimir

The 168 runs at speeds up to 20MHz, but the actual frequency is determined by the crystal (if it's configured to use a crystal, and the Arduino is so configured).

Take a look at the crystal, but I think the mega168 Arduinos are still at 16MHz.

-j

All the Arduino boards use a 16 MHz clock (even though as kg4wsv said the ATmega168 supports up to 20 MHz). Having them all the makes the software much simpler.

Hi!
Thanks a lot...but, I am not sure where can I check the information...somehow, I miss the documentation about arduino...like, by default which mode is used and which timer is used for what (if at all!)and so on...
So, if you could suggest me sth, it would be very useful. And, also about the crystal, where can I check if arduino runs on 16MHz....

Thakns a lot,

Vladimir

Very nice!

So, all arduinos run on 16MHz. I guessed, cause that makes the code be portable between different arduino configurations...
Nice, bu still, if somebody could give me some reference about arduino documentation...would be nice.

cheers!

Vladimir

Check out the Arduino schematic: http://www.arduino.cc/en/uploads/Main/arduino_NG_schematic.png linked to from the Arduino hardware page: http://www.arduino.cc/en/Main/Hardware.

The timers aren't currently exposed to users of Arduino so their configuration isn't documented. If you want to dig in and see how they're being used, just take a peek at the source code - it comes with every copy of the Arduino software (in lib/targets/arduino) and should be relatively readable.

I saw shematics already, but thanks for source code informations. I will have a look for sure:)

Cheers,

V.