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

Time loops in CCS

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



Joined: 01 Jun 2012
Posts: 13

View user's profile Send private message

Time loops in CCS
PostPosted: Sat Jun 09, 2012 9:02 am     Reply with quote

Hey, i'm looking for a way to get programs execution time in CCS if that is possible. Something like clock_t start = clock(); clock_t ends = clock(); in c++ visual, or even like ardoino's millis() function. I have been browsing the forums, and CCS manual without results.

I need to have access of the time in the pic itself, e.g not use simulation in mplab for example.
any help or pointers appreciated ,Thanks


16F886
4MHZ
CV: 4.013
temtronic



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

View user's profile Send private message

PostPosted: Sat Jun 09, 2012 10:27 am     Reply with quote

One way is to have an ISR for a timer. Every other trigger, captures the counts and sets a flag. Within 'main', test that flag, if set, display the counts, resets the flag, count, etc.
You can have a 'start flag' as well as an 'end flag' for testing.
Depending on how you setup the timer and length of 'one loop' of code, the 'counts' will tell you the time it takes. Clever coding can allow the counts to be actual us, ms or seconds.

There is an example that CCS supplies in the examples folder for a 'stopwatch' that may be of help to you.
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jun 09, 2012 12:18 pm     Reply with quote

PCM usually recommends using MPLAB It has that capability.
_________________
Google and Forum Search are some of your best tools!!!!
temtronic



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

View user's profile Send private message

PostPosted: Sat Jun 09, 2012 1:19 pm     Reply with quote

and if you're a real PICaholic.....dump the listing and count the cycles per loop.....old school..but tried and true !!
jgschmidt



Joined: 03 Dec 2008
Posts: 184
Location: Gresham, OR USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Jun 09, 2012 1:56 pm     Reply with quote

You might also look at #use timer and the get_ticks() and set_ticks() functions. I use this for longer running processes like timing how long it takes to write a file to an SD card. Be sure to check the compiler warnings to get the actual tick time.
_________________
Jürgen
www.jgscraft.com
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