9.9.1 __psv__ Type Qualifier
The __psv__
qualifier can be applied to variables or
pointer targets that have been allocated to the program memory space. It indicates how the
variable or pointer targets will be accessed/read. Allocation of variables to the program
memory space is a separate process and is made using the space
attribute,
so this qualifier is often used in conjunction with that attribute when the variable is
defined. For example:
__psv__ unsigned int __attribute__((space(psv))) myPSVvar =
0x1234;
__psv__ char * myPSVpointer;
The pointer in this example does not use the space
attribute as it is located in data memory, but the qualifier indicates how the pointer
targets are to be accessed. For more information on the space
attribute
and how to allocate variables to the Flash memory, see the 9.10 Variable Attributes section. For basic
information on the memory layout and how program memory is accessed by the device, see the
11.1 Address Spaces section.
When variables qualified as __psv__
are read, the
compiler will manage the selection of the program memory page visible in the Data
Memory window. This means that you do not need to adjust the PSVPAG SFR
explicitly in your source code, but the generated code may be slightly less efficient than
that produced if this window was managed by hand.
The compiler will assume that any object or pointer target qualified with
__psv__
will wholly fit within a single PSV page. Such is the case for
objects allocated memory using the psv
or auto_psv
space
attribute. If this is not the case, then you should use the __prog__
qualifier (see the 9.9.2 __prog__ Type Qualifier
section) and an appropriate space attribute.