Atmel CAVR-4 사용자 설명서
CAVR-4
146
Type and object attributes
AVR® IAR C/C++ Compiler
Reference Guide
DECLARING OBJECTS IN SOURCE FILES
When declaring objects, note that the IAR-specific attributes work exactly like
const
.
One exception to this is that attributes that are declared in front of the type specifier
apply to all declared objects.
apply to all declared objects.
DECLARING OBJECTS VOLATILE
There are three main reasons for declaring an object
volatile
:
●
Shared access; the object is shared between several tasks in a multitasking
environment
environment
●
Trigger access; as for a memory-mapped SFR where the fact that an access occurs
has an effect
has an effect
●
Modified access; where the contents of the object can change in ways not known to
the compiler.
the compiler.
Definition of access to volatile objects
The ISO/ANSI standard defines an abstract machine, which governs the behavior of
accesses to
accesses to
volatile
declared objects. The AVR IAR C/C++ Compiler considers each
read and write access to an object that has been declared
volatile
as an access. The
unit for the access is either the entire object or, for accesses to an element in a composite
object—such as an array, struct, class, or union—the element. For example:
object—such as an array, struct, class, or union—the element. For example:
char volatile a;
a = 5; /* A write access */
a += 6; /* First a read then a write access */
An access to a bitfield is treated as an access to the underlaying type.
Rules for accesses
Accesses to
volatile
declared objects are subject to the following rules:
1 All accesses are preserved
2 All accesses are complete, that is, the whole object is accessed
3 All accesses are performed in the same order as given in the abstract machine
4 All accesses are atomic, that is, non-interruptable.