11.3.4.1 Managed PSV Access [DD]
The compiler introduces several new qualifiers (or more specifically,
CV-qualifiers). Like a const volatile
qualifier, the new qualifiers can
be applied to objects or pointer targets. These qualifiers are:
__psv__
for accessing objects that do not cross a PSV boundary, such as those allocated inspace(auto_psv)
orspace(psv)
.__prog__
for accessing objects that may cross a PSV boundary, specifically those allocated inspace(prog)
, but it may be applied to any object in Flash.__eds__
for accessing objects that may be in Flash or the extended data space (for devices with > 32K of RAM), see__eds__
in 11.6 Extended Data Space Access [DD].
Typically there is no need to specify __psv__
or
__prog__
for an object placed in
space(auto_psv)
.
Defining a variable in a compiler managed Flash space is accomplished by:
__psv__ unsigned int Flash_variable __attribute__((space(psv)));
Reading from the variable now will cause the compiler to generate code that adjusts the appropriate PSV page SFR as necessary to access the variable correctly. These qualifiers can equally decorate pointers:
__psv__ unsigned int *pFlash;
produces a pointer to something in PSV, which can be assigned to a managed PSV object in the normal way. For example:
pFlash = &Flash_variable;