Quote:
|
Originally Posted by Pattyta
would this code work u think??
|
You can make counter local to this routine. Nowhere else does it have to be seen.
I might add an initialization for counter, e.g.,
Code:
void User_Autonomous_Code(void)
{
unsigned int counter=0;
...
while (autonomous_mode) /* DO NOT CHANGE! */
[edit] The following is not germane to this case you should just be aware of the pitfall.
Even if you initialized counter when you declare it, e.g., static unsigned int counter=0; You'll have trouble during the practice sessions when you run twice in a row. You'd have to be sure to reset the RC between runs. Explicitly setting it before the auto loop avoids this potential pitfall.
[edit]
Actually "static" isn't required in this case, since you never leave the routine. I only tend to use it as a matter of convention (Our functions aren't written to take control away from the main loop).
You can in this case declare "unsigned int counter=0;" in the
local routine and be fine. I still prefer explicit initialization though.