Microchip Technology SW006022-2N Data Sheet
MPLAB
®
XC16 C Compiler User’s Guide
DS52071B-page 136
2012 Microchip Technology Inc.
With the two major pieces of the puzzle in place, generate some variables and
accesses:
accesses:
_ _
external
_ _
unsigned char bits[NUMBER_OF_BITS]
_ _
attribute
_ _
((space(external(bit_memory))));
// inside main
__external__ unsigned char *bit;
bit = bits;
for (i = 0; i < 512; i++) {
printf("%d ",*bit++);
}
Apart from the __external__ CV-qualifiers, ordinary C statements can be used to
define and access variables in the external memory space.
define and access variables in the external memory space.
7.7
EXTENDED DATA SPACE ACCESS
Qualifying a variable or pointer target as being accessible through the extended data
space window allows you to easily access objects that have been placed in a variety of
different memory spaces. These include: space(data) (and its subsets), eds,
space(eedata)
space window allows you to easily access objects that have been placed in a variety of
different memory spaces. These include: space(data) (and its subsets), eds,
space(eedata)
, space(prog), space(psv), space(auto_psv), and on some
devices space(pmp). Not all devices support all memory spaces.
To use this feature:
• declare an object in an appropriate memory space
• qualify the object with the __eds__ qualifier
For example:
__eds__ int var_a __attribute__((space(prog)));
__eds__ int var_b [10] __attribute__((
eds
));
__eds__ int *var_c;
__eds__ int *__eds__ *var_d __attribute__((space(psv)));
var_a
- declares an int in Flash that is automatically accessed
var_b
- declares an array of ints, located in eds; the elements of the array are auto-
matically accessed
var_c
- declares a pointer to an int, where the destination may exist in any one of the
memory spaces supported by Extended Data Space pointers and will be automatically
accessed upon dereference; the pointer itself must live in a normal data space
accessed upon dereference; the pointer itself must live in a normal data space
var_d
- declares a pointer to an int, where the destination may exist in any one of the
memory spaces supported by Extended Data Space pointers and will be automatically
accessed upon dereference; the pointer value exists in Flash and is also automatically
accessed.
accessed upon dereference; the pointer value exists in Flash and is also automatically
accessed.
The compiler will automatically assert the page attribute to scalar variable declarations;
this allows the compiler to generate more efficient code when accessing larger data
types. Remember, scalar variables do not include structures or arrays. To force paging
of a structure or array, please manually use the page attribute and the compiler will
prevent the object from crossing a page boundary.
this allows the compiler to generate more efficient code when accessing larger data
types. Remember, scalar variables do not include structures or arrays. To force paging
of a structure or array, please manually use the page attribute and the compiler will
prevent the object from crossing a page boundary.
For read access to __eds__ qualified variables, the compiler will automatically manip-
ulate the PSVPAG or DSRPAG register as appropriate. For devices that support
extended data space memory, the compiler will also manipulate the DSWPAG register.
ulate the PSVPAG or DSRPAG register as appropriate. For devices that support
extended data space memory, the compiler will also manipulate the DSWPAG register.
Note:
Some devices use DSRPAG to represent extended read access to FLASH
or the extended data space (EDS)
or the extended data space (EDS)