Quick Timer Question

Is the timer count increased once per instruction or clock cycle? I’ve been working on the basis that its increased once per instruction and now suddenly i’m confused :-[

This depends on the settings of the timer.
But it is always associated with the clock, not the instruction.[/edit]

It’s incremented once per machine instruction. Some assembler instructions translate to more than one machine instruction. Most C functions translate to many more than 1 assembler instruction.

What timer?
What do you mean by instruction?

Is it one machine code instruction? If so some of these take longer than a clock cycle to execute.

For a summery of them see:-
http://www.atmel.com/dyn/resources/prod_documents/2545S.pdf

so what does the mips value in datasheets refer to say 10 Million Instructions Per Second - is it the machine instruction here?

mike,

any timer in general. I was assuming that the assembly instructions were equivalent to 1 machine instruction.
:-/

It’s incremented once per machine instruction. Some assembler instructions translate to more than one machine instruction. Most C functions translate to many more than 1 assembler instruction.

Looks like you’re confusing clock cycles with instructions cycles.

I was assuming that the assembly instructions were equivalent to 1 machine instruction

Assembly instructions are generally (excluding macros) single instructions, yes, but instructions can take 1, 2 or 3 clock cycles to execute on the AVR.

The data sheet says:-

– Up to 20 MIPS Throughput at 20 MHz

So the MIPS is connected to the clock frequency.

But the Arduino only has a 16MHz clock so that would be:-

– Up to 16 MIPS Throughput for an Arduino

Then it’s the

Up to

bit, that means that some instructions take longer as AWOL said.

any timer in general

The term Timer is usually reserved for those hardware registers inside the micro normally called imaginative things like T1 and T2. These run from the clock but it can be a pre scaled clock, that is one timer increment can be every clock cycle or every 2 or every 4 or 8 and so on.

So which one is it that the timer uses to increment? :-/

Back to my original question which timer???

mike,

got it. Just that we both posted at the same time

Thanks every one.