View previous topic :: View next topic |
Author |
Message |
Tunfiskur
Joined: 01 Jun 2012 Posts: 13
|
Time loops in CCS |
Posted: Sat Jun 09, 2012 9:02 am |
|
|
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: 9244 Location: Greensville,Ontario
|
|
Posted: Sat Jun 09, 2012 10:27 am |
|
|
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: 1934 Location: Norman, OK
|
|
Posted: Sat Jun 09, 2012 12:18 pm |
|
|
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: 9244 Location: Greensville,Ontario
|
|
Posted: Sat Jun 09, 2012 1:19 pm |
|
|
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
|
|
Posted: Sat Jun 09, 2012 1:56 pm |
|
|
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 |
|
|
|