View previous topic :: View next topic |
Author |
Message |
sapy44
Joined: 01 Feb 2004 Posts: 19 Location: Cedar Rapids, IA
|
cycle accurate timing simulation |
Posted: Thu Mar 26, 2009 12:47 pm |
|
|
I believe that MPLAB can compute cycle accurate timing simulations of compiled code.
I have an application where I need tight control of program execution time between iterations inside a while loop.
Does anyone have any experience with this type of code profiling ? Can you explain how to compile CCS code and then have MPLAB profile the execution timing ? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 26, 2009 2:43 pm |
|
|
Create a CCS MPLAB project and use the MPLAB simulator.
The Stopwatch feature of MPSIM will be used to measure the number of
instruction cycles between 2 breakpoints.
Procedure:
1. Start MPLAB and load (or create) a CCS project.
2. In the Debugger menu, go to Select Tool and choose MPLAB SIM.
3. In the Debugger menu, go to Settings and set the clock frequency.
This should be the same as your #use delay() frequency. If your
frequency is 4 MHz, then just enter: 4
4. Compile your program without errors.
5. Click on the left side of the source file window, and put a breakpoint
(Red circle with a "B" inside) at the start of the code block that you
want to measure. Put another breakpoint on the line immediately
after that code block.
6. Go to the Debugger menu and click on Stopwatch. A window will
pop up. Make room for it on your screen so you can always see it.
7. In the Debugger menu, select Run. The program will run to the first
breakpoint and stop. In the Stopwatch window, the two boxes under
the label "Stopwatch" will show the number of instruction cycles and
the time that it took to reach the first breakpoint.
8. Now, finally you are ready to measure the time to execute your code
block. Press the Zero button in the Stopwatch window. This will
clear the stopwatch's instruction cycles and time.
9. Go to the Debugger menu and select Run. The program will run to
the 2nd breakpoint. The Stopwatch window will show the number of
instruction cycles and the time that it took to execute your code block. |
|
|
sapy44
Joined: 01 Feb 2004 Posts: 19 Location: Cedar Rapids, IA
|
thanks |
Posted: Mon Mar 30, 2009 9:08 am |
|
|
Thanks. This worked out great. |
|
|
|