hi example: if i start a main function with a var A = 0 and let it add one every cycle: main(){ int A = 0; A++; } @ atmega 8 with 3.6mhz is 2.7 *10^-7 sec. when there is no interrupt and i stop after eg. 10 cycles, is there A=10??
First of all, unless A is declared volatile (http://en.wikipedia.org/wiki/Volatile_variable), the compiler will probably remove your code altogether, since it has no effect. Assuming you meant
1 | while(1) { A++; } |
you won't get one increment per cycle, because the increment and jump instruction together take more than one cycle.
:
Edited by Admin
yeah thats exactly what i wanna know. does every command use one cycle?
michael wrote: > does every command use one cycle? Hello Michael, you wanna look up the assembler listing of your code to find out what the compiler generated. After that you wanna look up the datasheet of the prcessor to find out how many (machine-) cycles each instruction requires, including the loop back. That gives you a exact numer of clock cycles required and therefore the exact time required for execution. rgds
Hi Michael, to be sure, you have to disassemble your compiled code, cause there are many assembler instructions which needs more than one cycle e.g. RET needs 5 cycles (just take a look at the data sheet, Chapter "Instruction Summary"). Regards, René
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.