View previous topic :: View next topic |
Author |
Message |
balboa
Joined: 24 Mar 2015 Posts: 8 Location: Syria
|
problem concerning time cost of every instruction |
Posted: Sat Apr 25, 2015 1:35 pm |
|
|
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 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Sat Apr 25, 2015 1:48 pm |
|
|
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
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Sat Apr 25, 2015 3:37 pm |
|
|
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
|
thank you for help |
Posted: Sun Apr 26, 2015 7:49 am |
|
|
REALLY APPRECIATE IT |
|
|
mbradley
Joined: 11 Jul 2009 Posts: 118 Location: California, USA
|
|
Posted: Sun Jul 05, 2015 12:52 am |
|
|
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 |
|
|
|