5.4.4.3 Absolute Objects In External Memory
Any object located in the PIC18's external memory can be placed at an
absolute address by using the __far
specifier along with the
__at(address)
construct.
volatile char __far mode __at(0x20100);
will
declare a variable called mode
located at address 0x20100, in the external
memory region of the PIC18 device. Note that the __at()
construct can be
placed before or after the variable identifier in the definition. As with non-absolute
__far
objects, the range of external memory that you have implemented
in your design should be specified using the -mram
option. (See Ram Option.)The compiler does not check for overlaps of absolute variables with other absolute variables. Defining more than one absolute variable at the same address is harmless if your design requires it, and no warning will be issued if the address of an absolute object lies outside the external memory defined for the device.
Absolute variables in external memory cannot be initialized when they are defined and are not cleared by the runtime startup code. After defining such variables, assign them an initial value at a suitable point in your main-line code, if required.