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

counter value increment time

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



Joined: 06 Sep 2017
Posts: 82

View user's profile Send private message

counter value increment time
PostPosted: Sun Apr 22, 2018 11:12 pm     Reply with quote

Hello guys my question is how much time required for each increment of counter value. for example

N=0 ;
N++ ;

How much time required for each increment of N ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Mon Apr 23, 2018 1:04 am     Reply with quote

Depends what 'N' 'is, the processor used, and the clock rate.

Look in the manual. Section 'Common questions and answers', sub-section 'How much time do math operations take'.

Nice little table, giving operation times for a number of different clock rates and processors.

If N is an int8, then the entry for addition on an int8 is what is involved. If N is an int16 then the entry for int16 applies. etc. etc.
srikrishna



Joined: 06 Sep 2017
Posts: 82

View user's profile Send private message

PostPosted: Mon Apr 23, 2018 1:48 am     Reply with quote

Can't find Section 'Common questions and answers'. Please mention the page from CCS C Compiler Manual 2018.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Mon Apr 23, 2018 2:00 am     Reply with quote

You could simulate in MPLAB SIM with a watch window and the stopwatch.
Stepping through the code will tell you for all number types.

Mike
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Mon Apr 23, 2018 3:07 am     Reply with quote

Compiler manual, not the pdf. Contents. About the thirteenth entry down.
temtronic



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

View user's profile Send private message

PostPosted: Mon Apr 23, 2018 4:44 am     Reply with quote

You could go 'old school'.
1) compile a small program, use 4MHz as the clock speed.
2) dump( print ) the listing ( programname.lst file).
3) look for the machine code that was built to execute those instructions.
4) find the 'instruction set' in the datasheet for your PIC.
5) lookup the instructions and see the time it takes.
Now PICs are great as most instructions only take 1 'cycle'. (goto and jumps take 2), it says so, in the chart ! 4MHz clock speed is 'magic' as the PIC will take clock speed/4 to execute a machine cycle, so each machine cycle takes 4MHz/4 so, 1 us to execute.

The good thing about doing it this way, is you can LEARN a LOT about PICs. You'll also see how CCS converts C into machine code !

Jay
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