View Single Post
  #2   Spotlight this post!  
Unread 17-02-2005, 17:38
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Global Struct Arrays and Interrupts

That's 5 questions.
Quote:
Originally Posted by Orborde
My question, then, is whether I need to disable interrupts when I want to write to goal_velocity?
Can I just declare the array as volatile, as shown below, or does that only act on the pointer?
Could I throw in an extra "volatile" or two in the array definition to make goal_velocity safe to fiddle with without disabling interrupts?
Or is it imperative that I disable interrupts before reading/writing goal_velocity?
In order: Yes. The former. Not necessary. No.

Volatile only means that the value cannot be "cached" by the processor. The compiler will assume that the value will change every time you use it.

Quote:
Originally Posted by Orborde
Where do I declare it, and how?
Easy. You make a header that contains the macros. In the same header, add the following code:
Code:
extern volatile drivemotor motors[NUM_MOTORS];
Then include that header where ever you reference it.