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 CCS Technical Support

problem concerning time cost of every instruction

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



Joined: 24 Mar 2015
Posts: 8
Location: Syria

View user's profile Send private message

problem concerning time cost of every instruction
PostPosted: Sat Apr 25, 2015 1:35 pm     Reply with quote

hey there :
I haven't decided which PIC to work with yet but my project works in real time and I need to know how much each CCS PIC C instruction takes in time ?
help pls Sad
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sat Apr 25, 2015 1:48 pm     Reply with quote

Not possible to answer.
Do a search here, this has been discussed before.

A CCS instruction can be anything from one machine instruction, to tens of thousands. The same instruction can use different amounts of time dependent on the variables involved. Then the optimiser may change that actual code used dependent on the actual values involved.

You have to benchmark your code, either using something like MPLAB simulator, or physically using marker pulses, and a scope/logic analyser.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 25, 2015 2:51 pm     Reply with quote

How to use the Stopwatch feature of MPLAB (vs. 8.92) simulator to
find the number of instruction cycles in a segment of your program:
http://www.ccsinfo.com/forum/viewtopic.php?t=38351
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Apr 25, 2015 3:37 pm     Reply with quote

I prefer the 'old school' method where you dump the listing of your program and go though it line by line.
If you're using a 16 series PIC at 4 MHz, each instruction will take 1us. Except for jumps...
If you look at the datasheet of your PIC from Microchip, it will list all the 'opcodes' and 'cycles'.

This is a GREAT way to LEARN the workings of a microcomputer....
..probably NOT taught at ANY level of school these days as all anyone does is crank up the speed to say 64MHz and then 'time' is not a factor.

Jay
balboa



Joined: 24 Mar 2015
Posts: 8
Location: Syria

View user's profile Send private message

thank you for help
PostPosted: Sun Apr 26, 2015 7:49 am     Reply with quote

PCM programmer wrote:
How to use the Stopwatch feature of MPLAB (vs. 8.92) simulator to
find the number of instruction cycles in a segment of your program:
http://www.ccsinfo.com/forum/viewtopic.php?t=38351

REALLY APPRECIATE IT Smile
mbradley



Joined: 11 Jul 2009
Posts: 118
Location: California, USA

View user's profile Send private message Visit poster's website

PostPosted: Sun Jul 05, 2015 12:52 am     Reply with quote

I agree with temtronic, I just recently did this because I had to seriously reduce execution time down to a few cycles...

by looking at the listing, I saw I could save 4 cycles from reducing:

if (i ==4) { i = 0; }
to:
i = i & 0b0011;


As a side note, I wrapped this project up that lets me do what you need, it allows you to time functions inside your project in real time:

http://www.ccsinfo.com/forum/viewtopic.php?t=54115
_________________
Michael Bradley
www.mculabs.com
Open Drivers and Projects
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