On 06/10/2015 02:46 PM, Sebastian wrote:
The gcc manual [1] only mentions "memory reads or writes to items other than those listed in the input and output operands", it doesn't mention anything about volatile qualifiers.
Now I wonder if array elements, too, must be qualified "volatile" if I want to access them from an ISR (Interrupt Service Routine) and from "normal" code.
The prototypical example that explains why volatile is important is "normal" code spinning in a tight loop waiting for the ISR to write some value to an object. It doesn't matter whether or not the object is an element of an array. If the access to the object isn't volatile the normal code may never see its value change. So the volatile qualifier may not be necessary in the ISR but is is essential outside of it. A barrier in the ISR won't help. Martin