The __far
type qualifier and the
-maddrqual
compiler option are used to place variables into external
memory.
Some PIC18 devices can support external memory. If your hardware supports
this, you must first specify this memory with the-mram
option (see Ram Option). For
example, to map additional data memory from 20000h to 2FFFFh use
-mram=default,+20000-2FFFF.
Memory added to the RAM ranges is exclusively used by variables that are
qualified __far
. Access of external memory is less efficient than that of
ordinary data memory and will be slower to execute and use more code. Here is an example of
an unsigned int
object placed into the device’s external program memory
space:
__far unsigned int farvar;
This qualifier is controlled by the compiler option
-maddrqual
, which determines its effect on PIC18 devices (see Addrqual Option). Based on this
option’s settings, this qualifier can be binding or ignored (which is the default
operation). Qualifiers which are ignored will not produce an error or warning, but will
have no effect.
Note that this qualifier will be ignored when compiling for PIC10/12/16 targets and that not all PIC18 devices support external memory.