Clock cycles estimation

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Clock cycles estimation

1,909 Views
jmd
Contributor I
I would like to have a file including the estimation of the execution cycles of some functions. I have several options:
-By using debug options, I can toggle pins that my application is not using after entering and before exiting, in order to measure with a scope the time a function lasts;
-Through the Hiware debugger, I could look at the cycle counter and calculate the number of cycles,
-Look into some files generated by the compiler and look for information related to the cycles in order to calculate these cycles.
 
I know that it is a bit difficult since it depends on factor like the number of iteration that a for structure could have, but I am wondering how to estimate these number of cycles.
 
Which is your recommendation?
 
Thank you and best regards!
Labels (1)
0 Kudos
5 Replies

423 Views
jmd
Contributor I
I know that you can find the clock cycles consumption of each different instruction in the datasheet. What I am looking for is a quick mechanism for estimating the clock cycles consumption that a long function could have. This way, I can make some calculations in order to know the CPU load.
 
Regarding the cicrocontroller, I am currently working with an AW60 micro, but my question is general. I am wondering if the Codewarrior includes an option in order to generate a log file or something similar that I can use to estimate the CPU consumption.
0 Kudos

423 Views
JimDon
Senior Contributor III
If you use the "disassemble" function on the right click menu it will list the number of cycles for each instruction.

0 Kudos

423 Views
JimDon
Senior Contributor III


Code:
  0000 a7f9     [2] <-- cylces            AIS   #-7   17:     volatile  byte marker=0;  0002 95       [2]             TSX     0003 7f       [4]             CLR   ,X   18:        19:     volatile word data=0xaaaa;  0004 45aaaa   [3]             LDHX  #-21846  0007 9eff02   [5]             STHX  2,SP   20:     volatile word data2=0x5555;  000a 455555   [3]             LDHX  #21845  000d 9eff04   [5]             STHX  4,SP   21:     volatile word data3=0xcccc;  0010 45cccc   [3]             LDHX  #-13108  0013 9eff06   [5]             STHX  6,SP   22:          23:     ReturnAddress = (word) &marker;   0016 95       [2]             TSX     0017 960000   [5]             STHX  ReturnAddress   24:     ReturnAddress = *((word*) (&marker +OFFSET));  001a 9efe04   [5]             LDHX  4,SP  001d 960000   [5]             STHX  ReturnAddress   25:     ReturnAddress =(word) GetMyCaller;  0020 450000   [3]             LDHX  @GetMyCaller  0023 960000   [5]             STHX  ReturnAddress   26:         27:  }  0026 a707     [2]             AIS   #7  0028 81       [6]             RTS      28:     29: 

 


0 Kudos

423 Views
allawtterb
Contributor IV


jmd wrote:
Regarding the cicrocontroller, I am currently working with an AW60 micro, but my question is general. I am wondering if the Codewarrior includes an option in order to generate a log file or something similar that I can use to estimate the CPU consumption.


It doesn't have any such feature that I am aware of.  Of the options given in your first post, I would almost always perfer using a pin on the microcontroller.  I usually have at least 1 status LED on a board and I often use this in the developement process to find the length of time routines take, the loading due to ISRs and anything else timing related.  It will add a minimum of time to a routine, and the amount of time added is known.  For a quick estimate I just disassmble the code to get a look at the assembly lines generated from each line of C.  In the end, I don't know of much anything much easier than toggling a pin and using a scope.
0 Kudos

423 Views
Rodo55
Contributor I
Hi JMD,
 
You didn't say which MCU you were working with but just about all MCU data sheets have a section that says what the bus cycles are for each instruction.
 
Download the MCU data sheet and you should find what you are looking for.
 
Hope this helps,
 
Rodo
0 Kudos