You can probably enable assembler listing generation (I don't use Keil, but I'm sure it must be possible).
Interspersed with code, it will look like something like this:
after you click on debug in keil, a sub window will be there in background of the main program window.
main program Tab has program in C, & other Tab will be of ASM language... that will be equivalent to the C program & so we can
judge the no. of cycles for 1 instruction of C by step execution.
But I've experienced that if we have used 3 for loop (even if all of them are same !) all of them will occupy diff. no. of Machine Cycles. (Don't know why !)
thanks for replay ?
one doubt How to calculate how much cycles take each instruction ?
is it according with bit operation ? please can you explain how it ?
for example take from the picture
what is the relation between bit operation and cycles ?
You can see from your screenshot that the "P2=0x00" command was translated into two instructions: CLR A
MOV PPAGE_SFR(0x00),A
Then, you can see that the "P3=0x00" command was translated to one instruction: MOV P3(0xB0),A
You can check the microcontroller data sheet to see how many clock cycles these instructions take. Maybe it is 1 clock cycle each for a PIC (I don't know).
Then, you can check the microcontroller clock cycle period (depends on your crystal) and multiply by the number of clock cycles.
So, the P2=0x00 command took twice as long as the P3=0x00 command, because the "CLR A" instruction was used for both (it basically sets register A to zero).
A total of 3 machine instructions for the two source code lines. So, for those two source code lines, the amount of time was 1.5 machine instructions each.
Isn't there a stopwatch in Keil that you can use to move through the code while debugging and check the time taken for each instruction written? I haven't used Keil, so I don't know. But a stopwatch is present in many other IDEs.
I heard that it is possible to use logic analyzer to measure the execution time in Uvision4 . but i don't know to verify that any idea to achieve that ?
I heard that it is possible to use logic analyzer to measure the execution time in Uvision4 . but i don't know to verify that any idea to achieve that ?
I think by using a dummy variable that is changed in the program and then view that variable in the integrated logic analyzer of uvision to measure the time between the variable state changes