4 Program Memory PDF
4 Program Memory PDF
Program Memory
HIGHLIGHTS
This section of the manual contains the following topics:
Program
Memory
Interrupt 52 Vector
Interrupt 53 Vector 00007E
Reserved 000080
User Memory
000082
Space
Interrupt 52 Vector
Interrupt 53 Vector 0000FE
000100
User Flash
Program Memory
(48K Instructions)
017FFE
018000
Reserved
(Read 0’s)
7FEFFE
800000
4
Space
Reserved
Program
8005BE
Memory
8005C0
UNITID
8005FE
800600
Reserved
F7FFFE
Device Configuration F80000
Registers F8000E
F80010
Reserved
FEFFFE
DEVID (2) FF0000
FFFFFE
Note: The address boundaries for user Flash program memory and data EEPROM memory will depend on the dsPIC30F device variant
that is selected. Refer to the appropriate device data sheet for further details.
24-bits
0x000000
User 24
Instruction
23
+1(1) Space
Latch
23
Instruction
Program Counter 0
22 0
0x7FFFFE
Figure 4-3: High and Low Address Regions for Table Operations
PC Address 23 16 8 0
0x000100 00000000
0x000102 00000000
0x000104 00000000
0x000106 00000000
Program
Memory
7 0 15 0
TBLPAG EA
24-bit EA
PC Address 23 16 8 0
0x000100 00000000
0x000102 00000000
0x000104 00000000
0x000106 00000000
TBLRDL.B (Wn<0> = 0)
TBLRDL.W
Program Memory
‘Phantom’ Byte
TBLRDL.B (Wn<0> = 1)
(Read as ‘0’)
TBLRDH.W
PC Address 23 16 8 0
0x000100 00000000
0x000102 00000000
0x000104 00000000
0x000106 00000000
TBLRDH.B (Wn<0> = 0)
Program Memory
‘Phantom’ Byte
(Read as ‘0’) TBLRDH.B (Wn<0> = 1)
Program
Memory
Program Space
0x000100
Data Space
0x0000
PSVPAG
0x01
0x8000 8 23 15 0
EA<15> = 1 0x008000
15 23
0xFFFF
0x017FFF
Upper 8 bits of Program
Memory Data cannot be
read using Program Space
Visibility. Data Read
4
23 bits
Program
Memory
Select
1 Wn
PSVPAG Reg
8 bits 15 bits
23-bit EA
Instructions that use PSV within a REPEAT loop eliminate the extra instruction cycle(s) required
for the data access from program memory, hence incurring no overhead in execution time.
However, the following iterations of the REPEAT loop will incur an overhead of two instruction
cycles to complete execution:
- The first iteration
- The last iteration
- Instruction execution prior to exiting the loop due to an interrupt
- Instruction execution upon re-entering the loop after an interrupt is serviced
Refer to Section 2. “CPU” for more information about instruction stalls using PSV.
4.5 Program Memory Writes
The dsPIC30F family of devices contains internal program Flash memory for executing user
code. There are two methods by which the user can program this memory:
1. Run-Time Self Programming (RTSP)
2. In-Circuit Serial Programming™ (ICSP™)
RTSP is accomplished using TBLWT instructions. ICSP is accomplished using the SPI interface
and integral bootloader software. Refer to Section 5. “Flash and EEPROM Programming” for
further details about RTSP. ICSP specifications can be downloaded from the Microchip
Technology web site (www.microchip.com).
int main(void)
{
// Initialize the UART1
U1MODE = 0x8000;
U1STA = 0x0000;
U1BRG = ((FCY/16)/BAUD) - 1; // set baud rate = BAUD
TXPtr = &hello[0]; // point to first char in string
U1STAbits.UTXEN = 1; // Initiate transmission
while (1)
{
while (*TXPtr) // while valid char in string ...
if (!U1STAbits.UTXBF) // and buffer not full ...
U1TXREG = *TXPtr++; // transmit string via UART
} // end main
__reset:
4
clr U1STA
mov #0x8000,W0 ; enable UART module
Program
Memory
mov W0,U1MODE
mov #BR,W0 ; set baudrate using formula value
mov W0, U1BRG ; /
bset U1STA,#UTXEN ; initiate transmission
Again:
rcall Delay500mSec ; delay for 500 mS
mov #psvpage(hello),w0
mov w0, PSVPAG
bset.b CORCONL,#PSV
mov #psvoffset(hello),w0
TxSend:
mov.b [w0++], w1 ; get char in string
cp w1,#0 ; if Null
bra Z,Again ; then re-initialize
BufferTest:
btsc U1STA,#UTXBF ; see if buffer full
bra BufferTest ; wait till empty
mov w1,U1TXREG ; load value in TX buffer
bra TxSend ; repeat for next char.
Note: Please visit the Microchip web site (www.microchip.com) for additional Application
Notes and code examples for the dsPIC30F Family of devices.
Program
Memory
NOTES: