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

measure execution time

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



Joined: 31 Jan 2013
Posts: 63

View user's profile Send private message

measure execution time
PostPosted: Sat Jan 19, 2019 11:05 am     Reply with quote

I am trying to find the best way to measure execution time of a specific section of code.
is there any function ?
dluu13



Joined: 28 Sep 2018
Posts: 395
Location: Toronto, ON

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

PostPosted: Sat Jan 19, 2019 11:34 am     Reply with quote

Something I've done is to output high to a pin before the code and low after. Use an oscilloscope to capture the pulse on that pin, and use the cursor.
temtronic



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

View user's profile Send private message

PostPosted: Sat Jan 19, 2019 11:49 am     Reply with quote

best way ?

we all have OUR 'best way'...

I prefer to dump the listing, highlight the 'specific section of code', referenece the PIC's instruction set and then calculate the time. With 'lower end' PICs, a 4MHz xtal gives a 1us execute time per most instructions. Easy to recallculate for say a 20MHz xtal, the time will be 5 times faster.

The scope method will work but depends on how good($$$) a scope you have and IF if has been calibrated !!

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jan 19, 2019 12:58 pm     Reply with quote

The MPLAB vs. 8.92 Stopwatch feature can be used to measure how
many cycles (and microseconds) it takes to execute a block of code:
http://www.ccsinfo.com/forum/viewtopic.php?t=38351

Mplab X stopwatch:
https://www.youtube.com/watch?v=zt44UxcpUlc
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