Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

MPLAB
®
XC16 C COMPILER
USERS GUIDE
2012-2013 Microchip Technology Inc. DS50002071C-page 143
Chapter 10. Memory Allocation and Access
10.1 INTRODUCTION
There are two broad groups of RAM-based variables: auto/parameter variables, which
are allocated to some form of stack, and global/static variables, which are positioned
freely throughout the data memory space. The memory allocation of these two groups
is discussed separately in the following sections.
Address Spaces
Variables in Data Space Memory
Variables in Program Space
Parallel Master Port Access
External Memory Access
Extended Data Space Access
Packing Data Stored in Flash
Allocation of Variables to Registers
Variables in EEPROM
Dynamic Memory Allocation
Memory Models
10.2 ADDRESS SPACES
The 16-bit devices are a combination of traditional PIC
®
Microcontroller (MCU) fea-
tures (peripherals, Harvard architecture, RISC) and new DSP capabilities (dsPIC DSC
devices). These devices have two distinct memory regions:
Program Memory contains executable code and optionally constant data.
Data Memory contains external variables, static variables, the system stack and
file registers. Data memory consists of near data, which is memory in the first 8
KB of the data memory space, and far data, which is in the upper 56 KB of data
memory space.
Although the program and data memory regions are distinctly separate, the
dsPIC30F/33F and PIC24F/H families of processors contain hardware support for
accessing data from within program Flash using a hardware feature that is commonly
called Program Space Visibility (PSV). More detail about how PSV works can be found
in device data sheets or family reference manuals. Also, see Section 10.3 Variables
in Data Space Memory and Section 14.8.2 PSV Usage with Interrupt Service
Routines.
Briefly, the architecture allows the mapping of one 32K page of Flash into the upper
32K of the data address space via the Special Function Register (SFR) PSVPAG.
Devices that support Extended Data Space (EDS) map using the DSRPAG register
instead. Also it is possible to map FLASH and other areas. See
Section 10.7 Extended Data Space Access for more details.
By default the compiler only supports direct access to one single PSV page, referred
to as the auto_psv space. In this model, 16-bit data pointers can be used. However,
on larger devices, this can make it difficult to manage large amounts of constant data
stored in Flash.

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh