Near Type Qualifier

The __near type qualifier and the -maddrqual compiler option are used to place variables in common memory.

Some of the 8-bit PIC architectures implement data memory which can be always accessed regardless of the currently selected bank. This common memory can be used to reduce code size and execution times as the bank selection instructions that are normally required to access data in banked memory are not required when accessing the common memory. PIC18 devices refer to this memory as the access bank memory. Mid-range and Baseline devices have very small amounts of this memory, if it is present at all. PIC18 devices have substantially more common memory, but the amount differs between devices. See your device data sheet for more information.

This qualifier can be used with any variable with static storage duration, for example:

__near unsigned char fred;

This qualifier is controlled by the compiler option -maddrqual, which determines its effect (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.

The compiler must use common memory for some temporary objects. Any remaining space is available for general use. The compiler automatically places frequently accessed user-defined objects in common memory, so this qualifier is only needed for special memory placement of objects.