Hi tj,
I don't think there is a list that shows execution times for each statement, because it depends on where the code is located in program memory, what bank the variables are in, and what size variable is being used. All the bank switching and code page changing takes time too.
However, it's pretty easy to actually measure the time it takes to execute any block of statements. This saves you from having to add them all up anyways.
Since a timer set to 1:1 prescaler uses FOSC/4, each tick represents the time it takes to execute 1 instruction cycle.
So you can simply zero the timer and then turn it on just before the statements you want to time. Then turn it off immediately after those statements. The value in the timer will indicate the number of cycles used. You can then convert that to uSeconds if needed fairly easily by multiplying * 1/(OSC*1000000/4).
Here's an example of measuring the time to do a 16/16 bit divide. But you can have any number of statements inbetween, as long as the time does not exceed 65535 instructions.@ 20Mhz, the result for this is 382 instructions or 76.4uSCode:T1CON = 0 ' Prescaler = 1:1, Timer off @ MOVE?CB OSC, _PicOSC ; Get OSC value, for Time calculation W1 var word W2 var word Dummy var word W1 = 12345 W2 = 12 ' ----- Measure Time for 16/16-bit variable divide ----- Gosub ClearTimer1: @ bsf T1CON, TMR1ON ' Start timer Dummy = W1/W2 ' The statement to measure @ bcf T1CON, TMR1ON ' Stop timer Hserout ["16/16 Var divide= "] : Gosub ShowTime STOP '---------------------------------------------------------------- PicOSC Var Byte Cycles Var Word Period Var Word Time Var Word ClearTimer1: TMR1H = 0 TMR1L = 0 Return ShowTime: Cycles.lowbyte = TMR1L Cycles.highbyte = TMR1H Period = 1000 / PicOSC * 4 / 10 ' Time for 1 Instruction Cycle in 100ns Time = Cycles * Period Time = Div32 10 Hserout [ Dec Cycles, " ",Dec Time/10, ".", Dec Time//10," uS", 13,10] Return
HTH,
Darrel




Bookmarks