Jump to content
Sign in to follow this  
moyoyoyo

time per instruction

Recommended Posts

Here is a juicy one. If you use assembler with PIC16f84 running at 4Mhz then it takes the PIC 1us (1 microsecond) to do each instruction. Some instruction take about 2us. So, if you have an application where this is important then this is a good thing to know. Now, how do I know how much time will it take the same device to do an istrcution that was written in C? What I mean is that one C instruction might be equal to 5 assembler. ???

Share this post


Link to post
Share on other sites
Guest Dave

Thats one of the prices you pay for using a high level language.

For many applications timing isn't that critcal, so you can enjoy the use of a high level languge.

 

Regards

Dave

 

:laugh:

Share this post


Link to post
Share on other sites
Guest C language and Timing Precision

Dave,

 

your information is correct but, with C language, you don't have to be concerned about instruction time. There's another ways to get a precision timer (usec timers), but i think we can't do that with the functions provided by C2C compiler.

 

Luiz Junior

Share this post


Link to post
Share on other sites
Guest Dave

Depends how precise you want to be.

 

To be as precise as you can, then you need to places those assembly level instructions carefully, and work out all the possible executions times, branches, calls or gotos all take 8 clocks when taken (on PIC), in not branching then all instructions take 4 clocks.

 

So if you are worried about timing, say a delay being precisely 16 clock cycles, then assembler is the only way.

 

If your timing requirements aren't so accurate, then you can use timers, they are good because you program can continue while the timing contniues.

 

I guess alot of this stuff depends on what you mean by accurate?

 

:cool:

 

Regard

Dave

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...