4.8.1 Accessing Data in Program Memory
The DSC device modified-Harvard architecture is comprised of two separate address spaces: one for data storage and one for program storage. Data memory is 16 bits wide and is accessed with a 16-bit address; program memory is 24 bits wide and is accessed with a 24-bit address.
Normally, DSC instructions can read or write data values only from data memory, while program memory is reserved for instruction storage. This arrangement allows for very fast execution, since the two memory buses can work simultaneously and independently of each other. In other words, a 16-bit instruction can read, modify and write a location in data memory at the same time the next instruction is being fetched from program memory.
Occasionally, circumstances may arise when the programmer or application designer is willing to sacrifice some execution speed in return for the ability to read constant data directly from program memory. For example, certain DSP algorithms require large tables of coefficients that would otherwise consume the data memory needed to buffer real-time data. To accommodate these needs, the DSC device modified-Harvard architecture permits instructions to access data stored in program memory.
There are three methods available for accessing data in program memory:
- Table Read/Write Instructions
- PSV Data Window
- EDS Data Window
In any case, the programmer must compensate for the different address width between data memory and program memory. For example, a pointer is commonly used to access constant data tables, yet pointers for table read/write instructions can specify an address of only 16 bits. A pointer used to access the PSV data window can specify only 15 bits – the most significant bit must be set for an address in the data window range (0x8000 to 0xFFFF).
As explained in the 16-bit MCU and DSC Programmer’s Reference
Manual (DS-70000157), SFRs can be used to specify the full flash address. For a
PSV address, use PSVPAG
(or DSRPAG
for devices with EDS). For a table read/write address, use TBLPAG
. For an EDS address, use DSRPAG
.