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.