CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

cycle accurate timing simulation

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sapy44



Joined: 01 Feb 2004
Posts: 19
Location: Cedar Rapids, IA

View user's profile Send private message MSN Messenger

cycle accurate timing simulation
PostPosted: Thu Mar 26, 2009 12:47 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 26, 2009 2:43 pm     Reply with quote

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

View user's profile Send private message MSN Messenger

thanks
PostPosted: Mon Mar 30, 2009 9:08 am     Reply with quote

Thanks. This worked out great.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group