Section 2. CPU: Highlights
Section 2. CPU: Highlights
CPU
Section 2. CPU
HIGHLIGHTS
This section of the manual contains the following topics: 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.13 Introduction .................................................................................................................... 2-2 Programmers Model...................................................................................................... 2-4 Software Stack Pointer................................................................................................... 2-8 CPU Register Descriptions .......................................................................................... 2-11 Arithmetic Logic Unit (ALU).......................................................................................... 2-17 DSP Engine ................................................................................................................. 2-18 Divide Support ............................................................................................................. 2-27 Instruction Flow Types ................................................................................................. 2-27 Loop Constructs........................................................................................................... 2-30 Address Register Dependencies ................................................................................. 2-35 Register Maps.............................................................................................................. 2-38 Related Application Notes............................................................................................ 2-41 Revision History ........................................................................................................... 2-42
DS70049D-page 2-1
DS70049D-page 2-2
Section 2. CPU
Figure 2-1 shows a block diagram of the CPU. Figure 2-1: dsPIC30F CPU Core Block Diagram
2
CPU
X Address Bus Y Data Bus X Data Bus 16 Interrupt Controller PSV & Table Data Access 24 Control Block 24 24 16 16 16 Data Latch X Data RAM (4 Kbytes) Address Latch 16
16
16
16
Address Latch Program Memory (144 Kbytes) Data EEPROM (4 Kbytes) Data Latch 16
PCU PCH PCL Program Counter Loop Stack Control Control Logic Logic
16
16 X RAGU X WAGU
Y AGU
16 ROM Latch
EA MUX
16 IR Literal Data
16
24
16
16 x 16 W Reg Array Instruction Decode & Control Control Signals to Various Blocks OSC1/CLKI Timing Generation 16 16 Divide Support
16
Power-up Timer Oscillator Start-up Timer POR/BOR Reset MCLR Watchdog Timer Low Voltage Detect
DSP Engine
16-bit ALU 16 16
CAN1, CAN2
I2C
I/O Ports
Timers
DCI
SPI1, SPI2
UART1, UART2
DS70049D-page 2-3
Register(s) Name W0 through W15 ACCA, ACCB PC SR SPLIM TBLPAG PSVPAG RCOUNT DCOUNT DOSTART DOEND CORCON
In addition to the registers contained in the programmers model, the dsPIC30F contains control registers for modulo addressing, bit-reversed addressing and interrupts. These registers are described in subsequent sections of this document. All registers associated with the programmers model are memory mapped, as shown in Table 2-8.
DS70049D-page 2-4
Section 2. CPU
Figure 2-2: Programmers Model
15 0 W0 (WREG) W1 W2 W3 W4 DSP Operand Registers W5 W6 W7 W8 DSP Address Registers W9 W10 W11 PUSH.S and POP.S Shadows W12 W13 Frame Pointer/W14 0 Stack Ptr/W15 SPLIM 39 DSP Accumulators 22 ACCA ACCB ACCAU ACCBU 31 ACCAH ACCBH 0 0 7 TBLPAG 7 PSVPAG 15 RCOUNT 15 DCOUNT 22 DOSTART 22 DOEND SRH SB OAB SAB DA SRL DC IPL<2:0> 15 CORCON RA N OV 0 Core Control Register SZ C Status Register 0 0 0 0 DO Loop Start Address 0 DO Loop Counter 0 REPEAT Loop Counter 0 0 Data Table Page Address Program Space Visibility Page Address 0 15 ACCAL ACCBL Stack Pointer Limit 0 Working/Address Registers
2
CPU
Program Counter
OA
OB
SA
Note:
DCOUNT, DOSTART and DOEND have one level of shadow registers (not shown) for nested DO loops.
DS70049D-page 2-5
W0 and File Register Instructions W0 is a special working register because it is the only working register that can be used in file register instructions. File register instructions operate on a specific memory address contained in the instruction opcode and W0. W1-W15 cannot be specified as a target register in file register instructions. The file register instructions provide backward compatibility with existing PIC devices which have only one W register. The label WREG is used in the assembler syntax to denote W0 in a file register instruction. For example: MOV ADD Note: WREG,0x0100 0x0100,WREG ; move contents of W0 to address 0x0100 ; add W0 to address 0x0100, store in W0
For a complete description of Addressing modes and instruction syntax, please refer to the dsPIC30F Programmers Reference Manual (DS70157).
2.2.1.2
W Register Memory Mapping Since the W registers are memory mapped, it is possible to access a W register in a file register instruction as shown below: MOV 0x0004, W10 ; equivalent to MOV W2, W10 where 0x0004 is the address in memory of W2. Further, it is also possible to execute an instruction that will attempt to use a W register as both an address pointer and operand destination. For example: MOV where: W1 = 0x1234 W2 = 0x0004 ;[W2] addresses W2 W1,[W2++]
In the example above, the contents of W2 are 0x0004. Since W2 is used as an address pointer, it points to location 0x0004 in memory. W2 is also mapped to this address in memory. Even though this is an unlikely event, it is impossible to detect until run-time. The dsPIC30F ensures that the data write will dominate, resulting in W2 = 0x1234 in the example above. 2.2.1.3 W Registers and Byte Mode Instructions Byte instructions which target the W register array only affect the Least Significant Byte of the target register. Since the working registers are memory mapped, the Least and Most Significant Bytes can be manipulated through byte wide data memory space accesses.
2.2.2
Shadow Registers
Many of the registers in the programmers model have an associated shadow register as shown in Figure 2-2. None of the shadow registers are accessible directly. There are two types of shadow registers: those utilized by the PUSH.S and POP.S instructions and those utilized by the DO instruction.
DS70049D-page 2-6
Section 2. CPU
2.2.2.1 PUSH.S and POP.S Shadow Registers The PUSH.S and POP.S instructions are useful for fast context save/restore during a function call or Interrupt Service Routine (ISR). The PUSH.S instruction will transfer the following register values into their respective shadow registers: W0...W3 SR (N, OV, Z , C, DC bits only) The POP.S instruction will restore the values from the shadow registers into these register locations. A code example using the PUSH.S and POP.S instructions is shown below: MyFunction: PUSH.S MOV ADD BTSC BSET POP.S RETURN ; #0x03,W0 ; RAM100 ; SR,#Z ; Flags,#IsZero ; ; Save W registers, MCU status load a literal value into W0 add W0 to contents of RAM100 is the result 0? Yes, set a flag Restore W regs, MCU status
2
CPU
The PUSH.S instruction will overwrite the contents previously saved in the shadow registers. The shadow registers are only one level in depth, so care must be taken if the shadow registers are to be used for multiple software tasks. The user must ensure that any task using the shadow registers will not be interrupted by a higher priority task that also uses the shadow registers. If the higher priority task is allowed to interrupt the lower priority task, the contents of the shadow registers saved in the lower priority task will be overwritten by the higher priority task. 2.2.2.2 DO Loop Shadow Registers The following registers are automatically saved in shadow registers when a DO instruction is executed: DOSTART DOEND DCOUNT The DO shadow registers are one level in depth, permitting two loops to be automatically nested. Refer to Section 2.9.2.2 DO Loop Nesting for further details.
2.2.3
DS70049D-page 2-7
W15 is initialized to 0x0800 during all Resets. This address ensures that the stack pointer (SP) will point to valid RAM in all dsPIC30F devices and permits stack availability for non-maskable trap exceptions, which may occur before the SP is initialized by the user software. The user may reprogram the SP during initialization to any location within the data space. The stack pointer always points to the first available free word and fills the software stack working from lower towards higher addresses. It pre-decrements for a stack pop (read) and postincrements for a stack push (writes), as shown in Figure 2-3. When the PC is pushed onto the stack, PC<15:0> is pushed onto the first available stack word, then PC<22:16> is pushed into the second available stack location. For a PC push during any CALL instruction, the MSByte of the PC is zero-extended before the push as shown in Figure 23. During exception processing, the MSByte of the PC is concatenated with the lower 8 bits of the CPU status register, SR. This allows the contents of SRL to be preserved automatically during interrupt processing. Figure 2-3: Stack Operation for a CALL Instruction 15 Stack Grows Towards Higher Address 0
CALL
SUBR
DS70049D-page 2-8
Section 2. CPU
2.3.1 Software Stack Examples
The software stack is manipulated using the PUSH and POP instructions. The PUSH and POP instructions are the equivalent of a MOV instruction with W15 used as the destination pointer. For example, the contents of W0 can be pushed onto the stack by: PUSH W0 This syntax is equivalent to: MOV W0,[W15++] The contents of the top-of-stack can be returned to W0 by: POP W0 This syntax is equivalent to: MOV [--W15],W0 Figure 2-4 through Figure 2-7 show examples of how the software stack is used. Figure 2-4 shows the software stack at device initialization. W15 has been initialized to 0x0800. Furthermore, this example assumes the values 0x5A5A and 0x3636 have been written to W0 and W1, respectively. The stack is pushed for the first time in Figure 2-5 and the value contained in W0 is copied to the stack. W15 is automatically updated to point to the next available stack location (0x0802). In Figure 2-6, the contents of W1 are pushed onto the stack. In Figure 2-7, the stack is popped and the top-of-stack value (previously pushed from W1) is written to W3. Figure 2-4: Stack Pointer at Device Reset 0x0000 W15 0x0800
2
CPU
0xFFFE W15 = 0x0800 W0 = 0x5A5A W1 = 0x3636 Figure 2-5: Stack Pointer After the First PUSH Instruction 0x0000 W15 0x5A5A 0x0800 0x0802 PUSH W0
0xFFFE W15 = 0x0802 W0 = 0x5A5A W1 = 0x3636 Figure 2-6: Stack Pointer After the Second PUSH Instruction 0x0000 0x5A5A 0x3636 0x0800 0x0802 0x0804 0xFFFE W15 = 0x0804 W0 = 0x5A5A W1 = 0x3636 PUSH W1
W15
DS70049D-page 2-9
2.3.2
2.3.3
If stack overflow checking has been enabled, a stack error trap will also occur if the W15 effective address calculation wraps over the end of data space (0xFFFF). Note: A write to the Stack Pointer Limit register, SPLIM, should not be followed by an indirect read operation using W15.
Refer to Section 6. Reset Interrupts for more information on the stack error trap.
2.3.4
DS70049D-page 2-10
Section 2. CPU
2.4 2.4.1 CPU Register Descriptions SR: CPU Status Register
2
CPU
The dsPIC30F CPU has a 16-bit status register (SR), the LSByte of which is referred to as the lower status register (SRL). The upper byte of SR is referred to as SRH. A detailed description of SR is shown in Register 2-1. SRL contains all the MCU ALU operation status flags, plus the CPU interrupt priority status bits, IPL<2:0> and the REPEAT loop active status bit, RA (SR<4>). During exception processing, SRL is concatenated with the MSByte of the PC to form a complete word value, which is then stacked. SRH contains the DSP Adder/Subtractor status bits, the DO loop active bit, DA (SR<9>) and the Digit Carry bit, DC (SR<8>). The SR bits are readable/writable with the following exceptions: 1. 2. 3. 4. The DA bit (SR<8>): DA is a read only bit. The RA bit (SR<4>): RA is a read only bit. The OA, OB (SR<15:14>) and OAB (SR<11>) bits: These bits are read only and can only be modified by the DSP engine hardware. The SA, SB (SR<13:12>) and SAB (SR<10>) bits: These are read and clear only and can only be set by the DSP engine hardware. Once set, they remain set until cleared by the user, irrespective of the results from any subsequent DSP operations. Note: Note: Clearing the SAB bit will also clear both the SA and SB bits. A description of the SR bits affected by each instruction is provided in the dsPIC30F Programmers Reference Manual (DS70157).
2.4.2
DS70049D-page 2-11
R/W-0(2)
R-0 RA
R/W-0 N
R/W-0 OV
R/W-0 Z
R/W-0 C bit 0
OA: Accumulator A Overflow Status bit 1 = Accumulator A overflowed 0 = Accumulator A has not overflowed OB: Accumulator B Overflow Status bit 1 = Accumulator B overflowed 0 = Accumulator B has not overflowed SA: Accumulator A Saturation Sticky Status bit 1 = Accumulator A is saturated or has been saturated at some time 0 = Accumulator A is not saturated Note: This bit may be read or cleared (not set). SB: Accumulator B Saturation Sticky Status bit 1 = Accumulator B is saturated or has been saturated at some time 0 = Accumulator B is not saturated Note: This bit may be read or cleared (not set). OAB: OA || OB Combined Accumulator Overflow Status bit 1 = Accumulators A or B have overflowed 0 = Neither Accumulators A or B have overflowed SAB: SA || SB Combined Accumulator Sticky Status bit 1 = Accumulators A or B are saturated or have been saturated at some time in the past 0 = Neither Accumulator A or B are saturated Note: This bit may be read or cleared (not set). Clearing this bit will clear SA and SB. DA: DO Loop Active bit 1 = DO loop in progress 0 = DO loop not in progress DC: MCU ALU Half Carry/Borrow bit 1 = A carry-out from the 4th low order bit (for byte-sized data) or 8th low order bit (for word-sized data) of the result occurred 0 = No carry-out from the 4th low order bit (for byte-sized data) or 8th low order bit (for word-sized data) of the result occurred
bit 14
bit 13
bit 12
bit 11
bit 10
bit 9
bit 8
DS70049D-page 2-12
Section 2. CPU
Register 2-1: bit 7-5 SR: CPU Status Register (Continued)
2
CPU
IPL<2:0>: CPU Interrupt Priority Level Status bits(1) 111 = CPU Interrupt Priority Level is 7 (15). User interrupts disabled. 110 = CPU Interrupt Priority Level is 6 (14) 101 = CPU Interrupt Priority Level is 5 (13) 100 = CPU Interrupt Priority Level is 4 (12) 011 = CPU Interrupt Priority Level is 3 (11) 010 = CPU Interrupt Priority Level is 2 (10) 001 = CPU Interrupt Priority Level is 1 (9) 000 = CPU Interrupt Priority Level is 0 (8) Note 1: The IPL<2:0> bits are concatenated with the IPL<3> bit (CORCON<3>) to form the CPU Interrupt Priority Level. The value in parentheses indicates the IPL if IPL<3> = 1. User interrupts are disabled when IPL<3> = 1. 2: The IPL<2:0> status bits are read only when NSTDIS = 1 (INTCON1<15>).
bit 4
RA: REPEAT Loop Active bit 1 = REPEAT loop in progress 0 = REPEAT loop not in progress N: MCU ALU Negative bit 1 = Result was negative 0 = Result was non-negative (zero or positive) OV: MCU ALU Overflow bit This bit is used for signed arithmetic (2s complement). It indicates an overflow of the magnitude which causes the sign bit to change state. 1 = Overflow occurred for signed arithmetic (in this arithmetic operation) 0 = No overflow occurred Z: MCU ALU Zero bit 1 = An operation which effects the Z bit has set it at some time in the past 0 = The most recent operation which effects the Z bit has cleared it (i.e., a non-zero result) C: MCU ALU Carry/Borrow bit 1 = A carry-out from the Most Significant bit of the result occurred 0 = No carry-out from the Most Significant bit of the result occurred Legend: R = Readable bit C = Clear only bit 1 = Bit is set W = Writable bit S = Set only bit 0 = Bit is cleared U = Unimplemented bit, read as 0 -n = Value at POR x = Bit is unknown
bit 3
bit 2
bit 1
bit 0
DS70049D-page 2-13
R/W-0 SATB
R/W-1 SATDW
R/W-0 ACCSAT
R/C-0 IPL3
R/W-0 PSV
R/W-0 RND
R/W-0 IF bit 0
bit 15-13 Unimplemented: Read as '0 bit 12 US: DSP Multiply Unsigned/Signed Control bit 1 = DSP engine multiplies are unsigned 0 = DSP engine multiplies are signed EDT: Early DO Loop Termination Control bit 1 = Terminate executing DO loop at end of current loop iteration 0 = No effect Note: bit 10-8 This bit will always read as 0. DL<2:0>: DO Loop Nesting Level Status bits 111 = 7 DO loops active 001 = 1 DO loop active 000 = 0 DO loops active SATA: AccA Saturation Enable bit 1 = Accumulator A saturation enabled 0 = Accumulator A saturation disabled SATB: AccB Saturation Enable bit 1 = Accumulator B saturation enabled 0 = Accumulator B saturation disabled SATDW: Data Space Write from DSP Engine Saturation Enable bit 1 = Data space write saturation enabled 0 = Data space write saturation disabled ACCSAT: Accumulator Saturation Mode Select bit 1 = 9.31 saturation (super saturation) 0 = 1.31 saturation (normal saturation) IPL3: CPU Interrupt Priority Level Status bit 3 1 = CPU interrupt priority level is greater than 7 0 = CPU interrupt priority level is 7 or less Note: The IPL3 bit is concatenated with the IPL<2:0> bits (SR<7:5>) to form the CPU interrupt priority level.
bit 11
bit 7
bit 6
bit 5
bit 4
bit 3
DS70049D-page 2-14
Section 2. CPU
Register 2-2: bit 2 CORCON: Core Control Register (Continued)
2
CPU
PSV: Program Space Visibility in Data Space Enable bit 1 = Program space visible in data space 0 = Program space not visible in data space RND: Rounding Mode Select bit 1 = Biased (conventional) rounding enabled 0 = Unbiased (convergent) rounding enabled IF: Integer or Fractional Multiplier Mode Select bit 1 = Integer mode enabled for DSP multiply ops 0 = Fractional mode enabled for DSP multiply ops Legend: R = Readable bit -n = Value at POR W = Writable bit 1 = Bit is set U = Unimplemented bit, read as 0 0 = Bit is cleared C = Bit can be cleared x = Bit is unknown
bit 1
bit 0
DS70049D-page 2-15
DS70049D-page 2-16
Section 2. CPU
2.5 Arithmetic Logic Unit (ALU)
The dsPIC30F ALU is 16-bits wide and is capable of addition, subtraction, single bit shifts and logic operations. Unless otherwise mentioned, arithmetic operations are 2s complement in nature. Depending on the operation, the ALU may affect the values of the Carry (C), Zero (Z), Negative (N), Overflow (OV) and Digit Carry (DC) status bits in the SR register. The C and DC status bits operate as a Borrow and Digit Borrow bits, respectively, for subtraction operations. The ALU can perform 8-bit or 16-bit operations, depending on the mode of the instruction that is used. Data for the ALU operation can come from the W register array or data memory depending on the Addressing mode of the instruction. Likewise, output data from the ALU can be written to the W register array or a data memory location. Refer to the dsPIC30F Programmers Reference Manual (DS70157) for information on the SR bits affected by each instruction, Addressing modes and 8-bit/16-bit Instruction modes. Note 1: Byte operations use the 16-bit ALU and can produce results in excess of 8 bits. However, to maintain backward compatibility with PIC devices, the ALU result from all byte operations is written back as a byte (i.e., MSByte not modified), and the SR register is updated based only upon the state of the LSByte of the result. 2: All register instructions performed in Byte mode only affect the LSByte of the W registers. The MSByte of any W register can be modified by using file register instructions that access the memory mapped contents of the W registers.
2
CPU
2.5.1
DS70049D-page 2-17
Data input to the DSP engine is derived from one of the following sources: Directly from the W array (registers W4, W5, W6 or W7) for dual source operand DSP instructions. Data values for the W4, W5, W6 and W7 registers are prefetched via the X and Y memory data buses. From the X memory data bus for all other DSP instructions. Data output from the DSP engine is written to one of the following destinations: The target accumulator, as defined by the DSP instruction being executed. The X memory data bus to any location in the data memory address space. The DSP engine has the capability to perform inherent accumulator to accumulator operations which require no additional data. The MCU shift and multiply instructions use the DSP engine hardware to obtain their results. The X memory data bus is used for data reads and writes in these operations. A block diagram of the DSP engine is shown in Figure 2-6. Note: For detailed code examples and instruction syntax related to this section, refer to the dsPIC30F Programmers Reference Manual (DS70157).
DS70049D-page 2-18
Section 2. CPU
Figure 2-8: DSP Engine Block Diagram
2
CPU
40
Saturation Logic
Round Logic
40
16
40
40
40
Barrel Shifter
16
Sign-Extend
Y Data Bus
32 Zero Backfill 32 32
16
To/From W Array
DS70049D-page 2-19
X Data Bus
40
2.6.2
Multiplier
The dsPIC30F features a 17-bit x 17-bit multiplier which is shared by both the MCU ALU and the DSP engine. The multiplier is capable of signed or unsigned operation and can support either 1.31 fractional (Q.31) or 32-bit integer results. The multiplier takes in 16-bit input data and converts the data to 17-bits. Signed operands to the multiplier are sign-extended. Unsigned input operands are zero-extended. The 17-bit conversion logic is transparent to the user and allows the multiplier to support mixed sign and unsigned/ unsigned multiplication. The IF control bit (CORCON<0>) determines integer/fractional operation for the instructions listed in Table 2-3. The IF bit does not affect MCU multiply instructions listed in Table 2-4, which are always integer operations. The multiplier scales the result one bit to the left for fractional operation. The Least Significant bit (LSb) of the result is always cleared. The multiplier defaults to Fractional mode for DSP operations at a device Reset. The representation of data in hardware for each of these modes is as follows: Integer data is inherently represented as a signed twos complement value, where the MSbit is defined as a sign bit. Generally speaking, the range of an N-bit twos complement integer is -2N-1 to 2N-1 1. Fractional data is represented as a twos complement fraction where the MSbit is defined as a sign bit and the radix point is implied to lie just after the sign bit (Q.X format). The range of an N-bit twos complement fraction with this implied radix point is -1.0 to (1 21-N). Figure 2-9 and Figure 2-10 illustrate how the multiplier hardware interprets data in Integer and Fractional modes. The range of data in both Integer and Fractional modes is listed in Table 2-2.
DS70049D-page 2-20
Section 2. CPU
Figure 2-9: Integer and Fractional Representation of 0x4001
2
CPU
1.15 Fractional: 0 -2
0
1 2
-1
0 2
-2
0 2
-3
0 ...
1 2-15
Figure 2-10:
1 214
0 213
0 212
0 ....
0 20
2-1
Implied Radix Point 0xC002 = -20 + 2-1 + 2-14 = -1 + 0.5 + 0.000061035 = -0.499938965
DS70049D-page 2-21
2.6.2.1
DSP Multiply Instructions The DSP instructions that utilize the multiplier are summarized in Table 2-3. Table 2-3: DSP Instructions that Utilize the Multiplier Description Multiply and Add to Accumulator OR Square and Add to Accumulator Multiply and Subtract from Accumulator Multiply Multiply and Negate Result Partial Euclidean Distance Add Partial Euclidean Distance to the Accumulator Algebraic Equivalent a = a + b*c a = a + b2 a = a b*c a = b*c a = -b*c a = (b c)2 a = a + (b c)2
DSP instructions using the multiplier can operate in Fractional (1.15) or Integer modes.
The US control bit (CORCON<12>) determines whether DSP multiply instructions are signed (default) or unsigned. The US bit does not influence the MCU multiply instructions which have specific instructions for signed or unsigned operation. If the US bit is set, the input operands for instructions shown in Table 2-3 are considered as unsigned values which are always zeroextended into the 17th bit of the multiplier value. 2.6.2.2 MCU Multiply Instructions The same multiplier is used to support the MCU multiply instructions, which include integer 16bit signed, unsigned and mixed sign multiplies as shown in Table 2-4. All multiplications performed by the MUL instruction produce integer results. The MUL instruction may be directed to use byte or word sized operands. Byte input operands will produce a 16-bit result and word input operands will produce a 32-bit result to the specified register(s) in the W array. Table 2-4: MCU Instructions that Utilize the Multiplier Description Multiply two unsigned integers Multiply two signed integers Multiply a signed integer with an unsigned integer
Note 1: MCU instructions using the multiplier operate only in Integer mode. 2: Result of an MCU multiply is 32-bits long and is stored in a pair of W registers.
DS70049D-page 2-22
Section 2. CPU
2.6.3 Data Accumulator Adder/Subtractor
The data accumulators have a 40-bit adder/subtractor with automatic sign extension logic for the multiplier result (if signed). It can select one of the two accumulators (A or B) as its pre-accumulation source and post-accumulation destination. For the ADD (accumulator) and LAC instructions, the data to be accumulated or loaded can optionally be scaled via the barrel shifter prior to accumulation. The 40-bit adder/subtractor may optionally negate one of its operand inputs to change the sign of the result (without changing the operands). The negate is used during multiply and subtract (MSC), or multiply and negate (MPY.N) operations. The 40-bit adder/subtractor has an additional saturation block which controls accumulator data saturation, if enabled. 2.6.3.1 Accumulator Status Bits Six Status register bits have been provided to support saturation and overflow. They are located in the CPU Status register, SR and are listed below: Table 2-5: Status Bit OA OB SA Accumulator Overflow and Saturation Status Bits Location SR<15> SR<14> SR<13> Description Accumulator A overflowed into guard bits (ACCA<39:32>) Accumulator B overflowed into guard bits(ACCB<39:32>) ACCA saturated (bit 31 overflow and saturation) or ACCA overflowed into guard bits and saturated (bit 39 overflow and saturation) ACCB saturated (bit 31 overflow and saturation) or ACCB overflowed into guard bits and saturated (bit 39 overflow and saturation) OA logically ORed with OB SA logically ORed with SB. Clearing SAB will also clear SA and SB.
2
CPU
SB
SR<12>
OAB SAB
SR<11> SR<10>
The OA and OB bits are read only and are modified each time data passes through the accumulator add/subtract logic. When set, they indicate that the most recent operation has overflowed into the accumulator guard bits (bits 32 through 39). This type of overflow is not catastrophic; the guard bits preserve the accumulator data. The OAB status bit is the logically ORed value of OA and OB. The OA and OB bits, when set, can optionally generate an arithmetic error trap. The trap is enabled by setting the corresponding overflow trap flag enable bit OVATE:OVBTE (INTCON1<10:9>). The trap event allows the user to take immediate corrective action, if desired. The SA and SB bits can be set each time data passes through the accumulator saturation logic. Once set, these bits remain set until cleared by the user. The SAB status bit indicates the logically ORed value of SA and SB. The SA and SB bits will be cleared when SAB is cleared. When set, these bits indicate that the accumulator has overflowed its maximum range (bit 31 for 32-bit saturation or bit 39 for 40-bit saturation) and will be saturated (if saturation is enabled). When saturation is not enabled, the SA and SB bits indicate that a catastrophic overflow has occurred (the sign of the accumulator has been destroyed). If the COVTE (INTCON1<8>) bit is set, SA and SB bits will generate an arithmetic error trap when saturation is disabled. Note: See Section 6. Reset Interrupts for further information on arithmetic warning traps. The user must remember that SA, SB and SAB status bits can have different meanings depending on whether accumulator saturation is enabled. The Accumulator Saturation mode is controlled via the CORCON register.
Note:
DS70049D-page 2-23
Data Space Write Saturation In addition to adder/subtractor saturation, writes to data space can be saturated without affecting the contents of the source accumulator. This feature allows data to be limited while not sacrificing the dynamic range of the accumulator during intermediate calculation stages. Data space write saturation is enabled by setting the SATDW control bit (CORCON<5>). Data space write saturation is enabled by default at a device Reset. The data space write saturation feature works with the SAC and SAC.R instructions. The value held in the accumulator is never modified when these instructions are executed. The hardware takes the following steps to obtain the saturated write result: 1. 2. 3. The read data is scaled based upon the arithmetic shift value specified in the instruction. The scaled data is rounded (SAC.R only). The scaled/rounded value is saturated to a 16-bit result based on the value of the guard bits. For data values greater than 0x007FFF, the data written to memory is saturated to the maximum positive 1.15 value, 0x7FFF. For input data less than 0xFF8000, data written to memory is saturated to the maximum negative 1.15 value, 0x8000.
DS70049D-page 2-24
Section 2. CPU
2.6.3.4 Accumulator Write Back The MAC and MSC instructions can optionally write a rounded version of the accumulator that is not the target of the current operation into data space memory. The write is performed across the X-bus into combined X and Y address space. This accumulator write back feature is beneficial in certain FFT and LMS algorithms. The following Addressing modes are supported by the accumulator write back hardware: W13, register direct: The rounded contents of the non-target accumulator are written into W13 as a 1.15 fractional result. [W13]+=2, register indirect with post-increment: The rounded contents of the non-target accumulator are written into the address pointed to by W13 as a 1.15 fraction. W13 is then incremented by 2.
2
CPU
2.6.4
Round Logic
The round logic can perform a conventional (biased) or convergent (unbiased) round function during an accumulator write (store). The Round mode is determined by the state of the RND (CORCON<1>) bit. It generates a 16-bit, 1.15 data value, which is passed to the data space write saturation logic. If rounding is not indicated by the instruction, a truncated 1.15 data value is stored. The two Rounding modes are shown in Figure 2-11. Conventional rounding takes bit 15 of the accumulator, zero-extends it and adds it to the most significant Word excluding the guard or overflow bits (bits 16 through 31). If the least significant word of the accumulator is between 0x8000 and 0xFFFF (0x8000 included), the MSWord is incremented. If the LSWord of the accumulator is between 0x0000 and 0x7FFF, the MSWord is left unchanged. A consequence of this algorithm is that over a succession of random rounding operations, the value will tend to be biased slightly positive. Convergent (or unbiased) rounding operates in the same manner as conventional rounding except when the least significant word equals 0x8000. If this is the case, the LSbit of the most significant word (bit 16 of the accumulator) is examined. If it is 1, the most significant word is incremented. If it is 0, the most significant word is not modified. Assuming that bit 16 is effectively random in nature, this scheme will remove any rounding bias that may accumulate. The SAC and SAC.R instructions store either a truncated (SAC) or rounded (SAC.R) version of the contents of the target accumulator to data memory via the X-bus (subject to data saturation, see Section 2.6.3.3 Data Space Write Saturation). Note that for the MAC class of instructions, the accumulator write back data path is always subject to rounding.
Figure 2-11:
Round Up (add 1 to MSWord) when: 1. LSWord = 0x8000 and bit 16 = 1 2. LSWord > 0x8000
16 15 MSWord
0 MSWord
16 15
Round Down (add nothing) when: 1. LSWord = 0x8000 and bit 16 = 0 2. LSWord < 0x8000
DS70049D-page 2-25
2.6.6
2.6.7
DS70049D-page 2-26
Section 2. CPU
2.7 Divide Support
The dsPIC30F supports the following types of division operations: DIVF: 16/16 signed fractional divide DIV.SD: 32/16 signed divide DIV.UD: 32/16 unsigned divide DIV.SW: 16/16 signed divide DIV.UW: 16/16 unsigned divide
2
CPU
The quotient for all divide instructions is placed in W0, and the remainder in W1. The 16-bit divisor can be located in any W register. A 16-bit dividend can be located in any W register and a 32-bit dividend must be located in an adjacent pair of W registers. All divide instructions are iterative operations and must be executed 18 times within a REPEAT loop. The user is responsible for programming the REPEAT instruction. A complete divide operation takes 19 instruction cycles to execute. The divide flow is interruptible, just like any other REPEAT loop. All data is restored into the respective data registers after each iteration of the loop, so the user will be responsible for saving the appropriate W registers in the ISR. Although they are important to the divide hardware, the intermediate values in the W registers have no meaning to the user. The divide instructions must be executed 18 times in a REPEAT loop to produce a meaningful result. Refer to the dsPIC30F Programmers Reference Manual (DS70157) for more information and programming examples for the divide instructions.
2.8
Figure 2-12:
Instruction Flow 1-Word, 1-Cycle TCY0 TCY1 Execute 1 Fetch 2 Execute 2 Fetch 3 1 Instruction Word, 2 Instruction Cycles: In these instructions, there is no prefetch flush. The only instructions of this type are the MOV.D instructions (load and store double-word). Two cycles are required to complete these instructions, as shown in Figure 2-13. Execute 3 TCY2 TCY3 TCY4 TCY5
Fetch 1
Figure 2-13:
Instruction Flow 1-Word, 2-Cycle (MOV.D Operation) TCY0 TCY1 Execute 1 Fetch 2 Execute 2 R/W Cycle 1 Fetch 3 Execute 2 R/W Cycle2 No Fetch Execute 3 Fetch 4 Execute 4 TCY2 TCY3 TCY4 TCY5
Fetch 1
4. MOV
#0x00CC,W0
DS70049D-page 2-27
Three cycles will be taken when a two-word instruction is skipped. In this case, the program memory prefetch data is discarded and the second word of the two-word instruction is fetched. The second word of the instruction will be executed as a NOP, as shown in Figure 2-15. Figure 2-15: Instruction Flow 1-Word, 3-Cycle (2-Word Instruction Skipped) TCY0 1. BTSC 2. GOTO SR,#Z LABEL Fetch 1 TCY1 Execute 1, Skip Taken Fetch 2 Forced NOP Fetch 2nd word of GOTO 2nd word executed as a NOP Fetch 3 Execute 3 Fetch 4 Execute 4 TCY2 TCY3 TCY4 TCY5
3. BCLR 4. MOV
PORTB,#3 W0,W1
4.
1 Instruction Word, 3 Instruction Cycles (RETFIE, RETURN, RETLW): The RETFIE, RETURN and RETLW instructions, that are used to return from a subroutine call or an Interrupt Service Routine, take 3 instruction cycles to execute, as shown in Figure 2-16.
Figure 2-16:
Instruction Flow 1-Word, 3-Cycle (RETURN, RETFIE, RETLW) TCY0 TCY1 Execute 1 Fetch 2 Execute 2 Fetch 3 Execute 2 No Fetch Execute 2 Fetch 4 Execute 4 Fetch 5 TCY2 TCY3 TCY4 TCY5
1. MOV
#0x55AA,W0
Fetch 1
DS70049D-page 2-28
Section 2. CPU
5. Table Read/Write Instructions: These instructions will suspend fetching to insert a read or write cycle to the program memory. The instruction fetched while executing the table operation is saved for 1 cycle and executed in the cycle immediately after the table operation as shown in Figure 2-17. Figure 2-17: Instruction Pipeline Flow Table Operations TCY0 1. MOV #0x1234,W0 2. TBLRDL.w [W0++],W1 3. MOV #0x00AA,W1 Fetch 1 TCY1 Execute 1 Fetch 2 Execute 2 Fetch 3 PM Data Read Cycle Bus Read 4. MOV #0x00CC,W0 Execute 3 Fetch 4 Execute 4 TCY2 TCY3 TCY4 TCY5
2
CPU
6.
2 Instruction Words, 2 Instruction Cycles: In these instructions, the fetch after the instruction contains data. This results in a 2-cycle instruction as shown in Figure 2-18. The second word of a two-word instruction is encoded so that it will be executed as a NOP, should it be fetched by the CPU without first fetching the first word of the instruction. This is important when a two-word instruction is skipped by a skip instruction (see Figure 2-15).
Figure 2-18:
Instruction Pipeline Flow 2-Word, 2-Cycle TCY0 TCY1 Execute 1 Fetch 2L Update PC Fetch 2H Forced NOP Fetch 3 Execute 3 Fetch 4 Execute 4 TCY2 TCY3 TCY4 TCY5
Fetch 1
7.
Address Register Dependencies: These are the instructions that are subjected to a stall due to a data address dependency between the X-data space read and write operations. An additional cycle is inserted to resolve the resource conflict as discussed in Section 2.10 Address Register Dependencies.
Figure 2-19:
Instruction Pipeline Flow 1-Word, 1-Cycle (With Instruction Stall) TCY0 TCY1 Execute 1 Fetch 2 Execute 1 Stall Execute 2 Fetch 3 Execute 3 TCY2 TCY3 TCY4 TCY5
Fetch 1
DS70049D-page 2-29
2.9.1
2.9.1.1
Repeat Operation The loop count for Repeat operations is held in the 14-bit RCOUNT register, which is memory mapped. RCOUNT is initialized by the REPEAT instruction. The REPEAT instruction sets the Repeat Active, or RA (SR<4>) status bit to 1, if the RCOUNT is a non-zero value. RA is a read only bit and cannot be modified through software. For repeat loop count values greater than 0, the PC is not incremented. Further PC increments are inhibited until RCOUNT = 0. See Figure 2-20 for an instruction flow example of a Repeat loop. For a loop count value equal to 0, REPEAT has the effect of a NOP and the RA (SR<4>) bit is not set. The Repeat loop is essentially disabled before it begins, allowing the target instruction to execute only once while prefetching the subsequent instruction (i.e., normal execution flow). Note: The instruction immediately following the REPEAT instruction (i.e., the target instruction) is always executed at least one time. It is always executed one time more than the value specified in the 14-bit literal or the W register operand.
Figure 2-20:
REPEAT Instruction Pipeline Flow TCY0 TCY1 Execute 1 Fetch 2 Execute 2 No Fetch Execute 2 No Fetch Execute 2 Fetch 3 PC X 0 PC+2 2 1 PC+2 1 1 PC+2 0 0 PC+4 0 0 Execute 3 PC+6 0 0 TCY2 TCY3 TCY4 TCY5
1.REPEAT #0x2
Fetch 1
2.MAC W4*W5,A,[W8]+=2,W4
3.BSET
PORTA,#3
PC (at end of instruction) RCOUNT (at end of instruction) RA (at end of instruction)
DS70049D-page 2-30
Section 2. CPU
2.9.1.2 Interrupting a REPEAT Loop A REPEAT instruction loop may be interrupted at any time. The RA state is preserved on the stack during exception processing to allow the user to execute further REPEAT loops from within (any number) of nested interrupts. After SRL is stacked, the RA status bit is cleared to restore normal execution flow within the ISR. Note: If a Repeat loop has been interrupted and an ISR is being processed, the user must stack the RCOUNT (Repeat Count register) prior to executing another REPEAT instruction within an ISR.
2
CPU
Note: If Repeat was used within an ISR, the user must unstack RCOUNT prior to executing RETFIE. Returning into a Repeat loop from an ISR using RETFIE requires no special handling. Interrupts will prefetch the repeated instruction during the third cycle of the RETFIE. The stacked RA bit will be restored when the SRL register is popped and, if set, the interrupted Repeat loop will be resumed. Note: Should the repeated instruction (target instruction in the Repeat loop) be accessing data from PS using PSV, the first time it is executed after a return from an exception will require 2 instruction cycles. Similar to the first iteration of a loop, timing limitations will not allow the first instruction to access data residing in PS in a single instruction cycle.
2.9.1.2.1
Early Termination of a REPEAT Loop An interrupted Repeat loop can be terminated earlier than normal in the ISR by clearing the RCOUNT register in software.
2.9.1.3
Restrictions on the REPEAT Instruction Any instruction can immediately follow a REPEAT except for the following: 1. 2. 3. 4. Program Flow Control instructions (any branch, compare and skip, subroutine calls, returns, etc.). Another REPEAT or DO instruction. DISI, ULNK, LNK, PWRSAV and RESET. MOV.D instruction. Note: There are some instructions and/or Instruction Addressing modes that can be executed within a Repeat loop, but make little sense when repeated.
DS70049D-page 2-31
The following features are provided in the DO loop construct: A W register can be used to specify the loop count. This allows the loop count to be defined at run-time. The instruction execution order need not be sequential (i.e., there can be branches, subroutine calls, etc.). The loop end address does not have to be greater than the start address. 2.9.2.1 DO Loop Registers and Operation The number of iterations executed by a DO loop will be the (14-bit literal value +1) or the (Wn value + 1). If a W register is used to specify the number of iterations, the two MSbits of the W register are not used to specify the loop count. The operation of a DO loop is similar to the do-while construct in the C programming language because the instructions in the loop will always be executed at least once. The dsPIC30F has three registers associated with DO loops: DOSTART, DOEND and DCOUNT. These registers are memory mapped and automatically loaded by the hardware when the DO instruction is executed. DOSTART holds the starting address of the DO loop while DOEND holds the end address of the DO loop. The DCOUNT register holds the number of iterations to be executed by the loop. DOSTART and DOEND are 22-bit registers that hold the PC value. The MSbits and LSbits of these registers is fixed to 0. Refer to Figure 2-2 for further details. The LSbit is not stored in these registers because PC<0> is always forced to 0. The DA status bit (SR<9>) indicates that a single DO loop (or nested DO loops) is active. The DA bit is set when a DO instruction is executed and enables a PC address comparison with the DOEND register on each subsequent instruction cycle. When PC matches the value in DOEND, DCOUNT is decremented. If the DCOUNT register is not zero, the PC is loaded with the address contained in the DOSTART register to start another iteration of the DO loop. The DO loop will terminate when DCOUNT = 0. If there are no other nested DO loops in progress, then the DA bit will also be cleared. Note: The group of instructions in a DO loop construct is always executed at least one time. The DO loop is always executed one time more than the value specified in the literal or W register operand.
DS70049D-page 2-32
Section 2. CPU
2.9.2.2 DO Loop Nesting The DOSTART, DOEND and DCOUNT registers each have a shadow register associated with them, such that the DO loop hardware supports one level of automatic nesting. The DOSTART, DOEND and DCOUNT registers are user accessible and they may be manually saved to permit additional nesting, where required. The DO Level bits, DL<2:0> (CORCON<10:8>) indicate the nesting level of the DO loop currently being executed. When the first DO instruction is executed, DL<2:0> is set to B001 to indicate that one level of DO loop is underway. The DA (SR<9>) is also set. When another DO instruction is executed within the first DO loop, the DOSTART, DOEND and DCOUNT registers are transferred into the shadow registers, prior to being updated with the new loop values. The DL<2:0> bits are set to B010 indicating that a second, nested DO loop is in progress. The DA (SR<9>) bit also remains set. If no more than one level of DO loop nesting is required in the application, no special attention is required. Should the user require more than one level of DO loop nesting, this may be achieved through manually saving the DOSTART, DOEND and DCOUNT registers prior to executing the next DO instruction. These registers should be saved whenever DL<2:0> is B010 or greater. The DOSTART, DOEND and DCOUNT registers will automatically be restored from their shadow registers when a DO loop terminates and DL<2:0> = B010. Note: The DL<2:0> (CORCON<10:8>) bits are combined (logically ORed) to form the DA (SR<9>) bit. If nested DO loops are being executed, the DA bit is cleared only when the loop count associated with the outer most loop expires.
2
CPU
2.9.2.3
Interrupting a DO Loop DO loops may be interrupted at any time. If another DO loop is to be executed during the ISR, the user must check the DL<2:0> status bits and save the DOSTART, DOEND and DCOUNT registers as required. No special handling is required if the user can ensure that only one level of DO loop will ever be executed in: both background and any one ISR handler (if interrupt nesting is enabled) or both background and any ISR (if interrupt nesting is disabled) Alternatively, up to two (nested) DO loops may be executed in either background or within any one ISR handler (if interrupt nesting is enabled) or in any ISR (if interrupt nesting is disabled) It is assumed that no DO loops are used within any trap handlers. Returning to a DO loop from an ISR, using the RETFIE instruction, requires no special handling.
2.9.2.4
Early Termination of the DO loop There are two ways to terminate a DO loop, earlier than normal: 1. The EDT (CORCON<11>) bit provides a means for the user to terminate a DO loop before it completes all loops. Writing a 1 to the EDT bit will force the loop to complete the iteration underway and then terminate. If EDT is set during the penultimate or last instruction of the loop, one more iteration of the loop will occur. EDT will always read as a 0; clearing it has no effect. After the EDT bit is set, the user can optionally branch out of the DO loop. Alternatively, the code may branch out of the loop at any point except from the last instruction, which cannot be a flow control instruction. Although the DA bit enables the DO loop hardware, it will have no effect unless the address of the penultimate instruction is encountered during an instruction prefetch. This is not a recommended method for terminating a DO loop. Note: Exiting a DO loop without using EDT is not recommended because the hardware will continue to check for DOEND addresses.
2.
DS70049D-page 2-33
Loop Length Restrictions Loop length is defined as the signed offset of the last instruction from the first instruction in the DO loop. The loop length when added to the address of the first instruction in the loop forms the address of the last instruction of the loop.There are some loop length values that should be avoided. 1. Loop Length = -2 Execution will start at the first instruction in the loop (i.e., at [PC]) and will continue until the loop end address (in this case [PC 4]) is prefetched. As this is the first word of the DO instruction, it will execute the DO instruction again, re-initializing the DCOUNT and prefetching [PC]. This will continue forever as long as the loop end address [PC 4] is prefetched. This value of n has the potential of creating an infinite loop (subject to a Watchdog Timer Reset). end_loop: DO #33, end_loop ;DO is a two-word instruction NOP ;2nd word of DO executes as a NOP ADD W2,W3,W4 ;First instruction in DO loop([PC])
DS70049D-page 2-34
Section 2. CPU
2. Loop Length = -1 Execution will start at the first instruction in the loop (i.e., at [PC]) and will continue until the loop end address ([PC 2]) is prefetched. Since the loop end address is the second word of the DO instruction, it will execute as a NOP but will still prefetch [PC]. The loop will then execute again. This will continue as long as the loop end address [PC 2] is prefetched and the loop does not terminate. Should the value in the DCOUNT register reach zero and on a subsequent decrement generate a borrow, the loop will terminate. However, in such a case the initial instruction outside the loop will once again be the first loop instruction. DO #33, end_loop ;DO is a two-word instruction end_loop: NOP ;2nd word of DO executes as a NOP ADD W2,W3,W4 ;First instruction in DO loop([PC]) Loop Length = 0 Execution will start at the first instruction in the loop (i.e., at [PC]) and will continue until the loop end address ([PC]) is prefetched. If the loop is to continue, this prefetch will cause the DO loop hardware to load the DOEND address ([PC]) into the PC for the next fetch (which will be [PC] again). After the first true iteration of the loop, the first instruction in the loop will be executed repeatedly until the loop count underflows and the loop terminates. When this occurs, the initial instruction outside the loop will be the instruction after [PC]. DO #33, end_loop ;DO is a two-word instruction NOP ;2nd word of DO executes as a NOP end_loop: ADD W2,W3,W4 ;First instruction in DO loop([PC])
2
CPU
3.
2.10
ADD [W8]
MOV
X-Space WAGU
[W9]++
X-Space Address
W7
W10
W8
W9
DS70049D-page 2-35
Destination Addressing Mode using Wn Direct Direct Direct Indirect Indirect Indirect Indirect with modification Indirect
ADD.w W0, W1, [W2] MOV.w [W2], W3 ; W2=0x0004 (mapped W2) ADD.w W0, W1, [W2] MOV.w [W2++], W3 ; W2=0x0004 (mapped W2) ADD.w MOV.w ADD.w MOV.w W0, W1, [W2++] [W2], W3 W0, W1, [W2++] [W2++], W3
Indirect
Stall
Stall Stall
2.10.2
DS70049D-page 2-36
Section 2. CPU
If a RAW data dependency is detected, the dsPIC30F will begin an instruction stall. During an instruction stall, the following events occur: 1. 2. 3. 4. 2.10.2.1 The write operation underway (for the previous instruction) is allowed to complete as normal. Data space is not addressed until after the instruction stall. PC increment is inhibited until after the instruction stall. Further instruction fetches are inhibited until after the instruction stall.
2
CPU
Instruction Stall Cycles and Interrupts When an interrupt event coincides with two adjacent instructions that will cause an instruction stall, one of two possible outcomes could occur: The interrupt could be coincident with the first instruction. In this situation, the first instruction will be allowed to complete and the second instruction will be executed after the ISR completes. In this case, the stall cycle is eliminated from the second instruction because the exception process provides time for the first instruction to complete the write phase. The interrupt could be coincident with the second instruction. In this situation, the second instruction and the appended stall cycle will be allowed to execute prior to the ISR. In this case, the stall cycle associated with the second instruction executes normally. However, the stall cycle will be effectively absorbed into the exception process timing. The exception process proceeds as if an ordinary two-cycle instruction was interrupted.
2.10.2.2
Instruction Stall Cycles and Flow Change Instructions The CALL and RCALL instructions write to the stack using W15 and may, therefore, force an instruction stall prior to the next instruction, if the source read of the next instruction uses W15. The RETFIE and RETURN instructions can never force an instruction stall prior to the next instruction because they only perform read operations. However, the user should note that the RETLW instruction could force a stall, because it writes to a W register during the last cycle. The GOTO and branch instructions can never force an instruction stall because they do not perform write operations.
2.10.2.3
Instruction Stalls and DO and REPEAT Loops Other than the addition of instruction stall cycles, RAW data dependencies will not affect the operation of either DO or REPEAT loops. The prefetched instruction within a REPEAT loop does not change until the loop is complete or an exception occurs. Although register dependency checks occur across instruction boundaries, the dsPIC30F effectively compares the source and destination of the same instruction during a REPEAT loop. The last instruction of a DO loop either prefetches the instruction at the loop start address or the next instruction (outside the loop). The instruction stall decision will be based on the last instruction in the loop and the contents of the prefetched instruction.
2.10.2.4
Instruction Stalls and Program Space Visibility (PSV) When program space (PS) is mapped to data space by enabling the PSV (CORCON<2>) bit, and the X space EA falls within the visible program space window, the read or write cycle is redirected to the address in program space. Accessing data from program space takes up to 3 instruction cycles. Instructions operating in PSV address space are subject to RAW data dependencies and consequent instruction stalls, just like any other instruction. Consider the following code segment: ADD MOV W0,[W1],[W2++] [W2],[W3] ; PSV = 1, W1=0x8000, PSVPAG=0xAA
This sequence of instructions would take 5 instruction cycles to execute. Two instruction cycles are added to perform the PSV access via W1. Furthermore, an instruction stall cycle is inserted to resolve the RAW data dependency caused by W2.
DS70049D-page 2-37
DS70049D-page 2-38
Table 2-8:
Name
W0 W1 W2 W3 W4 W5 W6 W7 W8 W9 W10 W11 W12 W13 W14 W15 SPLIM ACCAL ACCAH ACCAU ACCBL ACCBH ACCBU PCL PCH TBLPAG PSVPAG RCOUNT DCOUNT DOSTARTL DOSTARTH DOENDL DOENDH SR CORCON MODCON XMODSRT
CPU
Bit 15
Bit 14
Bit 13
Bit 12
Bit 11
Bit 10
Bit 9
Bit 8
W1 W2 W3 W4 W5 W6 W7 W8 W9 W10 W11 W12 W13 W14 W15 SPLIM
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Reset State
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
W0 (WREG)
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx0 0000 0000 00xx xxxx xxxx xxxx xxxx xxx0 0000 0000 00xx xxxx 0000 0000 0000 0000 0000 0000 0010 0000 0000 0000 0000 0000 xxxx xxxx xxxx xxx0
Section 2. CPU
DL<1:0>
XMODEN YMODEN
YWM<3:0>
XWM<3:0>
Table 2-8:
Name
XMODEND YMODSRT YMODEND XBREV DISICNT Reserved
Bit 15
Bit 14
Bit 13
Bit 12
Bit 11
Bit 10
Bit 9
Bit 8
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
1 0 1
Reset State
xxxx xxxx xxxx xxx1 xxxx xxxx xxxx xxx0 xxxx xxxx xxxx xxx1 xxxx xxxx xxxx xxxx 0000 0000 0000 0000
Legend: x = uninitiated Note: Refer to the device data sheet for specific Core Register Map details.
Section 2. CPU
2.12 Related Application Notes
This section lists application notes that are related to this section of the manual. These application notes may not be written specifically for the dsPIC30F Product Family, but the concepts are pertinent and could be used with modification and possible limitations. The current application notes related to the dsPIC30F CPU module are: Title No related application notes at this time. Note: Please visit the Microchip web site (www.microchip.com) for additional Application Notes and code examples for the dsPIC30F Family of devices. Application Note #
2
CPU
DS70049D-page 2-41
Revision B
This revision incorporates additional technical content for the dsPIC30F CPU module.
Revision C
This revision incorporates all known errata at the time of this document update.
DS70049D-page 2-42