Volatile Volatiles?

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey folks,

If I make a struct containing many variables, this works fine:

struct Test
{
 int Bannana;
 uint8_t Orange;
}

If I wanted to declare it as a variable, i'd use:

struct Test Fruit;

But what about ISR struct variables? Can I just use:

volatile struct Test Fruit;

Or do I need to also declare the variables inside the struct as volatile? Like:

struct Test
{
 volatile int Bannana;
 volatile uint8_t Orange;
}

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could do both. If you only need some member of the struct to be
volatile, declare it inside the struct, otherwise declare the entire
variable to be volatile.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.