12.5.1 Declare a New Memory Space

This is very similar to declaring a new memory space for PMP access.

The 16-bit toolsuite requires information about each external memory. In order for 16-bit device linker to be able to properly assign memory, information about the size of memory available and, optionally the origin of the memory, needs to be provided.

In Differences Between MPLAB XC16 and ANSI C the external memory space was introduced. This attribute serves two purposes: declaring extended memory spaces and assigning C variable declarations to external memory (this will be covered in the next subsection).

Declaring an extended memory requires providing the size of the memory. You may optionally specify an origin for this memory; if none is specified 0x0000 will be assumed.

extern int external_memory

__attribute__((space(external(size(1024)))));

Above an external memory of size 1024 bytes is defined. This memory can be uniquely identified by its given name of external_memory.