View Single Post
  #3   Spotlight this post!  
Unread 21-01-2007, 22:38
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,673
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: CPU Load in FRC RC

Alright, at the very least, I can state that IF statements won't cost much programming time. The PIC isn't a pipelined processor, so you don't lose time from a branch, so it's not particularly costly. Secondly, doing a calculation in a function/subroutine incurs a fairly significant processing cost versus not doing so. This is mostly because when you call a function, the program has to build a stack saving the current processor state and possibly passing arguments so the instructions in the function can operate in a clean environment. It's not a huge hit, something on the order of 10-20 instructions depending on things, but it does take time.

Edit: X-Istence, computation time can be very very important if you're coding an interrupt service routine or other bits of code where you want things to happen very very quickly. Calling 20 different functions in an interrupt just to keep your code clean isn't a good idea at all. If you want to use functions to keep code clean, I think you can make them inline functions. An inline function basically tells the compiler to take the function and paste it into where your function is called. I'm not positive the C18 compiler supports them out of the box, but I'll look into it.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter

Last edited by Kevin Sevcik : 21-01-2007 at 22:45.