8.1 Program memory
The dsPIC30F microcontrollers have 4M 24-bit (3 bytes) program memory address space. This does not mean that the the size of the memory is 12MB (3x4M=12MB), but that is can generate 4M(4x220) different addresses.
The size of the program memory of a dsPIC30F4013 device is 16K words, i.e. 3x16K=48KB. A program can have 16K instructions less the number of auxiliary locations (interrupt table and similar).
The structure of the program memory is given in Fig.8.1 The first two locations are reserved for defining the beginning of a program. The execution of a program starts from
Fig. 8.1 Program memory of dsPIC30F4013 microcontroller
The program memory is accessible only via even addresses. An attempt to read an odd address will result in CPU trap and device reset. Interrupts and traps are described in Chapter 3.
Example:
The main program start at the location $000120. The location $000000 contains GOTO instruction, and location $000002 contains value $000120. During each reset of the device, from the location $000000 GOTO instruction is read and from the location $000002 the address is read where to jump (in this case $000120). The program starts execution from the location $000120.
After the first two locations is the interrupt vector table serving, as explained in Chapter 3, for specifying the locations where the interrupt subprograms are. It consists of 62 locations (see Chapter 3). The next two locations ($000080 and $000082) are reserved for internal purposes. Then, there is the altenative interrupt vector table with another 62 locations. At the address $000100 is the start of the space in the program memory for the main program and subprograms. The maximum address of the program space is $0007FFE (total of 16K locations). After this address is the program memory configuration space.