View Single Post
  #48   Spotlight this post!  
Unread 04-01-2005, 17:00
seanwitte seanwitte is offline
Registered User
None #0116
Team Role: Engineer
 
Join Date: Nov 2002
Location: Herndon, VA
Posts: 378
seanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant futureseanwitte has a brilliant future
Send a message via AIM to seanwitte
Re: encoder vs. motor

Quote:
Originally Posted by Astronouth7303
If the interupt fire enough, you will want to declare it volatile. ie,
Code:
/*** Variables.h ***/
volatile unsigned char MyVar = 0;

/*** MyCode.c ***/

extern volatile unsigned char MyVar;
This will cause it to not copy the value to a temporary storage location.
Correct, I forgot about about the volatile keyword. You need to swap the declarations in the two files though. The extern statement goes in .h and the declaration goes in .c.

Code:
/*** Variables.h ***/
extern volatile unsigned char MyVar;

/*** MyCode.c ***/
volatile unsigned char MyVar = 0;