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 both the __far
specifier and 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, but to be compatible with the C90 standard, it should be place after the
identifier. And 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 4.6.1.17 Ram Option.)
No checks are made for the overlap of absolute variables with other absolute variables. There is no harm in defining more than one absolute variable to live at the same address if this is what you require. 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 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.