Extended Data Space (EDS) on a 16-bit PIC® MCU

Some of the PIC24 MCUs and dsPIC® Digital Signal Controller (DSC) have Extended Data Space (commonly referred to as EDS). EDS provides the device the ability to map additional memory to the upper 32 kilobytes of data memory space. EDS devices are able to map extended internal data RAM, external RAM connected through the Parallel Master Port, or blocks of Flash program memory to the upper 32 kB of data memory space.

Please consult the datasheet of the part you are using to ensure EDS is available. Accessing Flash program memory for devices without EDS can be accomplished using Program Space Visibility (PSV).

The two registers used to control EDS access are:

  • DSRPAG EDS Read Page Register
  • DSWPAG EDS Write Page Register

The value stored in the EDS registers determines which blocks of memory are mapped into address 0x8000 - 0xFFFF.

DSRPAG DSWPAG Address Referenced
in the Instruction
Effective Address Notes
0x0000 0x0000 0x0000 - 0x7FFE 0x0000 - 0x7FFFE Data Memory
0x0000 0x0000 0x8000 - 0xFFFE Invalid Address Trap Occurs

DSRPAG DSWPAG Address Referenced
in the Instruction
Effective Address Notes
0x0001 0x0001 0x8000 - 0xFFFE 0x008000 - 0x00FFFE Extended Data Memory
0x0002 0x0002 0x8000 - 0xFFFE 0x010000 - 0x017FFE Extended Data Memory
….
0x01FF 0x01FF 0x8000 - 0xFFFE 0xFF8000 - 0xFFFFFE Extended Data Memory

DSRPAG DSWPAG Address Referenced
in the Instruction
Effective Address Notes
0x0200 n/a 0x8000 - 0xFFFE 0x000000 - 0x00FFFE lower 16-bit of PM
….
0x02FF n/a 0x8000 - 0xFFFE 0x7F8000 - 0x7FFFFE lower 16-bit of PM

DSRPAG DSWPAG Address Referenced
in the Instruction
Effective Address Notes
0x0300 n/a 0x8001 - 0xFFFF 0x000001 - 0x00FFFF Upper 8-bits of PM
….
0x03FF n/a 0x8001 - 0xFFFF 0x7F8001 - 0x7FFFFF Upper 8-bits of PM

Example

The PIC24FJ256DA210 has 96 kB of data memory. Addresses 0 - 30 K are accessed by the operand contained in the instruction and with DSRPAG/DSWPAG set to 0. Memory in addresses above 30 K can be accessed through the EDS window with DSRPAG and DSWPAG set to the appropriate page value.

Putting Variables in EDS

The EDS registers are typically controlled by MPLAB® XC16 compiler directives. Variables are placed into EDS using the space or address attribute.

  • __attribute ((address(0xxxx))) will cause the compiler to place a variable at a particular address. The address may be within the virtual address space of extended data memory (0x0800 - 0x0178FE on the PIC24FJ256DA210), or within the typical data memory (0x0800 - 0x7FFE).
  • __attribute ((eds)) causes a variable to be placed in the EDS at an address selected by the compiler.

Accessing EDS Variables

The __eds__ qualifier is used in conjunction with the EDS or address attribute. The compiler will ensure the appropriate values are loaded in PSRPAG and PSWPAG before accessing variables defined with __eds__ qualifier.

eds-examples.png

MPLAB XC16 compiler will create a 32-bit pointer when the __eds__ qualifier is used during a pointer's declaration. 32-bit EDS qualified pointers are capable of being loaded with the virtual address of any operand. For the PIC24FJ256DA210, the virtual address for memory ranges from 0x0800 to 0x178FE (with all addresses above 0x8000 located in EDS memory). When accessing any variable with through an __eds__ qualified pointer, the compiler will ensure the appropriate values are loaded into PSRPAG and PSWPAG.

The following code example shows how variables can be placed into EDS. The example also shows how the program can use a pointer to access the EDS memory, thus leaving all register manipulations to the compiler.

eds-def.png

After the previous code has been run, the MPLAB X IDE's Watches window shows the following values. Note the value 0xABCD has been placed into the EDS memory location of eds_var.

eds-watch.png

 Learn More

Reading and Writing Directly to Flash
PSV
16-bit Architecture
Microchip 16-Bit MCUs

© 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.