# Clock speeds

" 16 Mhz "- What does this mean? how is this different to a 100Mhz processer?

## Comment viewing options

Thanks for the answers, More understandable than what I found on google. The whole thing made sense after I learned to program my arduino using pure C (used to use arduino language). So the higher the frequency the more instructions can be executed per second ;-), Got that now

Here is a cutout from the datasheet for the atmega328 arduino chip.

If you look at the last column for each instruction these are the clock cycles time it takes to complete that instruction.
You'll notice some take 1 cycle and others take more. At 16 MHz your atmega 328 can execute 16 million single clock cycle instructions per second. Or looking it another way your single cycle instruction takes just 62.5 nanoseconds to complete.
These are the native instructions to the processor. Known as assembly language.
When you use the arduino IDE the code you write consists of many of these instructions.
These days cpu's in computers don't simply rely on clock speed to accomplish more in less time they use a lot of other tricks you can read about on dedicated sites.
Microcontrollers are slowly following the cpu trail but for now you can safely say that the faster the clock speed of the microcontroller the more instructions it will execute in a given time.

you can not compare one 16Mhz processor to a totally different 100Mhz processor and decide one is better than the other. It really boils down to, as 6677 said, the number of instructions per cycle. I once built a computer with a 120Mhz processor. I upgraded to a 100Mhz processor and it was actually noticeably faster. It was faster because the new chip was crunching more instructions per clock cycle.

Your questions are more likely to make themselves apparent as you try to compare more similar clock speeds across different microcontrollers.

Bare in mind that these do not mean that at 16MHz the processor is completing 16000000 *instructions* per second as almost all instructions will take many cycles to complete

Only if the processor is very old or you are talking about a complex language like basic.

Using an Arduino's ATmega processor as an example. the MCU is optimised for "C" language and can complete one command per cycle,

The number of clockcycles it takes to excecute a given instruction varies highly dependant on archictecture. On the AVR, which I know best, you can roughly say it's 1.5 cycles per instruction. (on an average program)

Remember, there are differences between states, instructions, transitions, commands and operations.

On the PIC16F84A (and possibly a few more PICs besides) each assembly command is completed in 4 clock cycles. As I recall the clock I was using ran at 4MHz, equating to one command in my PIC every 1,000,000th of a second.

As you jump higher up the language ladder you lose the direct relationship unless you can see how your code compiled (an if statement with a complex comparison could cost several assembly commands).

You're right chuck. Use his numbers.

1 MHz is 1000000 cycles per second

16MHz =16000000 cycles per second

100MHz = 100000000 cycles per second