How do I place variables in EDS space using MPLAB® XC16?

The upper 32 kB of data memory address space (0x8000-0xFFFF) is used as an Extended Data Space (EDS).


The EDS includes any additional internal data memory not accessible by the lower 32 kB of data address space and any external memory accessible through enhanced PMP. EDS is organized as pages, with a single page called an EDS page (greater than 32 kB) An EDS page is selected through the Data Space Read register DSRPAG or Data Space Write register DSWPAG.

To declare a variable in EDS use the space(eds) attribute.

__eds__   int    var_b [10]    __attribute__((space(eds)));
__eds__   int    var_d [10]    __attribute__(((eds ));

Arrays var_b and var_d are eligible for allocation in data space greater than 32 kB. The __eds__ qualifier indicates that the qualified object is in an EDS accessible memory and that the compiler should manage the registers appropriately to access this memory.
The compiler will automatically manipulate the PSVPAG or DSRPAG register as appropriate. For devices that support extended data space memory, the compiler will also manipulate the DSWPAG register.

For more on EDS space access, refer to the “EXTENDED DATA SPACE ACCESS” section of the “MPLAB® XC16 C Compiler User's Guide”.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.