11.1 Address Spaces
The DSC devices are a combination of traditional PIC® Microcontroller (MCU) features (peripherals, Harvard architecture, RISC) and DSP capabilities (dsPIC DSC devices).
dsPIC33A devices have a unified memory; the rest of this sub-section does not apply to these devices.
dsPIC33C/E/F and dsPIC30F devices are modified Harvard Architecture devices with 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 dsPIC family 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. See sections 11.2 Variables In Data Space Memory and 15.7.2 PSV Usage with Interrupt Service Routines - dsPIC33C/E/F and dsPIC30 Devices Only [DD].
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. It is also possible to map Flash and other areas, see section 11.6 Extended Data Space Access [DD].
By default the compiler only supports direct access to one single PSV
page, referred to as the auto_psv
space. In this model, DSC data pointers can be used. However, on larger devices
this can make it difficult to manage large amounts of constant data stored in Flash.
The extensions presented here allow the definition of a variable as being a ‘managed’ PSV variable. This means that the compiler will manipulate both the offset (within a PSV page) and the page itself. As a consequence, data pointers must be 32 bits. The compiler will probably generate more instructions than the single PSV page model, but that is the price being paid to buy more flexibility and shorter coding time to access larger amounts of data in Flash.