Professional Documents
Culture Documents
Data Sheet
High Performance
Digital Signal Controllers
Preliminary
DS70135C
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip's Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, KEELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart, rfPIC, and SmartShunt are
registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
PICMASTER, SEEVAL, SmartSensor and The Embedded
Control Solutions Company are registered trademarks of
Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, dsPICDEM,
dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR,
FanSense, FlexROM, fuzzyLAB, In-Circuit Serial
Programming, ICSP, ICEPIC, MPASM, MPLIB, MPLINK,
MPSIM, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail,
PowerCal, PowerInfo, PowerMate, PowerTool, rfLAB,
rfPICDEM, Select Mode, Smart Serial, SmartTel and Total
Endurance are trademarks of Microchip Technology
Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
2005, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper. 11/12/04
DS70135C-page ii
Preliminary
dsPIC30F4011/4012
dsPIC30F4011/4012 Enhanced Flash
16-bit Digital Signal Controller
Note: This data sheet summarizes features of this group
of dsPIC30F devices and is not intended to be a complete
reference source. For more information on the CPU,
peripherals, register descriptions and general device
functionality, refer to the dsPIC30F Family Reference
Manual (DS70046). For more information on the device
instruction set and programming, refer to the dsPIC30F
Programmers Reference Manual (DS70030).
Peripheral Features:
High current sink/source I/O pins: 25 mA/25 mA
Timer module with programmable prescaler:
- Five 16-bit timers/counters; optionally pair
16-bit timers into 32-bit timer modules
16-bit Capture input functions
16-bit Compare/PWM output functions
3-wire SPI modules (supports 4 Frame modes)
I2C module supports Multi-Master/Slave mode
and 7-bit/10-bit addressing
2 UART modules with FIFO Buffers
1 CAN modules, 2.0B compliant
Preliminary
DS70135C-page 1
dsPIC30F4011/4012
Analog Features:
CMOS Technology:
SPI
I2C
CAN
Program
Output
Moto
SRAM EEPROM Timer Input
A/D 10-bit Quad
Pins Mem. Bytes/
Comp/Std Control
Bytes
Bytes
16-bit Cap
500 Ksps Enc
Instructions
PWM
PWM
dsPIC30F2010
28
12K/4K
512
1024
6 ch
6 ch
Yes
dsPIC30F3010
28
24K/8K
1024
1024
6 ch
6 ch
Yes
dsPIC30F4012
28
48K/16K
2048
1024
6 ch
6 ch
Yes
dsPIC30F3011 40/44
24K/8K
1024
1024
6 ch
9 ch
Yes
dsPIC30F4011 40/44
48K/16K
2048
1024
6 ch
9 ch
Yes
dsPIC30F5015
64
66K/22K
2048
1024
8 ch
16 ch
Yes
dsPIC30F6010
80
144K/48K
8192
4096
8 ch
16 ch
Yes
Device
* This table provides a summary of the dsPIC30F6010 peripheral features. Other available devices in the dsPIC30F
Motor Control and Power Conversion Family are shown for feature comparison.
DS70135C-page 2
Preliminary
dsPIC30F4011/4012
Pin Diagrams
40-Pin PDIP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
dsPIC30F4011
MCLR
EMUD3/AN0/VREF+/CN2/RB0
EMUC3/AN1/VREF-/CN3/RB1
AN2/SS1/CN4/RB2
AN3/INDX/CN5/RB3
AN4/QEA/IC7/CN6/RB4
AN5/QEB/IC8/CN7/RB5
AN6/OCFA/RB6
AN7/RB7
AN8/RB8
VDD
VSS
OSC1/CLKIN
OSC2/CLKO/RC15
EMUD1/SOSCI/T2CK/U1ATX/CN1/RC13
EMUC1/SOSCO/T1CK/U1ARX/CN0/RC14
FLTA/INT0/RE8
EMUD2/OC2/IC2/INT2/RD1
OC4/RD3
VSS
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
AVDD
AVSS
PWM1L/RE0
PWM1H/RE1
PWM2L/RE2
PWM2H/RE3
PWM3L/RE4
PWM3H/RE5
VDD
VSS
C1RX/RF0
C1TX/RF1
U2RX/CN17/RF4
U2TX/CN18/RF5
PGC/EMUC/U1RX/SDI1/SDA/RF2
PGD/EMUD/U1TX/SDO1/SCL/RF3
SCK1/RF6
EMUC2/OC1/IC1/INT1/RD0
OC3/RD2
VDD
dsPIC30F4011
33
32
31
30
29
28
27
26
25
24
23
12
13
14
15
16
17
18
19
20
21
22
1
2
3
4
5
6
7
8
9
10
11
NC
EMUD1/SOSCI/T2CK/U1ATX/CN1/RC13
OSC2/CLKO/RC15
OSC1/CLKIN
VSS
VDD
AN8/RB8
AN7/RB7
AN6/OCFA/RB6
AN5/QEB/IC8/CN7/RB5
AN4/QEA/IC7/CN6/RB4
NC
NC
PWM1H/RE1
PWM1L/RE0
AVSS
AVDD
MCLR
EMUD3/AN0/VREF+/CN2/RB0
EMUC3/AN1/VREF-/CN3/RB1
AN2/SS1/CN4/RB2
AN3/INDX/CN5/RB3
PGC/EMUC/U1RX/SDI1/SDA/RF2
U2TX/CN18/RF5
U2RX/CN17/RF4
CTX1/RF1
CRX1/RF0
VSS
VDD
PWM3H/RE5
PWM3L/RE4
PWM2H/RE3
PWM2L/RE2
44
43
42
41
40
39
38
37
36
35
34
PGD/EMUD/U1TX/SDO1/SCL/RF3
SCK1/RF6
EMUC2/OC1/IC1/INT1/RD0
OC3/RD2
VDD
VSS
OC4/RD3
EMUD2/OC2/IC2/INT2/RD1
FLTA/INT0/RE8
EMUC1/SOSCO/T1CK/U1ARX/CN0/RC14
NC
44-Pin TQFP
Preliminary
DS70135C-page 3
dsPIC30F4011/4012
Pin Diagrams (Continued)
1
2
3
4
5
6
7
8
9
10
11
dsPIC30F4011
33
32
31
30
29
28
27
26
25
24
23
OSC2/CLKO/RC15
OSC1/CLKIN
VSS
VSS
VDD
VDD
AN8/RB8
AN7/RB7
AN6/OCFA/RB6
AN5/QEB/IC8/CN7/RB5
AN4/QEA/IC7/CN6/RB4
PWM2L/RE2
NC
PWM1H/RE1
PWM1L/RE0
AVSS
AVDD
MCLR
EMUD3/AN0/VREF+/CN2/RB0
EMUC3/AN1/VREF-/CN3/RB1
AN2/SS1/CN4/RB2
AN3/INDX/CN5/RB3
12
13
14
15
16
17
18
19
20
21
22
PGC/EMUC/U1RX/SDI1/SDA/RF2
U2TX/CN18/RF5
U2RX/CN17/RF4
CTX1/RF1
CRX1/RF0
VSS
VDD
VDD
PWM3H/RE5
PWM3L/RE4
PWM2H/RE3
39
38
37
36
35
34
44
43
42
41
40
PGD/EMUD/U1TX/SDO1/SCL/RF3
SCK1/RF6
EMUC2/OC1/IC1/INT1/RD0
OC3/RD2
VDD
VSS
OC4/RD3
EMUD2/OC2/IC2/INT2/RD1
FLTA/INT0/RE8
EMUC1/SOSCO/T1CK/U1ARX/CN0/RC14
EMUD1/SOSCI/T2CK/U1ATX/CN1/RC13
44-Pin QFN
DS70135C-page 4
Preliminary
dsPIC30F4011/4012
Pin Diagrams (Continued)
28-Pin SPDIP
28-Pin SOIC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
dsPIC30F4012
MCLR
EMUD3/AN0/VREF+/CN2/RB0
EMUC3/AN1/VREF-/CN3/RB1
AN2/SS1/CN4/RB2
AN3/INDX/CN5/RB3
AN4/QEA/IC7/CN6/RB4
AN5/QEB/IC8/CN7/RB5
VSS
OSC1/CLKIN
OSC2/CLKO/RC15
EMUD1/SOSCI/T2CK/U1ATX/CN1/RC13
EMUC1/SOSCO/T1CK/U1ARX/CN0/RC14
VDD
EMUD2/OC2/IC2/INT2/RD1
28
27
26
25
24
23
22
21
20
19
18
17
16
15
AVDD
AVSS
PWM1L/RE0
PWM1H/RE1
PWM2L/RE2
PWM2H/RE3
PWM3L/RE4
PWM3H/RE5
VDD
VSS
PGC/EMUC/U1RX/SDI1/SDA/C1RX/RF2
PGD/EMUD/U1TX/SDO1/SCL/C1TX/RF3
FLTA/INT0/SCK1/OCFA/RE8
EMUC2/OC1/IC1/INT1/RD0
1
2
3
4
5
6
7
8
9
10
11
dsPIC30F4012
33
32
31
30
29
28
27
26
25
24
23
OSC2/CLKO/RC15
OSC1/CLKIN
VSS
VSS
VDD
VDD
NC
NC
NC
AN5/QEB/IC8/CN7/RB5
AN4/QEA/IC7/CN6/RB4
PWM2L/RE2
NC
PWM1H/RE1
PWM1L/RE0
AVSS
AVDD
MCLR
EMUD3/AN0/VREF+/CN2/RB0
EMUC3/AN1/VREF-/CN3/RB1
AN2/SS1/CN4/RB2
AN3/INDX/CN5/RB3
12
13
14
15
16
17
18
19
20
21
22
PGC/EMUC/U1RX/SDI1/SDA/C1RX/RF2
NC
NC
NC
NC
VSS
VDD
VDD
PWM3H/RE5
PWM3L/RE4
PWM2H/RE3
39
38
37
36
35
34
44
43
42
41
40
PGD/EMUD/U1TX/SDO1/SCL/C1TX/RF3
FLTA/INT0/SCK1/OCFA/RE8
EMUC2/OC1/IC1/INT1/RD0
NC
VDD
VSS
NC
EMUD2/OC2/IC2/INT2/RD1
VDD
EMUC1/SOSCO/T1CK/U1ARX/CN0/RC14
EMUD1/SOSCI/T2CK/U1ATX/CN1/RC13
44-Pin QFN
Preliminary
DS70135C-page 5
dsPIC30F4011/4012
Table of Contents
1.0
Device Overview ...................................................................................................................................................................... 7
2.0
CPU Architecture Overview.................................................................................................................................................... 15
3.0
Memory Organization ............................................................................................................................................................. 23
4.0
Address Generator Units........................................................................................................................................................ 35
5.0
Interrupts ................................................................................................................................................................................ 41
6.0
Flash Program Memory.......................................................................................................................................................... 47
7.0
Data EEPROM Memory ......................................................................................................................................................... 53
8.0
I/O Ports ................................................................................................................................................................................. 57
9.0
Timer1 Module ....................................................................................................................................................................... 63
10.0
Timer2/3 Module .................................................................................................................................................................... 67
11.0
Timer4/5 Module ................................................................................................................................................................... 73
12.0
Input Capture Module............................................................................................................................................................. 77
13.0
Output Compare Module ........................................................................................................................................................ 81
14.0
Quadrature Encoder Interface (QEI) Module ......................................................................................................................... 85
15.0
Motor Control PWM Module ................................................................................................................................................... 91
16.0
SPI Module ....................................................................................................................................................................... 101
17.0
I2C Module ....................................................................................................................................................................... 105
18.0
Universal Asynchronous Receiver Transmitter (UART) Module .......................................................................................... 113
19.0
CAN Module ......................................................................................................................................................................... 121
20.0
10-bit High Speed Analog-to-Digital Converter (A/D) Module .............................................................................................. 131
21.0
System Integration ............................................................................................................................................................... 139
22.0
Instruction Set Summary ...................................................................................................................................................... 153
23.0
Development Support........................................................................................................................................................... 161
24.0
Electrical Characteristics ...................................................................................................................................................... 167
25.0
Packaging Information.......................................................................................................................................................... 209
The Microchip Web Site ..................................................................................................................................................................... 223
Customer Change Notification Service .............................................................................................................................................. 223
Customer Support .............................................................................................................................................................................. 223
Reader Response .............................................................................................................................................................................. 224
Product Identification System............................................................................................................................................................. 225
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision
of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
Microchips Worldwide Web site; http://www.microchip.com
Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are
using.
DS70135C-page 6
Preliminary
dsPIC30F4011/4012
1.0
DEVICE OVERVIEW
Preliminary
DS70135C-page 7
dsPIC30F4011/4012
FIGURE 1-1:
Interrupt
Controller
16
16
Data Latch
Y Data
RAM
(1 Kbyte)
Address
Latch
16
24
Y AGU
Address Latch
Program Memory
(48 Kbytes)
Data EEPROM
(1 Kbyte)
16
Data Latch
X Data
RAM
(1 Kbyte)
Address
Latch
16
16
X RAGU
X WAGU
16
24
16
AN0/EMUD3/VREF+/CN2/RB0
AN1/EMUC3/VREF-/CN3/RB1
AN2/SS1/CN4/RB2
AN3/INDX/CN5/RB3
AN4/QEA/CN6/IC7/RB4
AN5/QEB/CN7/IC8/RB5
AN6/OCFA/RB6
AN7/RB7
AN8/RB8
Effective Address
16
Data Latch
PORTB
ROM Latch
16
24
IR
16 x 16
W Reg Array
Decode
Instruction
Decode and
Control
Power-up
Timer
Timing
Generation
PORTC
16 16
Control Signals
to Various Blocks
OSC1/CLKI
EMUD1/SOSCI/CN1/T2CK/U1ATX/RC13
EMUC1/SOSCO/T1CK/CN0/U1ARX/RC14
OSC2/CLKO/RC15
16
16
DSP
Engine
Divide
Unit
EMUC2/OC1/IC1/INT1/RD0
EMUD2/OC2/IC2/INT2/RD1
OC3/RD2
OC4/RD3
Oscillator
Start-up Timer
ALU<16>
POR/BOR
Reset
MCLR
PORTD
16
16
Watchdog
Timer
VDD, VSS
AVDD, AVSS
CAN
10-bit ADC
Input
Capture
Module
Output
Compare
Module
I2C
SPI1
Timers
QEI
Motor Control
PWM
UART1,
UART2
PWM1L/RE0
PWM1H/RE1
PWM2L/RE2
PWM2H/RE3
PWM3L/RE4
PWM3H/RE5
FLTA/INT0/RE8
PORTE
C1RX/RF0
C1TX/RF1
U1RX/PGC/EMUC/SDI1/SDA/RF2
U1TX/PGD/EMUD/SDO1/SCL/RF3
U2RX/CN17/RF4
U2TX/CN18/RF5
SCK1/RF6
PORTF
DS70135C-page 8
Preliminary
dsPIC30F4011/4012
FIGURE 1-2:
16
Interrupt
Controller
16
Data Latch
Y Data
RAM
(1 Kbyte)
Address
Latch
16
24
Y AGU
Address Latch
Program Memory
(48 Kbytes)
Data EEPROM
(1 Kbyte)
16
16
16
X RAGU
X WAGU
16
24
16
Data Latch
X Data
RAM
(1 Kbyte)
Address
Latch
AN0/CN2/VREF+/EMUD2/RB0
AN1/CN3/VREF-/EMUC3/RB1
AN2/SS1/CN4/RB2
AN3/INDX/CN5/RB3
AN4/QEA/CN6/IC7/RB4
AN5/QEB/CN7/IC8/RB5
PORTB
Effective Address
16
Data Latch
ROM Latch
16
24
IR
16 x 16
W Reg Array
Decode
Instruction
Decode and
Control
Power-up
Timer
Timing
Generation
PORTC
16 16
Control Signals
to Various Blocks
OSC1/CLKI
EMUD1/SOSCI/CN1/T2CK/U1ATX/RC13
EMUC1/SOSCO/T1CK/CN0/U1ARX/RC14
OSC2/CLKO/RC15
16
16
DSP
Engine
Divide
Unit
EMUC2/OC1/RD0
EMUD2/OC2/RD1
Oscillator
Start-up Timer
ALU<16>
POR/BOR
Reset
MCLR
VDD, VSS
AVDD, AVSS
PORTD
16
16
Watchdog
Timer
CAN
10-bit ADC
Input
Capture
Module
Output
Compare
Module
I2C
SPI1,
SPI2
Timers
QEI
Motor Control
PWM
UART1,
UART2
PWM1L/RE0
PWM1H/RE1
PWM2L/RE2
PWM2H/RE3
PWM3L/RE4
PWM3H/RE5
FLTA/INT0/SCK1/OCFA/RE8
PORTE
U1RX/PGC/EMUC/SDI1/SDA/RF2
U1TX/PGD/EMUD/SDO1/SCL/RF3
PORTF
Preliminary
DS70135C-page 9
dsPIC30F4011/4012
Table 1-1 provides a brief description of the device I/O
pinout and the functions that are multiplexed to a port
pin. Multiple functions may exist on one port pin. When
multiplexing occurs, the peripheral modules functional
requirements may force an override of the data
direction of the port pin.
TABLE 1-1:
Buffer
Type
AN0-AN8
Analog
Pin Name
Description
Analog input channels.
AN0 and AN1 are also used for device programming data and clock inputs,
respectively.
AVDD
AVSS
CLKI
CLKO
I
O
CN0-CN7
CN17-CN18
ST
C1RX
C1TX
I
O
ST
EMUD
EMUC
EMUD1
EMUC1
EMUD2
EMUC2
EMUD3
EMUC3
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
ST
ST
ST
ST
ST
ST
ST
ST
ST
INDX
QEA
I
I
ST
ST
QEB
ST
INT0
INT1
INT2
I
I
I
ST
ST
ST
External interrupt 0.
External interrupt 1.
External interrupt 2.
FLTA
PWM1L
PWM1H
PWM2L
PWM2H
PWM3L
PWM3H
I
O
O
O
O
O
O
ST
MCLR
I/P
ST
Master Clear (Reset) input or programming voltage input. This pin is an active
low Reset to the device.
OCFA
OC1-OC4
I
O
ST
Legend:
CMOS =
ST
=
I
=
DS70135C-page 10
ST/CMOS External clock source input. Always associated with OSC1 pin function.
Analog =
O
=
P
=
Preliminary
Analog input
Output
Power
dsPIC30F4011/4012
TABLE 1-1:
Pin Name
OSC1
OSC2
I
I/O
PGD
PGC
I/O
I
Buffer
Type
Description
otherwise.
Oscillator crystal output. Connects to crystal or resonator in Crystal Oscillator
mode. Optionally functions as CLKO in RC and EC modes.
ST
ST
RB0-RB8
I/O
ST
8RC13-RC15
8I/O
8ST
RD0-RD3
I/O
ST
RE0-RE5,
RE8
I/O
ST
RF0-RF6
I/O
ST
SCK1
SDI1
SDO1
SS1
I/O
I
O
I
ST
ST
ST
SCL
SDA
I/O
I/O
ST
ST
SOSCO
SOSCI
O
I
T1CK
T2CK
I
I
ST
ST
U1RX
U1TX
U1ARX
U1ATX
U2RX
U2TX
I
O
I
O
I
O
ST
ST
ST
UART1 Receive.
UART1 Transmit.
UART1 Alternate Receive.
UART1 Alternate Transmit.
UART2 Receive.
UART2 Transmit.
VDD
VSS
VREF+
Analog
VREF-
Analog
Legend:
CMOS =
ST
=
I
=
Analog =
O
=
P
=
Preliminary
Analog input
Output
Power
DS70135C-page 11
dsPIC30F4011/4012
Table 1-2 provides a brief description of the device I/O
pinout and the functions that are multiplexed to a port
pin. Multiple functions may exist on one port pin. When
multiplexing occurs, the peripheral modules functional
requirements may force an override of the data
direction of the port pin.
TABLE 1-2:
Buffer
Type
AN0-AN5
Analog
Pin Name
Description
Analog input channels.
AN0 and AN1 are also used for device programming data and clock inputs,
respectively.
AVDD
AVSS
CLKI
CLKO
I
O
CN0-CN7
ST
C1RX
C1TX
I
O
ST
EMUD
EMUC
EMUD1
EMUC1
EMUD2
EMUC2
EMUD3
EMUC3
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
ST
ST
ST
ST
ST
ST
ST
ST
ST
INDX
QEA
I
I
ST
ST
QEB
ST
INT0
INT1
INT2
I
I
I
ST
ST
ST
External interrupt 0.
External interrupt 1.
External interrupt 2.
FLTA
PWM1L
PWM1H
PWM2L
PWM2H
PWM3L
PWM3H
I
O
O
O
O
O
O
ST
MCLR
I/P
ST
Master Clear (Reset) input or programming voltage input. This pin is an active
low Reset to the device.
OCFA
OC1, OC2
I
O
ST
Legend:
CMOS =
ST
=
I
=
DS70135C-page 12
ST/CMOS External clock source input. Always associated with OSC1 pin function.
Analog =
O
=
P
=
Preliminary
Analog input
Output
Power
dsPIC30F4011/4012
TABLE 1-2:
Pin Name
OSC1
OSC2
I
I/O
PGD
PGC
I/O
I
Buffer
Type
Description
otherwise.
Oscillator crystal output. Connects to crystal or resonator in Crystal Oscillator
mode. Optionally functions as CLKO in RC and EC modes.
ST
ST
RB0-RB5
I/O
ST
RC13-RC15
8I/O
8ST
RD0-RD1
I/O
ST
RE0-RE5,
RE8
I/O
ST
RF2-RF3
I/O
ST
SCK1
SDI1
SDO1
I/O
I
O
ST
ST
SCL
SDA
I/O
I/O
ST
ST
SOSCO
SOSCI
O
I
T1CK
T2CK
I
I
ST
ST
U1RX
U1TX
U1ARX
U1ATX
I
O
I
O
ST
ST
UART1 Receive.
UART1 Transmit.
UART1 Alternate Receive.
UART1 Alternate Transmit.
VDD
VSS
VREF+
Analog
VREF-
Analog
Legend:
CMOS =
ST
=
I
=
Analog =
O
=
P
=
Preliminary
Analog input
Output
Power
DS70135C-page 13
dsPIC30F4011/4012
NOTES:
DS70135C-page 14
Preliminary
dsPIC30F4011/4012
2.0
CPU ARCHITECTURE
OVERVIEW
2.1
Core Overview
Preliminary
DS70135C-page 15
dsPIC30F4011/4012
2.2
Programmers Model
2.2.1
2.2.2
STATUS REGISTER
When a byte operation is performed on a working register, only the Least Significant Byte of the target register is affected. However, a benefit of memory mapped
working registers is that both the Least and Most
Significant Bytes can be manipulated through byte
wide data memory space accesses.
2.2.3
PROGRAM COUNTER
DS70135C-page 16
Preliminary
dsPIC30F4011/4012
FIGURE 2-1:
D0
W0/WREG
PUSH.S Shadow
W1
DO Shadow
W2
W3
Legend
W4
DSP Operand
Registers
W5
W6
W7
Working Registers
W8
W9
DSP Address
Registers
W10
W11
W12/DSP Offset
W13/DSP Write Back
W14/Frame Pointer
W15/Stack Pointer
SPLIM
AD39
AD15
AD31
AD0
AccA
DSP
Accumulators
AccB
PC22
PC0
Program Counter
0
0
7
TABPAG
TBLPAG
7
PSVPAG
0
RCOUNT
15
0
DCOUNT
DO Loop Counter
22
0
DOSTART
DOEND
22
15
0
Core Configuration Register
CORCON
OA
OB
SA
SB OAB SAB DA
SRH
OV
Status Register
SRL
Preliminary
DS70135C-page 17
dsPIC30F4011/4012
2.3
Divide Support
TABLE 2-1:
DIVIDE INSTRUCTIONS
Instruction
Function
DIVF
DIV.sd
DIV.ud
2.4
DSP Engine
TABLE 2-2:
Instruction
CLR
ED
EDAC
MAC
MOVSAC
MPY
MPY.N
MSC
DSP INSTRUCTION
SUMMARY
Algebraic Operation
A=0
A = (x y)2
A = A + (x y)2
A = A + (x * y)
No change in A
A=x*y
A=x*y
A=Ax*y
DS70135C-page 18
Preliminary
dsPIC30F4011/4012
FIGURE 2-2:
40
S
a
40 Round t 16
u
Logic r
a
t
e
40-bit Accumulator A
40-bit Accumulator B
Carry/Borrow Out
Carry/Borrow In
Saturate
Adder
Negate
40
40
40
16
X Data Bus
Barrel
Shifter
40
Y Data Bus
Sign-Extend
32
16
Zero Backfill
32
33
17-bit
Multiplier/Scaler
16
16
To/From W Array
Preliminary
DS70135C-page 19
dsPIC30F4011/4012
2.4.1
MULTIPLIER
2.4.2.1
2.4.2
4.
DS70135C-page 20
5.
6.
OA:
AccA overflowed into guard bits
OB:
AccB overflowed into guard bits
SA:
AccA saturated (bit 31 overflow and saturation)
or
AccA overflowed into guard bits and saturated
(bit 39 overflow and saturation)
SB:
AccB saturated (bit 31 overflow and saturation)
or
AccB overflowed into guard bits and saturated
(bit 39 overflow and saturation)
OAB:
Logical OR of OA and OB
SAB:
Logical OR of SA and SB
Preliminary
dsPIC30F4011/4012
The SA and SB bits are modified each time data passes
through the adder/subtractor, but can only be cleared by
the user. When set, they 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, SA and SB default to bit 39 overflow and thus
indicate that a catastrophic overflow has occurred. If the
COVTE bit in the INTCON1 register is set, SA and SB
bits will generate an arithmetic warning trap when saturation is disabled.
The overflow and saturation status bits can optionally
be viewed in the Status Register (SR) as the logical OR
of OA and OB (in bit OAB) and the logical OR of SA and
SB (in bit SAB). This allows programmers to check one
bit in the Status Register to determine if either accumulator has overflowed, or one bit to determine if either
accumulator has saturated. This would be useful for
complex number arithmetic which typically uses both
the accumulators.
The device supports three Saturation and Overflow
modes.
1.
2.
3.
2.4.2.2
2.
2.4.2.3
Round Logic
The round logic is a combinational block, which performs a conventional (biased) or convergent (unbiased)
round function during an accumulator write (store). The
Round mode is determined by the state of the RND bit
in the CORCON register. 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 and the LS Word is
simply discarded.
Conventional rounding takes bit 15 of the accumulator,
zero-extends it and adds it to the ACCxH word (bits 16
through 31 of the accumulator). If the ACCxL word (bits
0 through 15 of the accumulator) is between 0x8000
and 0xFFFF (0x8000 included), ACCxH is incremented. If ACCxL is between 0x0000 and 0x7FFF,
ACCxH 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
ACCxL equals 0x8000. If this is the case, the LS bit (bit
16 of the accumulator) of ACCxH is examined. If it is 1,
ACCxH is incremented. If it is 0, ACCxH 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.4.2.4). Note
that for the MAC class of instructions, the accumulator
write back operation will function in the same manner,
addressing combined MCU (X and Y) data space
though the X bus. For this class of instructions, the data
is always subject to rounding.
Preliminary
DS70135C-page 21
dsPIC30F4011/4012
2.4.2.4
2.4.3
BARREL SHIFTER
DS70135C-page 22
Preliminary
dsPIC30F4011/4012
3.0
MEMORY ORGANIZATION
FIGURE 3-1:
PROGRAM SPACE
MEMORY MAP FOR
dsPIC30F4011/4012
Reset - GOTO Instruction
Reset - Target Address
000000
000002
000004
Vector Tables
Interrupt Vector Table
User Memory
Space
3.1
Reserved
Alternate Vector Table
User Flash
Program Memory
(16K instructions)
Reserved
(Read 0s)
00007E
000080
000084
0000FE
000100
007FFE
008000
7FFBFE
7FFC00
Data EEPROM
(1 Kbytes)
7FFFFE
800000
Configuration Memory
Space
Reserved
8005BE
8005C0
8005FE
800600
Reserved
Device Configuration
Registers
F7FFFE
F80000
F8000E
F80010
Reserved
DEVID (2)
Preliminary
FEFFFE
FF0000
FFFFFE
DS70135C-page 23
dsPIC30F4011/4012
TABLE 3-1:
Instruction Access
TBLRD/TBLWT
TBLRD/TBLWT
Program Space Visibility
FIGURE 3-2:
Access
Space
Access Type
User
User
(TBLPAG<7> = 0)
Configuration
(TBLPAG<7> = 1)
User
TBLPAG<7:0>
0
<0>
0
Data EA <15:0>
PSVPAG<7:0>
Data EA <14:0>
Program Counter
Select
Using
Program
Space
Visibility
EA
PSVPAG Reg
8 bits
15 bits
EA
Using
Table
Instruction
1/0
TBLPAG Reg
8 bits
User/
Configuration
Space
Select
16 bits
24-bit EA
Byte
Select
Note: Program Space Visibility cannot be used to access bits <23:16> of a word in program memory.
DS70135C-page 24
Preliminary
dsPIC30F4011/4012
3.1.1
2.
3.
4.
Figure 3-2 shows how the EA is created for table operations and data space accesses (PSV = 1). Here,
P<23:0> refers to a program space word, whereas
D<15:0> refers to a data space word.
FIGURE 3-3:
PC Address
0x000000
0x000002
0x000004
0x000006
Program Memory
Phantom Byte
(Read as 0).
23
16
00000000
00000000
00000000
00000000
TBLRDL.W
TBLRDL.B (Wn<0> = 0)
TBLRDL.B (Wn<0> = 1)
Preliminary
DS70135C-page 25
dsPIC30F4011/4012
FIGURE 3-4:
23
16
00000000
00000000
00000000
00000000
TBLRDH.B (Wn<0> = 0)
Program Memory
Phantom Byte
(Read as 0)
3.1.2
TBLRDH.B (Wn<0> = 1)
DS70135C-page 26
Note that by incrementing the PC by 2 for each program memory word, the LS 15 bits of data space
addresses directly map to the LS 15 bits in the corresponding program space addresses. The remaining
bits are provided by the Program Space Visibility Page
register, PSVPAG<7:0>, as shown in Figure 3-5.
Note:
Preliminary
dsPIC30F4011/4012
FIGURE 3-5:
Data Space
Program Space
0x000100
0x0000
EA<15> = 0
Data
Space
EA
PSVPAG(1)
0x00
8
15
16
15
EA<15> = 1
0x8000
Address
15 Concatenation 23
23
15
0
0x001200
0xFFFF
BSET
MOV
MOV
MOV
CORCON,#2
#0x00, W0
W0, PSVPAG
0x9200, W0
Data Read
Note: PSVPAG is an 8-bit register, containing bits <22:15> of the program space address
(i.e., it defines the page in program space to which the upper half of data space is being mapped).
3.2
The core has two data spaces. The data spaces can be
considered either separate (for some DSP instructions), or as one unified linear address range (for MCU
instructions). The data spaces are accessed using two
Address Generation Units (AGUs) and separate data
paths.
3.2.1
Preliminary
DS70135C-page 27
dsPIC30F4011/4012
FIGURE 3-6:
2 Kbyte
SFR Space
0x0001
LS Byte
Address
16 bits
LSB
0x0000
SFR Space
0x07FE
0x0800
0x07FF
0x0801
X Data RAM (X)
2 Kbyte
SRAM Space
0x0BFE
0x0C00
0x0BFF
0x0C01
4096 bytes
Near
Data
Space
0x0FFE
0x1001
0x1000
0x8001
0x8000
X Data
Unimplemented (X)
Optionally
Mapped
into Program
Memory
0xFFFF
DS70135C-page 28
0xFFFE
Preliminary
dsPIC30F4011/4012
DATA SPACE FOR MCU AND DSP (MAC CLASS) INSTRUCTIONS EXAMPLE
SFR SPACE
SFR SPACE
X SPACE
FIGURE 3-7:
Y SPACE
UNUSED
X SPACE
(Y SPACE)
X SPACE
UNUSED
UNUSED
Preliminary
DS70135C-page 29
dsPIC30F4011/4012
3.2.2
DATA SPACES
3.2.3
The X data space is used by all instructions and supports all addressing modes. There are separate read
and write data buses. The X read data bus is the return
data path for all instructions that view data space as
combined X and Y address space. It is also the X
address space data path for the dual operand read
instructions (MAC class). The X write data bus is the
only write path to data space for all instructions.
The X data space also supports Modulo Addressing for
all instructions, subject to Addressing mode restrictions. Bit-Reversed Addressing is only supported for
writes to X data space.
The Y data space is used in concert with the X data
space by the MAC class of instructions (CLR, ED,
EDAC, MAC, MOVSAC, MPY, MPY.N and MSC) to provide two concurrent data read paths. No writes occur
across the Y bus. This class of instructions dedicates
two W register pointers, W10 and W11, to always
address Y data space, independent of X data space,
whereas W8 and W9 always address X data space.
Note that during accumulator write back, the data
address space is considered a combination of X and Y
data spaces, so the write occurs across the X bus.
Consequently, the write can be to any address in the
entire data space.
The Y data space can only be used for the data prefetch operation associated with the MAC class of
instructions. It also supports Modulo Addressing for
automated circular buffers. Of course, all other instructions can access the Y data address space through the
X data path, as part of the composite linear space.
The boundary between the X and Y data spaces is
defined as shown in Figure 3-6 and is not user programmable. Should an EA point to data outside its own
assigned address space, or to a location outside physical memory, an all-zero word/byte will be returned. For
example, although Y address space is visible by all
non-MAC instructions using any Addressing mode, an
attempt by a MAC instruction to fetch data from that
space, using W8 or W9 (X space pointers), will return
0x0000.
TABLE 3-2:
3.2.4
DATA ALIGNMENT
FIGURE 3-8:
EFFECT OF INVALID
MEMORY ACCESSES
Attempted Operation
Data Returned
15
DATA ALIGNMENT
MS Byte
87
LS Byte
Byte 0
0000
0003
0x0000
Byte 1
Byte 3
Byte 2
0002
Byte 5
Byte 4
0004
0x0000
0001
0005
EA = an unimplemented address
0x0000
DS70135C-page 30
Preliminary
dsPIC30F4011/4012
All byte loads into any W register are loaded into the
LS Byte. The MSB is not modified.
A sign-extend (SE) instruction is provided to allow
users to translate 8-bit signed data to 16-bit signed
values. Alternatively, for 16-bit unsigned data, users
can clear the MSB of any W register by executing a
zero-extend (ZE) instruction on the appropriate
address.
Although most instructions are capable of operating on
word or byte data sizes, it should be noted that some
instructions, including the DSP instructions, operate
only on words.
3.2.5
There is a Stack Pointer Limit register (SPLIM) associated with the stack pointer. SPLIM is uninitialized at
Reset. As is the case for the stack pointer, SPLIM<0>
is forced to 0, because all stack operations must be
word aligned. Whenever an effective address (EA) is
generated using W15 as a source or destination
pointer, the address thus generated is compared with
the value in SPLIM. If the contents of the Stack Pointer
(W15) and the SPLIM register are equal and a push
operation is performed, a Stack Error Trap will not
occur. The Stack Error Trap will occur on a subsequent
push operation. Thus, for example, if it is desirable to
cause a Stack Error Trap when the stack grows beyond
address 0x2000 in RAM, initialize the SPLIM with the
value, 0x1FFE.
Similarly, a Stack Pointer Underflow (Stack Error) trap
is generated when the stack pointer address is found to
be less than 0x0800, thus preventing the stack from
interfering with the Special Function Register (SFR)
space.
A write to the SPLIM register should not be immediately
followed by an indirect read operation using W15.
FIGURE 3-9:
The dsPIC device contains a software stack. W15 is
used as the Stack Pointer.
0x0000 15
SOFTWARE STACK
Preliminary
3.2.6
PC<15:0>
000000000 PC<22:16>
<Free Word>
DS70135C-page 31
DS70135C-page 32
Preliminary
0016
0018
001A
001C
001E
0020
0022
0024
0026
0028
002A
002C
002E
0030
0032
0034
W11
W12
W13
W14
W15
SPLIM
ACCAL
ACCAH
ACCAU
ACCBL
ACCBH
ACCBU
PCL
PCH
TBLPAG
PSVPAG
0044
SR
CORCON
Bit 14
OA
YMODEN
OB
Bit 15
MODCON
0046
XMODEN
Legend:
u = uninitialized bit
0040
0042
DOENDH
003E
0014
W10
003C
0012
W9
DOENDL
0010
W8
DOSTARTH
000E
W7
003A
000C
W6
DOSTARTL
000A
W5
0036
0008
W4
0038
0006
W3
RCOUNT
0004
W2
DCOUNT
0000
0002
W0
W1
SFR Name
Bit 12
Bit 11
US
SB
SA
EDT
OAB
Sign-Extension (ACCB<39>)
DL0
DC
DOENDL
IPL2
SATA
DCOUNT
RCOUNT
PCL
ACCBH
ACCBL
ACCAH
ACCAL
SPLIM
W15
W14
W13
W12
W11
W10
W9
W8
W7
W6
W5
W4
W3
W2
W1
Bit 7
W0 / WREG
Bit 8
DOSTARTL
DL1
DA
Bit 9
BWM<3:0>
DL2
SAB
Bit 10
Sign-Extension (ACCA<39>)
Bit 13
Address
(Home)
TABLE 3-3:
Bit 3
RA
IPL3
DOENDH
DOSTARTH
PSVPAG
TBLPAG
PCH
ACCBU
ACCAU
Bit 4
SATDW ACCSAT
IPL0
Bit 5
YWM<3:0>
SATB
IPL1
Bit 6
RND
Bit 1
XWM<3:0>
PSV
OV
Bit 2
IF
Bit 0
Reset State
dsPIC30F4011/4012
004E
0050
YMODSRT
YMODEND
XBREV
BREN
Bit 15
Bit 14
Bit 13
Bit 12
Bit 11
Bit 10
Bit 9
YE<15:1>
YS<15:1>
XE<15:1>
XS<15:1>
Bit 8
Bit 6
DISICNT<13:0>
XB<14:0>
Bit 7
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
0052
u = uninitialized bit
004C
XMODEND
DISICNT
Legend:
0048
004A
XMODSRT
SFR Name
Address
(Home)
TABLE 3-3:
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Reset State
dsPIC30F4011/4012
Preliminary
DS70135C-page 33
dsPIC30F4011/4012
NOTES:
DS70135C-page 34
Preliminary
dsPIC30F4011/4012
4.0
4.1.2
MCU INSTRUCTIONS
4.1
4.1.1
Register Direct
Register Indirect
Register Indirect Post-modified
Register Indirect Pre-modified
5-bit or 10-bit Literal
Note:
TABLE 4-1:
Not all instructions support all the addressing modes given above. Individual
instructions may support different subsets
of these addressing modes.
Addressing Mode
Description
Register Direct
Register Indirect
Register Indirect with Register Offset The sum of Wn and Wb forms the EA.
Register Indirect with Literal Offset
Preliminary
DS70135C-page 35
dsPIC30F4011/4012
4.1.3
Register Direct
Register Indirect
Register Indirect Post-modified
Register Indirect Pre-modified
Register Indirect with Register Offset (Indexed)
Register Indirect with Literal Offset
8-bit Literal
16-bit Literal
Note:
4.1.4
Register Indirect
Register Indirect Post-modified by 2
Register Indirect Post-modified by 4
Register Indirect Post-modified by 6
Register Indirect with Register Offset (Indexed)
4.1.5
OTHER INSTRUCTIONS
4.2
Modulo Addressing
Modulo addressing is a method of providing an automated means to support circular data buffers using
hardware. The objective is to remove the need for software to perform data address boundary checks when
executing tightly looped code, as is typical in many
DSP algorithms.
Not all instructions support all the addressing modes given above. Individual
instructions may support different subsets
of these addressing modes.
MAC INSTRUCTIONS
Modulo addressing can operate in either data or program space (since the data pointer mechanism is essentially the same for both). One circular buffer can be
supported in each of the X (which also provides the
pointers into Program space) and Y data spaces. Modulo addressing can operate on any W register pointer.
However, it is not advisable to use W14 or W15 for Modulo addressing, since these two registers are used as
the Stack Frame Pointer and Stack Pointer, respectively.
In general, any particular circular buffer can only be
configured to operate in one direction, as there are certain restrictions on the buffer start address (for incrementing buffers) or end address (for decrementing
buffers) based upon the direction of the buffer.
The only exception to the usage restrictions is for buffers which have a power-of-2 length. As these buffers
satisfy the start and end address criteria, they may
operate in a Bi-directional mode, (i.e., address boundary checks will be performed on both the lower and
upper address boundaries).
DS70135C-page 36
Preliminary
dsPIC30F4011/4012
4.2.1
4.2.2
W ADDRESS REGISTER
SELECTION
The Modulo and Bit-Reversed Addressing Control register MODCON<15:0> contains enable flags as well as
a W register field to specify the W address registers.
The XWM and YWM fields select which registers will
operate with modulo addressing. If XWM = 15, X RAGU
and X WAGU modulo addressing are disabled. Similarly, if YWM = 15, Y AGU modulo addressing is
disabled.
The X Address Space Pointer W register (XWM) to
which modulo addressing is to be applied, is stored in
MODCON<3:0> (see Table 3-3). Modulo addressing is
enabled for X data space when XWM is set to any value
other than 15 and the XMODEN bit is set at
MODCON<15>.
The Y Address Space Pointer W register (YWM) to
which modulo addressing is to be applied, is stored in
MODCON<7:4>. Modulo addressing is enabled for Y
data space when YWM is set to any value other than 15
and the YMODEN bit is set at MODCON<14>.
FIGURE 4-1:
Byte
Address
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
DO
MOV
AGAIN:
0x1100
#0x1100,W0
W0, XMODSRT
#0x1163,W0
W0,MODEND
#0x8001,W0
W0,MODCON
#0x0000,W0
#0x1110,W1
AGAIN,#0x31
W0, [W1++]
INC
W0,W0
0x1163
Preliminary
DS70135C-page 37
dsPIC30F4011/4012
4.2.3
MODULO ADDRESSING
APPLICABILITY
4.3
Bit-Reversed Addressing
Bit-Reversed addressing is intended to simplify data reordering for radix-2 FFT algorithms. It is supported by
the X AGU for data writes only.
The modifier, which may be a constant value or register
contents, is regarded as having its bit order reversed.
The address source and destination are kept in normal
order. Thus, the only operand requiring reversal is the
modifier.
4.3.1
2.
3.
FIGURE 4-2:
BIT-REVERSED ADDRESSING
IMPLEMENTATION
b7 b6 b5 b4
b3 b2 b1
0
Bit Locations Swapped Left-to-Right
Around Center of Binary Value
b7 b6 b5 b1
b2 b3 b4
Bit-Reversed Address
Pivot Point
XB = 0x0008 for a 16-word Bit-Reversed Buffer
DS70135C-page 38
Preliminary
dsPIC30F4011/4012
TABLE 4-2:
Bit-Reversed
Address
A3
A2
A1
A0
Decimal
A3
A2
A1
A0
Decimal
12
10
14
10
11
13
12
13
11
14
15
15
TABLE 4-3:
32768
0x4000
16384
0x2000
8192
0x1000
4096
0x0800
2048
0x0400
1024
0x0200
512
0x0100
256
0x0080
128
0x0040
64
0x0020
32
0x0010
16
0x0008
0x0004
0x0002
0x0001
*Modifier values for buffer sizes greater than 1024 words will exceed the available data memory on the
dsPIC30F4011/4012 devices.
Preliminary
DS70135C-page 39
dsPIC30F4011/4012
NOTES:
DS70135C-page 40
Preliminary
dsPIC30F4011/4012
5.0
INTERRUPTS
INTCON1<15:0>, INTCON2<15:0>
Global interrupt control functions are derived from
these two registers. INTCON1 contains the control and status flags for the processor exceptions.
The INTCON2 register controls the external interrupt request signal behavior and the use of the
alternate vector table.
Note:
Interrupt Flag bits get set when an interrupt condition occurs, regardless of the
state of its corresponding Enable bit. User
software should ensure the appropriate
Interrupt Flag bits are clear prior to
enabling an interrupt.
Certain interrupts have specialized control bits for features like edge or level triggered interrupts, interrupton-change, etc. Control of these features remains
within the peripheral module which generates the
interrupt.
The DISI instruction can be used to disable the
processing of interrupts of priorities 6 and lower for a
certain number of instructions, during which the DISI bit
(INTCON2<14>) remains set.
When an interrupt is serviced, the PC is loaded with the
address stored in the vector location in Program Memory that corresponds to the interrupt. There are 63 different vectors within the IVT (refer to Figure 5-2). These
vectors are contained in locations 0x000004 through
0x0000FE of program memory (refer to Figure 5-2).
These locations contain 24-bit addresses, and in order
to preserve robustness, an address error trap will take
place should the PC attempt to fetch any of these
words during normal execution. This prevents execution of random data as a result of accidentally decrementing a PC into vector space, accidentally mapping
a data space address into vector space, or the PC rolling over to 0x000000 after reaching the end of implemented program memory space. Execution of a GOTO
instruction to this vector space will also generate an
address error trap.
Preliminary
DS70135C-page 41
dsPIC30F4011/4012
5.1
TABLE 5-1:
Interrupt Priority
DS70135C-page 42
INT
Vector
Number Number
Interrupt Source
Preliminary
dsPIC30F4011/4012
5.2
Reset Sequence
5.3
5.2.1
Traps
RESET SOURCES
If the user does not intend to take corrective action in the event of a trap error
condition, these vectors must be loaded
with the address of a default handler that
simply contains the RESET instruction. If,
on the other hand, one of the vectors
containing an invalid address is called, an
address error trap is generated.
5.3.1
TRAP SOURCES
The following traps are provided with increasing priority. However, since all traps can be nested, priority has
little effect.
2.
3.
4.
Preliminary
DS70135C-page 43
dsPIC30F4011/4012
Address Error Trap:
5.3.2
1.
2.
3.
4.
5.
6.
FIGURE 5-1:
TRAP VECTORS
1.
2.
Decreasing
Priority
IVT
AIVT
DS70135C-page 44
Preliminary
Interrupt 52 Vector
Interrupt 53 Vector
Reserved
Reserved
Reserved
Oscillator Fail Trap Vector
Stack Error Trap Vector
Address Error Trap Vector
Math Error Trap Vector
Reserved Vector
Reserved Vector
Reserved Vector
Interrupt 0 Vector
Interrupt 1 Vector
Interrupt 52 Vector
Interrupt 53 Vector
0x000000
0x000002
0x000004
0x000014
0x00007E
0x000080
0x000082
0x000084
0x000094
0x0000FE
dsPIC30F4011/4012
5.4
Interrupt Sequence
5.5
FIGURE 5-2:
5.6
A context saving option is available using shadow registers. Shadow registers are provided for the DC, N,
OV, Z and C bits in SR, and the registers W0 through
W3. The shadows are only one level deep. The shadow
registers are accessible using the PUSH.S and POP.S
instructions only.
INTERRUPT STACK
FRAME
0x0000 15
PC<15:0>
SRL IPL3 PC<22:16>
<Free Word>
5.7
5.8
Preliminary
DS70135C-page 45
IFS2
CNIF
DS70135C-page 46
CNIE
008C
008E
0090
0094
0096
0098
IEC0
IEC1
IEC2
IPC0
IPC1
IPC2
T31P<2:0>
T1IP<2:0>
SI2CIE
009E
00A0
00A2
00A4
00A6
00A8
00AA
u = uninitialized bit
IPC5
IPC6
IPC7
IPC8
IPC9
IPC10
IPC11
Legend:
Preliminary
FLTAIP<2:0>
PWMIP<2:0>
FLTAIE
C1IE
ADIE
FLTAIF
C1IF
ADIF
Bit 11
U2TXIF
U1RXIF
OVBTE
Bit 9
SPI1IE
QEIIF
U2RXIF
SPI1IF
COVTE
Bit 8
T5IP<2:0>
IC8IP<2:0>
MI2CIP<2:0>
U1TXIP<2:0>
T2IP<2:0>
OC1IP<2:0>
QEIIE
U2TXIE U2RXIE
U1TXIE U1RXIE
U1TXIF
OVATE
Bit 10
PWMIE
INT2IE
T3IE
PWMIF
INT2IF
T3IF
Bit 7
T5IE
T2IE
T5IF
T2IF
Bit 6
Bit 4
U2TXIP<2:0>
T4IP<2:0>
IC7IP<2:0>
SI2CIP<2:0>
U1RXIP<2:0>
OC2IP<2:0>
OC4IE
IC2IE
OC4IF
IC2IF
MATHERR
IC1IP<2:0>
T4IE
OC2IE
T4IF
OC2IF
Bit 5
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
C1IP<2:0>
INT2IP<2:0>
NVMIE
OC3IP<2:0>
CNIP<2:0>
Bit 12
NVMIF
009A
009C
IPC4
IPC3
ADIP<2:0>
MI2CIE
0088
SI2CIF
MI2CIF
IFS1
Bit 13
Bit 14
0084
0086
IFS0
0080 NSTDIS
0082 ALTIVT
Bit 15
INTCON1
ADR
INTCON2
SFR
Name
TABLE 5-2:
OC3IE
T1IE
OC3IF
T1IF
ADDRERR
Bit 3
Bit 1
IC8IE
OC1IE
IC8IF
OC1IF
INT2EP
QEIIP<2:0>
U2RXIP<2:0>
OC4IP<2:0>
INT1IP<2:0>
NVMIP<2:0>
SPI1IP<2:0>
IC2IP<2:0>
INT0IP<2:0>
IC7IE
IC1IE
IC7IF
IC1IF
INT1EP
STKERR OSCFAIL
Bit 2
Reset State
INT1IE
INT0IE
INT1IF
INT0IF
Bit 0
dsPIC30F4011/4012
dsPIC30F4011/4012
6.0
6.2
6.3
6.1
FIGURE 6-1:
Program Counter
NVMADR Reg EA
Using
NVMADR
Addressing
1/0
NVMADRU Reg
8 bits
16 bits
Working Reg EA
Using
Table
Instruction
User/Configuration
Space Select
1/0
TBLPAG Reg
8 bits
16 bits
24-bit EA
Preliminary
Byte
Select
DS70135C-page 47
dsPIC30F4011/4012
6.4
RTSP Operation
6.5
NVMCON
NVMADR
NVMADRU
NVMKEY
6.5.1
NVMCON REGISTER
6.5.2
NVMADR REGISTER
6.5.3
6.5.4
NVMKEY REGISTER
DS70135C-page 48
NVMADRU REGISTER
Preliminary
dsPIC30F4011/4012
6.6
Programming Operations
4.
6.6.1
5.
2.
3.
EXAMPLE 6-1:
6.
6.6.2
write
Preliminary
DS70135C-page 49
dsPIC30F4011/4012
6.6.3
EXAMPLE 6-2:
; 31st_program_word
MOV
#LOW_WORD_31,W2
;
MOV
#HIGH_BYTE_31,W3
;
; Write PM low word into program latch
TBLWTL W2, [W0]
; Write PM high byte into program latch
TBLWTH W3, [W0++]
Note: In Example 6-2, the contents of the upper byte of W3 has no effect.
6.6.4
EXAMPLE 6-3:
DISI
#5
MOV
MOV
MOV
MOV
BSET
NOP
NOP
#0x55,W0
W0,NVMKEY
#0xAA,W1
W1,NVMKEY
NVMCON,#WR
DS70135C-page 50
Preliminary
NVMADRU
Bit 14
WREN
0762
0764
NVMADR
WR
Bit 15
Bit 9
Bit 8
Bit 7
NVMADR<15:0>
TWRI
Bit 6
Bit 5
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
NVMKEY
0766
Legend:
u = uninitialized bit
WRERR
Bit 13
0760
Addr.
NVMCON
File Name
TABLE 6-1:
Bit 3
Bit 2
KEY<7:0>
NVMADR<22:16>
PROGOP<6:0>
Bit 4
Bit 1
Bit 0
All RESETS
dsPIC30F4011/4012
Preliminary
DS70135C-page 51
dsPIC30F4011/4012
NOTES:
DS70135C-page 52
Preliminary
dsPIC30F4011/4012
7.0
NVMCON
NVMADR
NVMADRU
NVMKEY
Control bit WR initiates write operations, similar to program Flash writes. This bit cannot be cleared, only set,
in software. This bit is cleared in hardware at the completion of the write operation. The inability to clear the
WR bit in software prevents the accidental or
premature termination of a write operation.
The WREN bit, when set, will allow a write operation.
On power-up, the WREN bit is clear. The WRERR bit is
set when a write operation is interrupted by a MCLR
Reset, or a WDT Time-out Reset, during normal operation. In these situations, following Reset, the user can
check the WRERR bit and rewrite the location. The
address register NVMADR remains unchanged.
Note:
7.1
Interrupt flag bit NVMIF in the IFS0 register is set when write is complete. It must be
cleared in software.
A TBLRD instruction reads a word at the current program word address. This example uses W0 as a
pointer to data EEPROM. The result is placed in
register W4, as shown in Example 7-1.
EXAMPLE 7-1:
MOV
MOV
MOV
TBLRDL
Preliminary
DS70135C-page 53
dsPIC30F4011/4012
7.2
7.2.1
EXAMPLE 7-2:
7.2.2
EXAMPLE 7-3:
DS70135C-page 54
Preliminary
dsPIC30F4011/4012
7.3
2.
3.
EXAMPLE 7-4:
7.3.1
#0x55,W0
W0,NVMKEY
#0xAA,W1
W1,NVMKEY
NVMCON,#WR
; Init pointer
; Get data
; Write data
complete in 2mS. CPU is not stalled for the Data Write Cycle
bit, use NVMIF or Timer IRQ to determine write complete
Preliminary
DS70135C-page 55
dsPIC30F4011/4012
7.3.2
EXAMPLE 7-5:
MOV
MOV
MOV
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
TBLWTL
MOV
MOV
DISI
MOV
MOV
MOV
MOV
BSET
NOP
NOP
7.4
#LOW_ADDR_WORD,W0
#HIGH_ADDR_WORD,W1
W1,TBLPAG
#data1,W2
W2,[ W0]++
#data2,W2
W2,[ W0]++
#data3,W2
W2,[ W0]++
#data4,W2
W2,[ W0]++
#data5,W2
W2,[ W0]++
#data6,W2
W2,[ W0]++
#data7,W2
W2,[ W0]++
#data8,W2
W2,[ W0]++
#data9,W2
W2,[ W0]++
#data10,W2
W2,[ W0]++
#data11,W2
W2,[ W0]++
#data12,W2
W2,[ W0]++
#data13,W2
W2,[ W0]++
#data14,W2
W2,[ W0]++
#data15,W2
W2,[ W0]++
#data16,W2
W2,[ W0]++
#0x400A,W0
W0,NVMCON
#5
#0x55,W0
W0,NVMKEY
#0xAA,W1
W1,NVMKEY
NVMCON,#WR
; Init pointer
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
Write Verify
7.5
DS70135C-page 56
Preliminary
dsPIC30F4011/4012
8.0
I/O PORTS
When a pin is shared with another peripheral or function that is defined as an input only, it is nevertheless
regarded as a dedicated port because there is no
other competing source of outputs. An example is the
INT4 pin.
8.1
A parallel I/O (PIO) port that shares a pin with a peripheral is, in general, subservient to the peripheral. The
peripherals output buffer data and control signals are
provided to a pair of multiplexers. The multiplexers
select whether the peripheral or the associated port
has ownership of the output data and control signals of
the I/O pad cell. Figure 8-2 shows how ports are shared
with other peripherals, and the associated I/O cell (pad)
to which they are connected. Table 8-1 and shows the
formats of the registers for the shared ports, PORTB
through PORTG.
FIGURE 8-1:
Read TRIS
I/O Cell
TRIS Latch
Data Bus
WR TRIS
CK
Data Latch
D
WR LAT +
WR Port
I/O Pad
CK
Read LAT
Read Port
Preliminary
DS70135C-page 57
dsPIC30F4011/4012
FIGURE 8-2:
Peripheral Module
Peripheral Input Data
Peripheral Module Enable
I/O Cell
PIO Module
Output Enable
Output Data
0
Read TRIS
I/O Pad
Data Bus
WR TRIS
CK
TRIS Latch
D
WR LAT +
WR Port
CK
Data Latch
Read LAT
Input Data
Read Port
8.2
8.2.1
DS70135C-page 58
EXAMPLE 8-1:
MOV
0xFF00, W0
MOV
NOP
btss
W0, TRISBB
Preliminary
PORTB, #13
PORT WRITE/READ
EXAMPLE
;
;
;
;
;
Configure PORTB<15:8>
as inputs
and PORTB<7:0> as outputs
Delay 1 cycle
Next Instruction
02DC
02EE
LATE
TRISF
02E0
02DA
PORTE
LATC15
RC15
LATC14
RC14
LATC13
RC13
Bit 12
Bit 11
Bit 10
Bit 9
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RE8
LATE8
TRISE8
LATB7
LATB8
RB7
RB8
LATB4
RB4
LATB2
RB2
LATB1
RB1
LATB0
RB0
RD2
LATD2
RD3
LATD3
LATD1
RD1
LATD0
RD0
LATB3
RB3
LATE5
RE5
LATE4
RE4
LATE3
RE3
LATE2
RE2
LATE1
RE1
LATE0
RE0
LATB5
RB5
LATF6
RF6
LATF5
RF5
LATF4
RF4
LATF3
RF3
LATF2
RF2
LATF1
RF1
LATF0
RF0
LATB6
RB6
Bit 8
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
u = uninitialized bit
LATF
Legend:
02E2
PORTF
02D8
TRISE
02D2
TRISD
02D4
02D0
LATC
02D6
02CE
PORTC
LATD
TRISC
PORTD
02CB
LATB
02C8
02C6
TRISB
Bit 13
PORTB
Bit 14
Bit 15
Addr.
SFR
Name
TABLE 8-1:
Reset State
dsPIC30F4011/4012
Preliminary
DS70135C-page 59
DS70135C-page 60
02E0
02EE
TRISF
LATC15
RC15
LATC14
RC14
LATC13
RC13
Bit 12
Bit 11
Bit 10
Bit 9
Bit 7
RE8
LATE8
TRISE8
Bit 8
Bit 6
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RB3
LATB3
RB2
LATB2
RB1
RB0
LATB0
RD0
LATD0
RD1
TRISD1 TRISD0
LATB1
LATD1
LATE5
RE5
LATE4
RE4
LATE2
RE2
LATF3
RF3
LATF2
RF2
TRISF3 TRISF2
LATE3
RE3
LATE1
RE1
LATE0
RE0
RB4
LATB4
RB5
LATB5
Bit 5
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
u = uninitialized bit
LATF
Legend:
02E2
PORTF
02DC
LATE
02D6
LATD
02D8
02D4
PORTD
02DA
02D2
TRISD
PORTE
02D0
LATC
TRISE
02CE
PORTC
TRISC
02C8
Bit 13
02CB
Bit 14
LATB
Bit 15
PORTB
02C6
Addr.
TRISB
SFR
Name
TABLE 8-2:
Reset State
dsPIC30F4011/4012
Preliminary
dsPIC30F4011/4012
8.3
TABLE 8-3:
SFR Name
Addr.
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Reset State
CNEN1
00C0
CN7IE
CN6IE
CN5IE
CN4IE
CN3IE
CN2IE
CN1IE
CN0IE
CNEN2
00C2
CN18IE*
CN17IE*
CNPU1
00C4
CN7PUE
CN6PUE
CN5PUE
CN4PUE
CN3PUE
CN2PUE
CN1PUE
CN0PUE
00C6
CN18PUE*
CN17PUE*
CNPU2
Legend:
u = uninitialized bit
*Not available on dsPIC30F4012
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
Preliminary
DS70135C-page 61
dsPIC30F4011/4012
NOTES:
DS70135C-page 62
Preliminary
dsPIC30F4011/4012
9.0
TIMER1 MODULE
Preliminary
DS70135C-page 63
dsPIC30F4011/4012
FIGURE 9-1:
Equal
Comparator x 16
TSYNC
1
Reset
(3)
TMR1
Sync
0
0
Q
CK
TGATE
TCS
TGATE
SOSCO/
T1CK
1X
Gate
Sync
SOSCI
When the CPU goes into the Idle mode, the timer will
stop incrementing, unless TSIDL = 0. If TSIDL = 1, the
timer will resume the incrementing sequence upon
termination of the CPU Idle mode.
Timer Prescaler
TCKPS<1:0>
TON
00
9.3
The 16-bit timer can be placed in the Gated Time Accumulation mode. This mode allows the internal TCY to
increment the respective timer when the gate input signal (T1CK pin) is asserted high. Control bit TGATE
(T1CON<6>) must be set to enable this mode. The
timer must be enabled (TON = 1) and the timer clock
source set to internal (TCS = 0).
9.2
01
TCY
LPOSCEN
9.1
TGATE
T1IF
Event Flag
Prescaler
1, 8, 64, 256
DS70135C-page 64
Preliminary
dsPIC30F4011/4012
9.4
9.5.1
Timer Interrupt
Enabling an interrupt is accomplished via the respective Timer Interrupt Enable bit, T1IE. The Timer Interrupt Enable bit is located in the IEC0 control register in
the Interrupt Controller.
When the CPU enters Sleep mode, the RTC will continue to operate, provided the 32 kHz external crystal
oscillator is active and the control bits have not been
changed. The TSIDL bit should be cleared to 0 in
order for RTC to continue operation in Idle mode.
9.5
9.5.2
Real-Time Clock
FIGURE 9-2:
RTC INTERRUPTS
When an interrupt event occurs, the respective interrupt flag, T1IF, is asserted and an interrupt will be generated, if enabled. The T1IF bit must be cleared in
software. The respective Timer interrupt flag, T1IF, is
located in the IFS0 status register in the Interrupt
Controller.
Enabling an interrupt is accomplished via the respective Timer Interrupt Enable bit, T1IE. The Timer Interrupt Enable bit is located in the IEC0 control register in
the Interrupt Controller.
RECOMMENDED
COMPONENTS FOR
TIMER1 LP OSCILLATOR
RTC
C1
SOSCI
32.768 kHz
XTAL
dsPIC30FXXXX
SOSCO
C2
C1 = C2 = 18 pF; R = 100K
Preliminary
DS70135C-page 65
0102
PR1
Bit 15
DS70135C-page 66
TSIDL
Bit 13
Bit 12
Bit 11
Bit 10
Bit 9
Bit 7
Bit 6
TGATE
Period Register 1
Timer 1 Register
Bit 8
Bit 4
TCKPS1 TCKPS0
Bit 5
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
Bit 14
0104
TON
u = uninitialized bit
0100
TMR1
T1CON
Legend:
Addr.
SFR Name
TABLE 9-1:
Bit 3
TSYNC
Bit 2
TCS
Bit 1
Bit 0
Reset State
dsPIC30F4011/4012
Preliminary
dsPIC30F4011/4012
10.0
TIMER2/3 MODULE
Note:
Input Capture
Output Compare/Simple PWM
Preliminary
DS70135C-page 67
dsPIC30F4011/4012
FIGURE 10-1:
Data Bus<15:0>
TMR3HLD
16
16
Write TMR2
Read TMR2
16
Reset
TMR3
TMR2
MSB
LSB
Sync
Comparator x 32
PR3
PR2
0
T3IF
Event Flag
CK
TGATE(T2CON<6>)
TCS
TGATE
TGATE
(T2CON<6>)
TON
T2CK
1X
Gate
Sync
01
TCY
Note:
TCKPS<1:0>
2
Prescaler
1, 8, 64, 256
00
Timer Configuration bit T32, T2CON(<3>) must be set to 1 for a 32-bit timer/counter operation. All control
bits are respective to the T2CON register.
DS70135C-page 68
Preliminary
dsPIC30F4011/4012
FIGURE 10-2:
Reset
Comparator x 16
TMR2
Sync
T2IF
Event Flag
CK
TGATE
TCS
TGATE
1
TGATE
TON
T2CK
TCKPS<1:0>
2
1X
Gate
Sync
TCY
FIGURE 10-3:
Prescaler
1, 8, 64, 256
01
00
Equal
Reset
T3IF
Event Flag
Comparator x 16
TMR3
0
D
CK
TGATE
TCS
TGATE
Q
Q
1
TGATE
Sync
TON
1X
01
TCY
Note:
TCKPS<1:0>
2
Prescaler
1, 8, 64, 256
00
The dsPIC30F4011/4012 devices do not have external pin inputs to TIMER3. In these devices the following
modes should not be used:
1. TCS = 1
2. TCS = 0 and TGATE = 1 (gated time accumulation)
Preliminary
DS70135C-page 69
dsPIC30F4011/4012
10.1
10.4
The 32-bit timer can be placed in the Gated Time Accumulation mode. This mode allows the internal TCY to
increment the respective timer when the gate input signal (T2CK pin) is asserted high. Control bit TGATE
(T2CON<6>) must be set to enable this mode. When in
this mode, Timer2 is the originating clock source. The
TGATE setting is ignored for Timer3. The timer must be
enabled (TON = 1) and the timer clock source set to
internal (TCS = 0).
The falling edge of the external signal terminates the
count operation, but does not reset the timer. The user
must reset the timer in order to start counting from zero.
10.2
10.3
10.5
Timer Interrupt
Timer Prescaler
DS70135C-page 70
Preliminary
010A
010C
010E
0110
TMR3
PR2
PR3
T2CON
TON
Bit 12
Bit 11
Bit 9
Bit 7
Timer2 Register
Bit 8
Bit 6
Bit 5
TGATE
TGATE
Period Register 3
Period Register 2
Timer3 Register
Bit 4
TCKPS1 TCKPS0
TCKPS1 TCKPS0
Bit 10
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
0112
TON
u = uninitialized bit
0108
T3CON
Legend:
0106
TMR2
TMR3HLD
Bit 13
Bit 15
Bit 14
TABLE 10-1:
T32
Bit 3
Bit 2
TCS
TCS
Bit 1
Bit 0
Reset State
dsPIC30F4011/4012
Preliminary
DS70135C-page 71
dsPIC30F4011/4012
NOTES:
DS70135C-page 72
Preliminary
dsPIC30F4011/4012
11.0
TIMER4/5 MODULE
FIGURE 11-1:
TMR5HLD
16
16
Write TMR4
Read TMR4
16
Reset
TMR4
MSB
Equal
TMR5
LSB
Comparator x 32
PR5
PR4
0
1
TGATE
(T4CON<6>)
CK
TGATE(T4CON<6>)
TCS
TGATE
T5IF
Event Flag
Sync
1X
Gate
Sync
TCY
Note:
01
TCKPS<1:0>
TON
2
Prescaler
1, 8, 64, 256
00
Timer Configuration bit T32, T4CON(<3>) must be set to 1 for a 32-bit timer/counter operation. All
control bits are respective to the T4CON register.
The dsPIC30F4011/4012 devices do not have external pin inputs to TIMER4 or TIMER5. In these
devices the following modes should not be used: (1) TCS = 1, (2) TCS = 0 and (3) TGATE = 1 (gated
time accumulation)
Preliminary
DS70135C-page 73
dsPIC30F4011/4012
FIGURE 11-2:
Equal
Comparator x 16
Reset
Sync
0
1
CK
TGATE
TCS
TGATE
TGATE
T4IF
Event Flag
TMR4
TCKPS<1:0>
TON
1X
Gate
Sync
TCY
Note:
DS70135C-page 74
01
Prescaler
1, 8, 64, 256
00
The dsPIC30F4011/4012 devices do not have external pin inputs to TIMER4 or TIMER5. In these
devices the following modes should not be used:
1. TCS = 1
2. TCS = 0 and TGATE = 1 (gated time accumulation)
Preliminary
dsPIC30F4011/4012
FIGURE 11-3:
Equal
Comparator x 16
TMR5
Reset
0
Q
CK
TGATE
TCS
TGATE
TGATE
T5IF
Event Flag
TCKPS<1:0>
TON
Sync
01
TCY
Note:
1X
Prescaler
1, 8, 64, 256
00
The dsPIC30F4011/4012 devices do not have external pin inputs to TIMER4 or TIMER5. In these
devices the following modes should not be used:
1. TCS = 1
2. TCS = 0 and TGATE = 1 (gated time accumulation)
Preliminary
DS70135C-page 75
DS70135C-page 76
TON
Bit 15
TSIDL
Bit 13
Bit 12
Bit 11
Bit 9
Bit 7
Bit 6
Timer 4 Register
Bit 8
Bit 5
TGATE
TGATE
Period Register 5
Period Register 4
Timer 5 Register
TCKPS1
TCKPS1
Bit 10
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
TSIDL
Bit 14
0120
TON
u = uninitialized bit
011E
T4CON
T5CON
Legend:
011A
011C
PR4
TMR5
PR5
0116
0118
TMR5HLD
0114
Addr.
TMR4
SFR Name
TABLE 11-1:
TCKPS0
TCKPS0
Bit 4
T45
Bit 3
Bit 2
TCS
TCS
Bit 1
Bit 0
Reset State
dsPIC30F4011/4012
Preliminary
dsPIC30F4011/4012
12.0
Note:
Frequency/Period/Pulse Measurements
Additional sources of External Interrupts
FIGURE 12-1:
T3_CNT
T2_CNT
16
ICx
Pin
16
ICTMR
1
Prescaler
1, 4, 16
3
Edge
Detection
Logic
Clock
Synchronizer
FIFO
R/W
Logic
ICM<2:0>
Mode Select
ICxBUF
ICBNE, ICOV
ICI<1:0>
ICxCON
Interrupt
Logic
Set Flag
ICxIF
Data Bus
Note:
Where x is shown, reference is made to the registers or bits associated to the respective input
capture channels 1 through N.
Preliminary
DS70135C-page 77
dsPIC30F4011/4012
12.1
12.1.3
CAPTURE PRESCALER
There are four input capture prescaler settings, specified by bits ICM<2:0> (ICxCON<2:0>). Whenever the
capture channel is turned off, the prescaler counter will
be cleared. In addition, any Reset will clear the
prescaler counter.
12.1.2
12.1.1
12.1.4
12.2
12.2.1
CPU Sleep mode allows input capture module operation with reduced functionality. In the CPU Sleep
mode, the ICI<1:0> bits are not applicable, and the
input capture module can only function as an external
interrupt source.
The capture module must be configured for interrupt
only on the rising edge (ICM<2:0> = 111), in order for
the input capture module to be used while the device
is in Sleep mode. The prescale settings of 4:1 or 16:1
are not applicable in this mode.
DS70135C-page 78
Preliminary
dsPIC30F4011/4012
12.2.2
12.3
Preliminary
DS70135C-page 79
DS70135C-page 80
0144
0146
0158
015A
015C
015E
IC2BUF
IC2CON
IC7BUF
IC7CON
IC8BUF
IC8CON
Bit 15
ICSIDL
ICSIDL
ICSIDL
ICSIDL
Bit 13
Bit 12
Bit 11
Bit 10
Bit 8
Bit 7
ICTMR
ICTMR
ICTMR
ICTMR
Bit 9
Bit 5
ICI<1:0>
ICI<1:0>
ICI<1:0>
ICI<1:0>
Bit 6
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
Bit 14
u = uninitialized bit
0142
IC1CON
Legend:
0140
IC1BUF
TABLE 12-1:
ICOV
ICOV
ICOV
ICOV
Bit 4
ICBNE
ICBNE
ICBNE
ICBNE
Bit 3
Bit 2
ICM<2:0>
ICM<2:0>
ICM<2:0>
ICM<2:0>
Bit 1
Bit 0
Reset State
dsPIC30F4011/4012
Preliminary
dsPIC30F4011/4012
13.0
FIGURE 13-1:
OCxRS
Output
Logic
OCxR
3
OCM<2:0>
Mode Select
Comparator
S Q
R
OCx
Output Enable
OCFA
(for x = 1, 2, 3 or 4)
OCTSEL
Note:
TMR3<15:0> T2P2_MATCH
T3P3_MATCH
Where x is shown, reference is made to the registers associated with the respective output compare
channels 1 through N.
Preliminary
DS70135C-page 81
dsPIC30F4011/4012
13.1
13.2
13.3.1
4.
DS70135C-page 82
3.
13.4
13.3
13.3.2
13.4.1
Preliminary
dsPIC30F4011/4012
13.4.2
PWM PERIOD
The PWM period is specified by writing to the PRx register. The PWM period can be calculated using
Equation 13-1.
EQUATION 13-1:
PWM PERIOD
FIGURE 13-1:
Duty Cycle
TMR3 = PR3
T3IF = 1
(Interrupt Flag)
OCxR = OCxRS
13.5
TMR3 = PR3
T3IF = 1
(Interrupt Flag)
OCxR = OCxRS
TMR3 = Duty Cycle (OCxR)
TMR3 = Duty Cycle (OCxR)
13.6
13.7
The output compare channels have the ability to generate an interrupt on a compare match, for whichever
Match mode has been selected.
For all modes except the PWM mode, when a compare
event occurs, the respective interrupt flag (OCxIF) is
asserted and an interrupt will be generated, if enabled.
The OCxIF bit is located in the corresponding IFS
Status register, and must be cleared in software. The
interrupt is enabled via the respective compare interrupt enable (OCxIE) bit, located in the corresponding
IEC Control register.
For the PWM mode, when an event occurs, the respective timer interrupt flag (T2IF or T3IF) is asserted and
an interrupt will be generated, if enabled. The IF bit is
located in the IFS0 Status register, and must be cleared
in software. The interrupt is enabled via the respective
Timer Interrupt Enable bit (T2IE or T3IE), located in the
IEC0 Control register. The output compare interrupt
flag is never set during the PWM mode of operation.
Preliminary
DS70135C-page 83
0184
0186
0188
018A
018C
018E
0190
0192
0194
OC1CON
OC2RS
OC2R
OC2CON
OC3RS*
OC3R*
OC3CON*
DS70135C-page 84
OC4RS*
OC4R*
OCSIDL
OCSIDL
OCSIDL
Bit 8
Bit 7
Bit 6
Bit 5
Bit 9
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
OC4CON*
0196
OCSIDL
Legend:
u = uninitialized bit, * = not available on dsPIC30F4012
0182
Bit 10
0180
Bit 11
OC1R
Bit 12
OC1RS
Bit 13
Bit 15
Addr.
SFR Name
Bit 14
TABLE 13-1:
OCFLT
OCFLT
OCFLT
OCFLT
Bit 4
OCTSEL
OCTSEL
OCTSE
OCTSEL
Bit 3
Bit 2
OCM<2:0>
OCM<2:0>
OCM<2:0>
OCM<2:0>
Bit 1
Bit 0
Reset State
dsPIC30F4011/4012
Preliminary
dsPIC30F4011/4012
14.0
QUADRATURE ENCODER
INTERFACE (QEI) MODULE
This section describes the Quadrature Encoder Interface (QEI) module and associated operational modes.
The QEI module provides the interface to incremental
encoders for obtaining mechanical position data.
FIGURE 14-1:
Sleep Input
TQCS
TCY
Synchronize
Det
0
Prescaler
1, 8, 64, 256
1
1
QEIM<2:0>
0
QEA
Programmable
Digital Filter
UPDN_SRC
0
QEICON<11>
2
Quadrature
Encoder
Interface Logic
QEB
Equal
Programmable
Digital Filter
INDX
3
QEIM<2:0>
Mode Select
QEIIF
Event
Flag
CK
TQGATE
Programmable
Digital Filter
3
Up/Down
Note: In dsPIC30F4011/4012, the UPDN pin is not available. Up/Down logic bit can still be polled by software.
Preliminary
DS70135C-page 85
dsPIC30F4011/4012
14.1
14.2.2
14.2
14.2.1
14.2.3
QEI pins are multiplexed with analog inputs. User must insure that all QEI associated pins are set as digital
inputs in the ADPCFG register.
DS70135C-page 86
Preliminary
dsPIC30F4011/4012
14.3
14.5
There are two Measurement modes which are supported and are termed x2 and x4. These modes are
selected by the QEIM<2:0> mode select bits located in
SFR QEICON<10:8>.
When control bits QEIM<2:0> = 100 or 101, the x2
Measurement mode is selected and the QEI logic only
looks at the Phase A input for the position counter
increment rate. Every rising and falling edge of the
Phase A signal causes the position counter to be incremented or decremented. The Phase B signal is still
utilized for the determination of the counter direction,
just as in the x4 mode.
Within the x2 Measurement mode, there are two
variations of how the position counter is reset:
1.
2.
The x4 Measurement mode provides for finer resolution data (more position counts) for determining motor
position.
14.4
The digital noise filter section is responsible for rejecting noise on the incoming capture or quadrature signals. Schmitt Trigger inputs and a three-clock cycle
delay filter combine to reject low level noise and large,
short duration noise spikes that typically occur in noise
prone applications, such as a motor system.
14.6
14.6.1
14.6.2
Preliminary
DS70135C-page 87
dsPIC30F4011/4012
14.7
14.7.1
14.7.2
When the CPU is placed in the Idle mode and the QEI
module is configured in the 16-bit Timer mode, the
16-bit timer will operate if the QEISIDL bit
(QEICON<13>) = 0. This bit defaults to a logic 0 upon
executing POR and BOR. For halting the timer module
during the CPU Idle mode, QEISIDL should be set
to 1.
14.8
DS70135C-page 88
Preliminary
Bit 15
0128
MAXCNT
QEISIDL
Bit 13
INDX
Bit 12
UPDN
Bit 11
IMV1
QEIM2
Bit 10
Bit 8
Bit 7
IMV0
Maximun Count<15:0>
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Reset State
PCFG5
PCFG4
QECK0
PCFG3
PCFG2
PCFG1
PCFG0
TQGATE TQCKPS1 TQCKPS0 POSRES TQCS UPDN_SRC 0000 0000 0000 0000
Bit 5
Bit 6
Position Counter<15:0>
CEID
Bit 9
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
ADPCFG 02A8
Legend:
u = uninitialized bit
0126
POSCNT
Bit 14
0122 CNTERR
Addr.
DFLTCON 0124
QEICON
SFR
Name
TABLE 14-1:
dsPIC30F4011/4012
Preliminary
DS70135C-page 89
dsPIC30F4011/4012
NOTES:
DS70135C-page 90
Preliminary
dsPIC30F4011/4012
15.0
Preliminary
DS70135C-page 91
dsPIC30F4011/4012
FIGURE 15-1:
FLTACON
OVDCON
PWM Manual
Control SFR
PWM Generator #3
PDC3 Buffer
PDC3
Comparator
PWM Generator
#2
PTMR
PWM3H
Channel 3 Dead-Time
Generator and
Override Logic
Channel 2 Dead-Time
Generator and
Override Logic
Comparator
PWM3L
PWM2H
Output
Driver
PWM2L
Block
PWM Generator
#1
Channel 1 Dead-Time
Generator and
Override Logic
PTPER
PWM1H
PWM1L
FLTA
PTPER Buffer
PTCON
Comparator
SEVTDIR
SEVTCMP
Special Event
Postscaler
PTDIR
DS70135C-page 92
Preliminary
dsPIC30F4011/4012
15.1
15.1.1
15.1.2
15.1.3
CONTINUOUS UP/DOWN
COUNTING MODES
Preliminary
DS70135C-page 93
dsPIC30F4011/4012
15.1.4
15.1.5
EQUATION 15-1:
TPWM =
can
The match output of PTMR can optionally be postscaled through a 4-bit postscaler (which gives a 1:1 to
1:16 scaling).
The postscaler counter is cleared when any of the
following occurs:
a write to the PTMR register
a write to the PTCON register
any device Reset
TCY (PTPER + 1)
EQUATION 15-2:
15.3
PWM RESOLUTION
log (2 TPWM / TCY)
log (2)
FIGURE 15-2:
PWM Period
PTPER
PTPER is a 15-bit register and is used to set the counting period for the PWM time base. PTPER is a double
buffered register. The PTPER buffer contents are
loaded into the PTPER register at the following instants:
Free Running and Single Shot modes: When the
PTMR register is reset to zero after a match with
the PTPER register.
Up/Down Counting modes: When the PTMR
register is zero.
The value held in the PTPER buffer is automatically
loaded into the PTPER register when the PWM time
base is disabled (PTEN = 0).
DS70135C-page 94
using
15.2
determined
PWM PERIOD
Resolution =
be
15.1.6
Preliminary
PTMR
Value
0
Duty Cycle
Period
dsPIC30F4011/4012
15.4
15.5.1
Center aligned PWM signals are produced by the module when the PWM time base is configured in an Up/
Down Counting mode (see Figure 15-3).
The PWM compare output is driven to the active state
when the value of the duty cycle register matches the
value of PTMR and the PWM time base is counting
downwards (PTDIR = 1). The PWM compare output is
driven to the inactive state when the PWM time base is
counting upwards (PTDIR = 0) and the value in the
PTMR register matches the duty cycle value.
If the value in a particular duty cycle register is zero,
then the output on the corresponding PWM pin will be
inactive for the entire PWM period. In addition, the output on the PWM pin will be active for the entire PWM
period if the value in the duty cycle register is equal to
the value held in the PTPER register.
FIGURE 15-3:
Period/2
PTPER
The three PWM duty cycle registers are double buffered to allow glitchless updates of the PWM outputs.
For each duty cycle, there is a duty cycle register that
is accessible by the user and a second duty cycle register that holds the actual compare value used in the
present PWM period.
For edge aligned PWM output, a new duty cycle value
will be updated whenever a match with the PTPER register occurs and PTMR is reset. The contents of the
duty cycle buffers are automatically loaded into the
duty cycle registers when the PWM time base is disabled (PTEN = 0) and the UDIS bit is cleared in
PWMCON2.
When the PWM time base is in the Up/Down Counting
mode, new duty cycle values are updated when the
value of the PTMR register is zero and the PWM time
base begins to count upwards. The contents of the duty
cycle buffers are automatically loaded into the duty
cycle registers when the PWM time base is disabled
(PTEN = 0).
When the PWM time base is in the Up/Down Counting
mode with double updates, new duty cycle values are
updated when the value of the PTMR register is zero,
and when the value of the PTMR register matches the
value in the PTPER register. The contents of the duty
cycle buffers are automatically loaded into the duty
cycle registers when the PWM time base is disabled
(PTEN = 0).
PTMR
Value
Duty
Cycle
15.6
Period
15.5
Preliminary
DS70135C-page 95
dsPIC30F4011/4012
15.7
15.7.1
Dead-Time Generators
15.7.2
DEAD-TIME RANGES
FIGURE 15-4:
DEAD-TIME GENERATORS
PWMxH
PWMxL
DS70135C-page 96
Preliminary
dsPIC30F4011/4012
15.8
An independent PWM Output mode is required for driving certain types of loads. A particular PWM output pair
is in the Independent Output mode when the corresponding PMOD bit in the PWMCON1 register is set.
No dead-time control is implemented between adjacent
PWM I/O pins when the module is operating in the
Independent mode and both I/O pins are allowed to be
active simultaneously.
In the Independent mode, each duty cycle generator is
connected to both of the PWM I/O pins in an output
pair. By using the associated duty cycle register and
the appropriate bits in the OVDCON register, the user
may select the following signal output options for each
PWM I/O pin operating in the Independent mode:
All control bits associated with the PWM output override function are contained in the OVDCON register.
The upper half of the OVDCON register contains six
bits, POVDxH<3:1> and POVDxL<3:1>, that determine
which PWM I/O pins will be overridden. The lower half
of the OVDCON register contains six bits,
POUTxH<3:1> and POUTxL<3:1>, that determine the
state of the PWM I/O pins when a particular output is
overridden via the POVD bits.
15.10.1
15.9
The PWM output override bits allow the user to manually drive the PWM I/O pins to specified logic states,
independent of the duty cycle comparison units.
15.10.2
OVERRIDE SYNCHRONIZATION
Preliminary
DS70135C-page 97
dsPIC30F4011/4012
15.11 PWM Output and Polarity Control
15.12.2
15.11.1
15.12.1
FAULT STATES
15.12.3
The FAULT pin logic can operate independent of the PWM logic. If all the enable bits
in the FLTACON register are cleared, then
the FAULT pin could be used as a general
purpose interrupt pin. The FAULT pin has
an interrupt vector, Interrupt Flag bit and
Interrupt Priority bits associated with it.
DS70135C-page 98
Preliminary
dsPIC30F4011/4012
15.13 PWM Update Lockout
15.14.1
Preliminary
DS70135C-page 99
DS70135C-page 100
01D0
01D4
01D6
01D8
01DA
FLTACON
OVDCON
PDC1
PDC2
PDC3
Bit 14
Bit 13
POVD3H
FAOV3H
PTSIDL
POVD3L
FAOV3L
Bit 12
POVD2H
FAOV2H
Bit 11
POVD2L
FAOV2L
Bit 5
PTOPS<3:0>
Bit 6
POVD1L
PEN3H
FLTAM
DTAPS<1:0>
POVD1H
FAOV1L
PTMOD1
PEN1H
Bit 4
Bit 2
PEN3L
FAEN3
Dead-Time A Value
PTCKPS<1:0>
Bit 3
Bit 0
FAEN2
OSYNC
PEN2L
FAEN1
UDIS
PEN1L
PTMOD<1:0>
Bit 1
PEN2H
FAOV1H
Bit 7
Bit 8
PTMOD2
Bit 9
SEVOPS<3:0>
PTMOD3
Bit 10
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
u = uninitialized bit
01CC
DTCON1
Legend:
01C8
01CA
01C6 SEVTDIR
SEVTCMP
PWMCON1
01C4
PTPER
PWMCON2
01C2
PTMR
PTDIR
PTEN
01C0
PTCON
Bit 15
TABLE 15-1:
Reset State
dsPIC30F4011/4012
Preliminary
dsPIC30F4011/4012
16.0
SPI MODULE
The Serial Peripheral Interface (SPI) module is a synchronous serial interface. It is useful for communicating
with other peripheral devices such as EEPROMs, shift
registers, display drivers and A/D converters, or other
microcontrollers. It is compatible with Motorola's SPI
and SIOP interfaces.
16.1
16.1.1
16.1.2
16.2
SDO1 DISABLE
Preliminary
DS70135C-page 101
dsPIC30F4011/4012
FIGURE 16-1:
Write
SPI1BUF
SPI1BUF
Transmit
Receive
SPI1SR
SDI1
bit0
SDO1
Shift
clock
Clock
Control
SS & FSYNC
Control
SS1
Edge
Select
Secondary
Prescaler
1,2,4,6,8
SCK1
Primary
Prescaler
1, 4, 16, 64
FCY
FIGURE 16-2:
SPI Master
SPI Slave
SDOx
SDIy
SDIx
Shift Register
(SPIxSR)
MSb
SDOy
LSb
Shift Register
(SPIySR)
MSb
SCKx
Serial Clock
PROCESSOR 1
LSb
SCKy
PROCESSOR 2
Note: x = 1 or 2, y = 1 or 2.
DS70135C-page 102
Preliminary
dsPIC30F4011/4012
16.3
16.4
16.5
Preliminary
DS70135C-page 103
0220
0222
SPI1STAT
SPI1CON
Bit 13
FRMEN
SPIEN
DS70135C-page 104
Bit 12
Bit 10
DISSDO MODE16
Bit 11
CKE
Bit 8
SSEN
Bit 7
CKP
SPIROV
Bit 6
SMP
Bit 9
MSTEN
Bit 5
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
SPIFSD
SPISIDL
Bit 14
Bit 15
SPI1BUF
0224
Legend:
u = uninitialized bit
Addr.
SFR
Name
TABLE 16-1:
SPRE2
Bit 4
SPRE1
Bit 3
SPRE0
Bit 2
PPRE1
SPITBF
Bit 1
Reset State
PPRE0
Bit 0
dsPIC30F4011/4012
Preliminary
dsPIC30F4011/4012
17.0
I2C MODULE
17.1.1
17.1
17.1.2
I2C has a 2-pin interface; pin SCL is clock and pin SDA
is data.
17.1.3
I2C REGISTERS
FIGURE 17-1:
PROGRAMMERS MODEL
I2CRCV (8 bits)
bit 7
bit 0
bit 7
bit 0
I2CTRN (8 bits)
I2CBRG (9 bits)
bit 8
bit 0
I2CCON (16-bits)
bit 15
bit 0
bit 15
bit 0
I2CSTAT (16-bits)
I2CADD (10-bits)
bit 9
bit 0
Preliminary
DS70135C-page 105
dsPIC30F4011/4012
FIGURE 17-2:
I2CRCV
Read
SCL
Shift
Clock
I2CRSR
LSB
SDA
Addr_Match
Match Detect
Write
I2CADD
Read
Start and
Stop bit Detect
I2CSTAT
Write
Control Logic
Start, Restart,
Stop bit Generate
Write
I2CCON
Collision
Detect
Acknowledge
Generation
Clock
Stretching
Read
Read
Write
I2CTRN
LSB
Shift
Clock
Read
Reload
Control
BRG Down
Counter
DS70135C-page 106
Write
I2CBRG
FCY
Preliminary
Read
dsPIC30F4011/4012
17.2
17.3.2
TABLE 17-1:
SLAVE RECEPTION
0x00
0x01-0x03
Reserved
0x04-0x77
17.4
0x78-0x7b
0x7c-0x7f
Reserved
In 10-bit mode, the basic receive and transmit operations are the same as in the 7-bit mode. However, the
criteria for address match is more complex.
17.3
17.3.1
SLAVE TRANSMISSION
17.4.1
Preliminary
DS70135C-page 107
dsPIC30F4011/4012
17.4.2
17.5
17.5.1
17.5.2
17.5.3
DS70135C-page 108
17.5.4
17.6
Preliminary
dsPIC30F4011/4012
17.7
Interrupts
17.8
Slope Control
2
17.9
IPMI Support
17.12.1
Transmission of a data byte, a 7-bit address, or the second half of a 10-bit address is accomplished by simply
writing a value to I2CTRN register. The user should
only write to I2CTRN when the module is in a WAIT
state. This action will set the buffer full flag (TBF) and
allow the baud rate generator to begin counting and
start the next transmission. Each bit of address/data
will be shifted out onto the SDA pin after the falling
edge of SCL is asserted. The Transmit Status Flag,
TRSTAT (I2CSTAT<14>), indicates that a master
transmit is in progress.
Preliminary
DS70135C-page 109
dsPIC30F4011/4012
17.12.2
EQUATION 17-1:
17.12.3
I2CBRG =
17.12.4
I2CBRG VALUE
FCY
( FSCL
FCY
1,111,111
CLOCK ARBITRATION
17.12.5
MULTI-MASTER COMMUNICATION,
BUS COLLISION AND BUS
ARBITRATION
DS70135C-page 110
17.13.2
For the I2C, the I2CSIDL bit selects if the module will
stop on Idle or continue on Idle. If I2CSIDL = 0, the
module will continue operation on assertion of the Idle
mode. If I2CSIDL = 1, the module will stop on Idle.
Preliminary
0204
0206
0208
I2CBRG
I2CCON
I2CSTAT
ACKSTAT
Bit 13
Bit 12
Bit 11
DISSLW
Bit 9
GCSTAT
A10M
Bit 10
BCL
ADD10
SMEN
Bit 8
IWCOL
GCEN
Bit 7
I2COV
STREN
Bit 6
Bit 3
Transmit Register
Receive Register
Bit 4
Address Register
D_A
ACKEN
S
RCEN
Bit 5
ACKDT
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
TRSTAT
I2CEN
Bit 14
Bit 15
020A
u = uninitialized bit
0202
I2CADD
Legend:
0200
I2CRCV
I2CTRN
TABLE 17-2:
R_W
PEN
Bit 2
RBF
RSEN
Bit 1
TBF
SEN
Bit 0
Reset State
dsPIC30F4011/4012
Preliminary
DS70135C-page 111
dsPIC30F4011/4012
NOTES:
DS70135C-page 112
Preliminary
dsPIC30F4011/4012
18.0
UNIVERSAL ASYNCHRONOUS
RECEIVER TRANSMITTER
(UART) MODULE
18.1
FIGURE 18-1:
UTX8
Write
Transmit Control
Control TSR
Control Buffer
Generate Flags
Generate Interrupt
Load TSR
UxTXIF
UTXBRK
Data
UxTX
1 (Stop)
Parity
Parity
Generator
16 Divider
Control
Signals
Note: x = 1 or 2.
dsPIC30F4012 only has UART1.
Preliminary
DS70135C-page 113
dsPIC30F4011/4012
FIGURE 18-2:
16
Write
Read
Read Read
UxMODE
URX8
Write
UxSTA
Load RSR
to Buffer
Receive Shift Register
(UxRSR)
Control
Signals
FERR
UxRX
8-9
PERR
LPBACK
From UxTX
16 Divider
DS70135C-page 114
Preliminary
dsPIC30F4011/4012
18.2
18.2.1
18.3
18.3.1
18.2.2
1.
2.
3.
4.
18.2.3
18.2.4
5.
18.3.2
ALTERNATE I/O
Transmitting Data
18.3.3
Preliminary
DS70135C-page 115
dsPIC30F4011/4012
18.3.4
TRANSMIT INTERRUPT
18.4.2
b)
18.3.5
TRANSMIT BREAK
18.4.3
RECEIVE INTERRUPT
a)
b)
18.4
Switching between the Interrupt modes during operation is possible, though generally not advisable during
normal operation.
18.4.1
Receiving Data
RECEIVING IN 8-BIT OR 9-BIT DATA
MODE
4.
5.
DS70135C-page 116
c)
18.5
18.5.1
Preliminary
dsPIC30F4011/4012
18.5.2
18.6
18.5.3
18.5.4
IDLE STATUS
18.5.5
RECEIVE BREAK
18.7
Loopback Mode
18.8
EQUATION 18-1:
BAUD RATE
Preliminary
DS70135C-page 117
dsPIC30F4011/4012
18.9
18.10.2
For the UART, the USIDL bit selects if the module will
stop operation when the device enters Idle mode, or
whether the module will continue on Idle. If USIDL = 0,
the module will continue operation during Idle mode. If
USIDL = 1, the module will stop on Idle.
DS70135C-page 118
Preliminary
0210
0212
U1TXREG
U1RXREG
UARTEN
UTXISEL
USIDL
021A
021C
U2TXREG
U2RXREG
ALTIO
Bit 10
UTXBRK UTXEN
Bit 11
URX8
UTX8
TRMT
Bit 8
LPBACK
Bit 12
Bit 10
UTXBRK UTXEN
Bit 11
UTXBF
Bit 9
Bit 6
LPBACK
Bit 6
ABAUD
Bit 5
PERR
Bit 3
RIDLE
Bit 4
PERR
Bit 3
Receive Register
Transmit Register
RIDLE
Bit 4
Receive Register
Transmit Register
WAKE
Bit 7
URX8
UTX8
TRMT
Bit 8
ABAUD
Bit 5
WAKE
Bit 7
UTXBF
Bit 9
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
021E
u = uninitialized bit
USIDL
UARTEN
UTXISEL
0216
0218
U2MODE
Bit 13
Bit 14
U2STA
Bit 15
Addr.
U2BRG
Legend:
Bit 12
SFR
Name
TABLE 18-2:
0214
u = uninitialized bit
020E
U1BRG
Legend:
020C
U1MODE
U1STA
Bit 13
Bit 15
Bit 14
TABLE 18-1:
Bit 1
Bit 0
Reset State
Bit 1
OERR
FERR
OERR
PDSEL1 PDSEL0
Bit 2
FERR
Reset State
Bit 0
Bit 2
dsPIC30F4011/4012
Preliminary
DS70135C-page 119
dsPIC30F4011/4012
NOTES:
DS70135C-page 120
Preliminary
dsPIC30F4011/4012
19.0
CAN MODULE
19.1
Overview
19.2
Frame Types
Preliminary
DS70135C-page 121
dsPIC30F4011/4012
FIGURE 19-1:
BUFFERS
Acceptance Filter
RXF2
Message
Queue
Control
Acceptance Mask
RXM0
MESSAGE
MSGREQ
TXABT
TXLARB
TXERR
MTXBUFF
R
X
B
0
Acceptance Filter
RXF4
Acceptance Filter
RXF1
A
c
c
e
p
t
Acceptance Filter
RXF5
Identifier
M
A
B
Data Field
Data Field
PROTOCOL
ENGINE
TERRCNT
C1TX
ErrPas
BusOff
Receive Shift
Protocol
Finite
State
Machine
CRC Check
Bit
Timing
Logic
Transmit
Logic
DS70135C-page 122
RERRCNT
Transmit
Error
Counter
CRC Generator
R
X
B
1
Identifier
Receive
Error
Counter
Transmit Shift
A
c
c
e
p
t
Acceptance Filter
RXF3
Acceptance Filter
RXF0
TXB2
MESSAGE
MSGREQ
TXABT
TXLARB
TXERR
MTXBUFF
TXB1
MESSAGE
MSGREQ
TXABT
TXLARB
TXERR
MTXBUFF
TXB0
Bit Timing
Generator
C1RX
Preliminary
dsPIC30F4011/4012
19.3
Modes of Operation
The CAN Module can operate in one of several operation modes selected by the user. These modes include:
Initialization Mode
Disable Mode
Normal Operation Mode
Listen Only Mode
Loop Back Mode
Error Recognition Mode
Note:
19.3.1
INITIALIZATION MODE
19.3.2
19.3.3
19.3.4
19.3.5
DISABLE MODE
19.3.6
If the loopback mode is activated, the module will connect the internal transmit signal to the internal receive
signal at the module boundary. The transmit and
receive pins revert to their Port I/O function.
Preliminary
DS70135C-page 123
dsPIC30F4011/4012
19.4
19.4.1
Message Reception
19.4.4
RECEIVE BUFFERS
19.4.2
19.4.3
RECEIVE OVERRUN
19.4.5
RECEIVE ERRORS
19.4.6
RECEIVE INTERRUPTS
DS70135C-page 124
Preliminary
dsPIC30F4011/4012
Receive Error Interrupts
A receive error interrupt will be indicated by the ERRIF
bit. This bit shows that an error condition occurred. The
source of the error can be determined by checking the
bits in the CAN Interrupt Status Register C1INTF.
Invalid message received
If any type of error occurred during reception of
the last message, an error will be indicated by the
IVRIF bit.
Receiver overrun
The RXnOVR bit indicates that an overrun condition occurred.
Receiver warning
The RXWAR bit indicates that the Receive Error
Counter (RERRCNT<7:0>) has reached the
Warning limit of 96.
Receiver error passive
The RXEP bit indicates that the Receive Error
Counter has exceeded the Error Passive limit of
127 and the module has gone into Error Passive
state.
19.5
19.5.1
Message Transmission
TRANSMIT BUFFERS
19.5.2
19.5.3
TRANSMISSION SEQUENCE
19.5.4
ABORTING MESSAGE
TRANSMISSION
19.5.5
TRANSMISSION ERRORS
Preliminary
DS70135C-page 125
dsPIC30F4011/4012
19.5.6
19.6
TRANSMIT INTERRUPTS
Transmit Interrupt
FIGURE 19-2:
19.6.1
BIT TIMING
The time segments and also the nominal bit time are
made up of integer units of time called time quanta or
TQ. By definition, the Nominal Bit Time has a minimum
of 8 TQ and a maximum of 25 TQ. Also, by definition,
the minimum nominal bit time is 1 sec, corresponding
to a maximum bit rate of 1 MHz.
Input Signal
Sync
Prop
Segment
Phase
Segment 1
Phase
Segment 2
Sync
Sample Point
TQ
DS70135C-page 126
Preliminary
dsPIC30F4011/4012
19.6.2
PRESCALER SETTING
19.6.5
There is a programmable prescaler, with integral values ranging from 1 to 64, in addition to a fixed divideby-2 for clock generation. The Time Quantum (TQ) is a
fixed unit of time derived from the oscillator period, and
is given by Equation 19-1, where FCAN is FCY (if the
CANCKS bit is set or 4 FCY (if CANCKS is cleared).
Note:
EQUATION 19-1:
19.6.6
PROPAGATION SEGMENT
19.6.4
TQ = 2 ( BRP<5:0> + 1 ) / FCAN
19.6.3
SAMPLE POINT
PHASE SEGMENTS
SYNCHRONIZATION
19.6.6.1
Hard Synchronization
19.6.6.2
Re-synchronization
Preliminary
DS70135C-page 127
DS70135C-page 128
0322
0324
C1RXF4EIDH
C1RXF4EIDL
Preliminary
u = uninitialized bit
0356
C1TX1B1
Legend:
0352
0350
C1TX1SID
0354
034E
C1TX1DLC
034C
C1TX2B4
C1TX2CON
C1TX1EID
0348
034A
C1TX2B2
C1TX2B3
0346
C1TX2B1
0342
0344
C1TX2DLC
C1TX2EID
0340
C1TX2SID
033C
C1RXM1EIDH 033A
C1RXM1EIDL
0338
C1RXM1SID
C1RXM0EIDH 0332
0334
0330
C1RXM0EIDL
032C
C1RXM0SID
C1RXF5EIDL
032A
Bit 11
C1RXF5EIDH
Bit 12
0328
0320
Bit 13
Bit 14
Bit 15
C1RXF5SID
031C
0314
C1RXF2EIDL
C1RXF4SID
0312
C1RXF2EIDH
C1RXF3EIDL
0310
C1RXF2SID
0318
030C
C1RXF1EIDL
031A
030A
C1RXF1EIDH
C1RXF3EIDH
0308
C1RXF1SID
C1RXF3SID
0302
0304
C1RXF0EIDH
0300
C1RXF0SID
C1RXF0EIDL
Addr.
SFR Name
TABLE 19-1:
Bit 10
Bit 9
Bit 8
Bit 7
Bit 6
Bit 5
TXRTR
TXRTR
TXRB1
TXRB1
TXRB0
TXRB0
Bit 2
TXERR
TXREQ
DLC<3:0>
TXABT
DLC<3:0>
Bit 3
Bit 4
Bit 0
TXIDE
MIDE
MIDE
EXIDE
EXIDE
EXIDE
EXIDE
EXIDE
EXIDE
SRR
TXIDE
TXPRI<1:0>
SRR
Bit 1
Reset State
dsPIC30F4011/4012
Bit 11
0368
036A
036C
036E
0370
C1TX0B2
C1TX0B3
C1TX0B4
C1TX0CON
C1RX1SID
037C
037E
0380
C1RX1B4
C1RX1CON
C1RX0SID
Preliminary
038E
0390
0392
0394
0396
C1CTRL
C1CFG1
C1CFG2
C1INTF
0398
038C
C1RX0B4
C1RX0CON
RX0OVR
CANCAP
RX1OVR
WAKFIL
TXEP
ABAT
RXEP
CANCKS
TXBO
CSIDLE
TXRB1
Bit 8
TXRB0
Bit 7
RXRB1
SEG2PH<2:0>
RXRB1
REQOP<2:0>
RXRTR
TXERR
RXFUL
TXABT
TXERR
IVRIE
IVRIF
SEG2PHTS
WAKIE
WAKIF
SAM
SJW<1:0>
RXRB0
TX2IE
SRR
RXIDE
DLC<3:0>
SRR
RXIDE
FILHIT<2:0>
TX1IE
TX1IF
TX0IE RX1E
RX0IE
RX0IF
PRSEG<2:0>
TX0IF RX1IF
BRP<5:0>
ICODE<2:0>
ERRIE
TX2IF
TXIDE
TXPRI<1:0>
SRR
DLC<3:0>
Bit 0
TXPRI<1:0>
Bit 1
SEG1PH<2:0>
ERRIF
RXRTRRO
RXRB0
TXREQ
DLC<3:0>
TXLARB
OPMODE<2:0>
RXFUL
Bit 2
TXREQ
Bit 3
TXLARB
RXRTR
Bit 4
Bit 5
TXABT
Bit 6
TXRTR
Bit 9
Bit 10
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
u = uninitialized bit
C1EC
Legend:
039A
C1INTE
0388
038A
C1RX0B2
C1RX0B3
0386
C1RX0B1
0382
0384
C1RX0DLC
C1RX0EID
0378
037A
C1RX1B2
C1RX1B3
0376
C1RX1B1
0372
0374
C1RX1DLC
C1RX1EID
0366
C1TX0B1
0362
0364
0360
C1TX0SID
C1TX0DLC
035E
C1TX1CON
Bit 12
C1TX0EID
035A
035C
C1TX1B3
Bit 13
Transmit Buffer 1 Byte 5
Bit 14
Transmit Buffer 1 Byte 3
Bit 15
0358
Addr.
C1TX1B4
C1TX1B2
SFR Name
TABLE 19-1:
Reset State
dsPIC30F4011/4012
DS70135C-page 129
dsPIC30F4011/4012
NOTES:
DS70135C-page 130
Preliminary
dsPIC30F4011/4012
20.0
The ADCON1, ADCON2 and ADCON3 registers control the operation of the A/D module. The ADCHS register selects the input channels to be converted. The
ADPCFG register configures the port pins as analog
inputs or as digital I/O. The ADCSSL register selects
inputs for scanning.
Note:
Preliminary
DS70135C-page 131
dsPIC30F4011/4012
FIGURE 20-1:
VREF+
VREF-
+
-
ADC
10-bit Result
S/H
Conversion Logic
CH2
16-word, 10-bit
Dual Port
Buffer
AN2
AN5
AN8
AN2
CH1
S/H
CH3
CH1,CH2,
CH3,CH0
sample
AN3
AN0
AN1
AN2
AN3
AN4
AN4
AN5
AN5
*AN6
AN6
*AN7
AN7
*AN8
AN8
AN1
Sample/Sequence
Control
Bus Interface
AN1
AN4
S/H
Data
Format
AN7
AN1
AN0
AN3
AN6
AN0
input
switches
S/H
Input Mux
Control
CH0
DS70135C-page 132
Preliminary
dsPIC30F4011/4012
20.1
20.2
Conversion Operation
20.3
The CHPS bits selects how many channels are sampled. This can vary from 1, 2 or 4 channels. If CHPS
selects 1 channel, the CH0 channel will be sampled at
the sample clock and converted. The result is stored in
the buffer. If CHPS selects 2 channels, the CH0 and
CH1 channels will be sampled and converted. If CHPS
selects 4 channels, the CH0, CH1, CH2 and CH3
channels will be sampled and converted.
The SMPI bits select the number of acquisition/conversion sequences that would be performed before an
interrupt occurs. This can vary from 1 sample per
interrupt to 16 samples per interrupt.
The user cannot program a combination of CHPS and
SMPI bits that specifies more than 16 conversions per
interrupt, or 8 conversions per interrupt, depending on
the BUFM bit. The BUFM bit, when set, will split the
16--word results buffer (ADCBUF0...ADCBUFF) into
two 8-word groups. Writing to the 8-word buffers will be
alternated on each interrupt event. Use of the BUFM bit
will depend on how much time is available for moving
data out of the buffers after the interrupt, as determined
by the application.
If the processor can quickly unload a full buffer within
the time it takes to acquire and convert one channel,
the BUFM bit can be 0 and up to 16 conversions may
be done per interrupt. The processor will have one
sample and conversion time to move the sixteen
conversions.
If the processor cannot unload the buffer within the
acquisition and conversion time, the BUFM bit should
be 1. For example, if SMPI<3:0> (ADCON2<5:2>) =
0111, then eight conversions will be loaded into 1/2 of
the buffer, following which an interrupt occurs. The next
eight conversions will be loaded into the other 1/2 of the
buffer. The processor will have the entire time between
interrupts to move the eight conversions.
The ALTS bit can be used to alternate the inputs
selected during the sampling sequence. The input multiplexer has two sets of sample inputs: MUX A and
MUX B. If the ALTS bit is 0, only the MUX A inputs are
selected for sampling. If the ALTS bit is 1 and
SMPI<3:0> = 0000, on the first sample/convert
sequence, the MUX A inputs are selected, and on the
next acquire/convert sequence, the MUX B inputs are
selected.
The CSCNA bit (ADCON2<10>) will allow the CH0
channel inputs to be alternately scanned across a
selected number of analog inputs for the MUX A group.
The inputs are selected by the ADCSSL register. If a
particular bit in the ADCSSL register is 1, the corresponding input is selected. The inputs are always
scanned from lower to higher numbered inputs, starting
after each interrupt. If the number of inputs selected is
greater than the number of samples taken per interrupt,
the higher numbered inputs are unused.
Preliminary
DS70135C-page 133
dsPIC30F4011/4012
20.4
20.6
EQUATION 20-1:
To operate the A/D at the maximum specified conversion speed, the Auto Convert
Trigger option should be selected (SSRC
= 111) and the Auto Sample Time bits
shoud be set to 1 TAD (SAMC = 00001).
This configuration will give a total conversion period (sample + convert) of 13 TAD.
EXAMPLE 20-1:
20.5
Aborting a Conversion
ADCS<5:0> = 2
Therefore,
Set ADCS<5:0> = 9
TCY
(ADCS<5:0> + 1)
2
33 nsec
=
(9 + 1)
2
Actual TAD =
= 165 nsec
DS70135C-page 134
Preliminary
dsPIC30F4011/4012
20.7
FIGURE 20-2:
Rs
VA
ANx
CPIN
RIC 250
VT = 0.6V
Sampling
Switch
RSS 3 k
RSS
VT = 0.6V
I leakage
500 nA
CHOLD
= DAC capacitance
= 4.4 pF
VSS
Legend: CPIN
= input capacitance
VT
= threshold voltage
I leakage = leakage current at the pin due to
various junctions
RIC
= interconnect resistance
RSS
= sampling switch resistance
CHOLD
= sample/hold capacitance (from DAC)
Note: CPIN value depends on device package and is not tested. Effect of CPIN negligible if Rs 5 k.
Preliminary
DS70135C-page 135
dsPIC30F4011/4012
20.8
20.9
20.9.1
20.9.2
FIGURE 20-3:
RAM Contents:
d09 d08 d07 d06 d05 d04 d03 d02 d01 d00
Read to Bus:
Signed Fractional (1.15)
d09 d08 d07 d06 d05 d04 d03 d02 d01 d00
Fractional (1.15)
d09 d08 d07 d06 d05 d04 d03 d02 d01 d00
Signed Integer
Integer
DS70135C-page 136
d09 d09 d09 d09 d09 d09 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00
d09 d08 d07 d06 d05 d04 d03 d02 d01 d00
Preliminary
dsPIC30F4011/4012
20.12 Configuring Analog Port Pins
An external RC filter is sometimes added for antialiasing of the input signal. The R component should be
selected to ensure that the sampling time requirements
are satisfied. Any external components connected (via
high impedance) to an analog input pin (capacitor,
zener diode, etc.) should have very little leakage
current at the pin.
Preliminary
DS70135C-page 137
DS70135C-page 138
0282
0284
0286
0288
028A
028C
028E
0290
0292
0294
0296
0298
029A
029C
ADCBUF1
ADCBUF2
ADCBUF3
ADCBUF4
ADCBUF5
ADCBUF6
ADCBUF7
ADCBUF8
ADCBUF9
ADCBUFA
ADCBUFB
ADCBUFC
ADCBUFD
ADCBUFE
Preliminary
02A6
02A8
ADCHS
ADPCFG
CH0NB
Bit 12
CSCNA
Bit 10
CSSL8*
PCFG8*
CHPS<1:0>
CH0SB<3:0>
Bit 8
FORM<1:0>
Bit 9
SAMC<4:0>
Bit 11
CSSL*7
PCFG7*
CSSL6*
PCFG6*
Bit 5
Bit 4
CSSL5
PCFG5
SIMSAM
Bit 3
CSSL4
PCFG4
CH0NA
ASAM
Bit 2
CSSL3
PCFG3
BUFM
SAMP
Bit 1
ALTS
DONE
Bit 0
CSSL2
CSSL1
CSSL0
CH0SA<3:0>
ADCS<5:0>
SMPI<3:0>
CH123SA
SSRC<2:0>
Bit 6
CH123NA<1:0>
ADRC
BUFS
Bit 7
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
CH123SB
ADSIDL
VCFG<2:0>
Bit 13
CH123NB<1:0>
ADON
Bit 14
Bit 15
02AA
u = uninitialized bit
02A4
ADCON3
ADCSSL
Legend:
02A0
02A2
ADCON1
ADCON2
029E
0280
ADCBUF0
ADCBUFF
Addr.
SFR Name
TABLE 20-1:
Reset State
dsPIC30F4011/4012
dsPIC30F4011/4012
21.0
SYSTEM INTEGRATION
21.1
There are several features intended to maximize system reliability, minimize cost through elimination of
external components, provide Power Saving Operating
modes and offer code protection:
Oscillator Selection
Reset
- Power-on Reset (POR)
- Power-up Timer (PWRT)
- Oscillator Start-up Timer (OST)
- Programmable Brown-out Reset (BOR)
Watchdog Timer (WDT)
Power Saving modes (Sleep and Idle)
Code Protection
Unit ID Locations
In-Circuit Serial Programming (ICSP)
Preliminary
DS70135C-page 139
dsPIC30F4011/4012
TABLE 21-1:
Oscillator Mode
Description
XTL
XT
XT w/ PLL 4x
XT w/ PLL 8x
XT w/ PLL 16x
LP
HS
EC
ECIO
EC w/ PLL 4x
External clock input (0-40 MHz), OSC2 pin is I/O, 4x PLL enabled(1)
EC w/ PLL 8x
External clock input (0-40 MHz), OSC2 pin is I/O, 8x PLL enabled(1)
EC w/ PLL 16x
External clock input (0-40 MHz), OSC2 pin is I/O, 16x PLL enabled(1)
ERC
ERCIO
FRC
FRC w/ PLL 4x
FRC w/ PLL 8x
LPRC
Note 1:
2:
3:
DS70135C-page 140
Preliminary
dsPIC30F4011/4012
FIGURE 21-1:
OSC1
OSC2
Primary
Oscillator
PLL
x4, x8, x16
PLL
Lock
COSC<1:0>
Primary Osc
NOSC<1:0>
Primary
Oscillator
Stability Detector
POR Done
OSWEN
Oscillator
Start-up
Timer
Clock
Secondary Osc
Switching
and Control
Block
SOSCO
SOSCI
32 kHz LP
Oscillator
Secondary
Oscillator
Stability Detector
Programmable
Clock Divider System
Clock
2
POST<1:0>
FRC
Internal Fast RC
Oscillator (FRC)
Internal Low
Power RC
Oscillator (LPRC)
LPRC
FCKSM<1:0>
2
Fail-Safe Clock
Monitor (FSCM)
CF
Oscillator Trap
to Timer1
Preliminary
DS70135C-page 141
dsPIC30F4011/4012
21.2
21.2.1
Oscillator Configurations
21.2.2
b)
TABLE 21-2:
Oscillator Mode
Oscillator
Source
FOS1
FOS0
FPR3
FPR2
FPR1
FPR0
OSC2
Function
EC
Primary
CLKO
ECIO
Primary
I/O
EC w/PLL 4x
Primary
I/O
EC w/PLL 8x
Primary
I/O
EC w/PLL 16x
Primary
I/O
ERC
Primary
CLKO
ERCIO
Primary
I/O
XT
Primary
OSC2
XT w/PLL 4x
Primary
OSC2
XT w/PLL 8x
Primary
OSC2
XT w/PLL 16x
Primary
OSC2
XTL
Primary
OSC2
HS
Primary
OSC2
FRC w/PLL 4x
Primary
I/O
FRC w/PLL 8x
Primary
I/O
Primary
I/O
LP
Secondary
(Notes 1, 2)
FRC
Internal FRC
(Notes 1, 2)
LPRC
Internal LPRC
(Notes 1, 2)
Note 1: OSC2 pin function is determined by the Primary Oscillator mode selection (FPR<3:0>).
2: Note that OSC1 pin cannot be used as an I/O pin, even if the secondary oscillator or an internal clock
source is selected at all times.
21.2.3
LP OSCILLATOR CONTROL
DS70135C-page 142
Preliminary
dsPIC30F4011/4012
21.2.4
TABLE 21-4:
TABLE 21-3:
Fin
4 MHz-10 MHz
4 MHz-10 MHz
4 MHz-7.5 MHz
TUN<3:0>
Bits
0111
0110
0101
0100
0011
0010
0001
0000
Fout
16 MHz-40 MHz
32 MHz-80 MHz
64 MHz-120 MHz
1111
1110
1101
1100
1011
1010
1001
1000
21.2.5
21.2.6
FRC TUNING
FRC Frequency
+ 10.5%
+ 9.0%
+ 7.5%
+ 6.0%
+ 4.5%
+ 3.0%
+ 1.5%
Center Frequency (oscillator is
running at calibrated frequency)
- 1.5%
- 3.0%
- 4.5%
- 6.0%
- 7.5%
- 9.0%
- 10.5%
- 12.0%
Preliminary
DS70135C-page 143
dsPIC30F4011/4012
21.2.7
Primary
Secondary
Internal FRC
Internal LPRC
21.2.8
PROTECTION AGAINST
ACCIDENTAL WRITES TO OSCCON
DS70135C-page 144
Preliminary
dsPIC30F4011/4012
21.3
Reset
FIGURE 21-2:
Different registers are affected in different ways by various Reset conditions. Most registers are not affected
by a WDT wake-up, since this is viewed as the resumption of normal operation. Status bits from the RCON
register are set or cleared differently in different Reset
situations, as indicated in Table 21-5. These bits are
used in software to determine the nature of the Reset.
A block diagram of the on-chip Reset circuit is shown in
Figure 21-2.
A MCLR noise filter is provided in the MCLR Reset
path. The filter detects and ignores small pulses.
Internally generated Resets do not drive MCLR pin low.
RESET
Instruction
Digital
Glitch Filter
MCLR
Sleep or Idle
WDT
Module
POR
VDD Rise
Detect
VDD
Brown-out
Reset
BOR
BOREN
R
SYSRST
TRAP Conflict
Illegal Opcode/
Uninitialized W Register
21.3.1
Preliminary
DS70135C-page 145
dsPIC30F4011/4012
FIGURE 21-3:
MCLR
INTERNAL POR
TOST
OST TIME-OUT
TPWRT
PWRT TIME-OUT
INTERNAL Reset
FIGURE 21-4:
VDD
MCLR
INTERNAL POR
TOST
OST TIME-OUT
TPWRT
PWRT TIME-OUT
INTERNAL Reset
FIGURE 21-5:
VDD
MCLR
INTERNAL POR
TOST
OST TIME-OUT
TPWRT
PWRT TIME-OUT
INTERNAL Reset
DS70135C-page 146
Preliminary
dsPIC30F4011/4012
21.3.1.1
21.3.1.2
FIGURE 21-6:
21.3.2
BOR: PROGRAMMABLE
BROWN-OUT RESET
VDD
D
2.0V
2.7V
4.2V
4.5V
Note:
MCLR
dsPIC30F
R
R1
The BOR module allows selection of one of the following voltage trip points:
EXTERNAL POWER-ON
RESET CIRCUIT (FOR
SLOW VDD POWER-UP)
Preliminary
DS70135C-page 147
dsPIC30F4011/4012
Table 21-5 shows the Reset conditions for the RCON
Register. Since the control bits within the RCON register are R/W, the information in the table implies that all
the bits are negated prior to the action specified in the
condition column.
TABLE 21-5:
Condition
Program
Counter
Power-on Reset
0x000000
Brown-out Reset
0x000000
0x000000
0x000000
0x000000
0x000000
0x000000
WDT Wake-up
PC + 2
PC + 2(1)
0x000004
Trap Reset
0x000000
0x000000
Legend:
Note 1:
TABLE 21-6:
Condition
Program
Counter
Power-on Reset
0x000000
Brown-out Reset
0x000000
0x000000
0x000000
0x000000
0x000000
0x000000
PC + 2
PC + 2
(1)
0x000004
Trap Reset
0x000000
0x000000
WDT Wake-up
Legend:
Note 1:
DS70135C-page 148
Preliminary
dsPIC30F4011/4012
21.4
21.4.1
21.5.1
21.4.2
21.5
SLEEP MODE
Preliminary
DS70135C-page 149
dsPIC30F4011/4012
Any interrupt that is individually enabled (using the
corresponding IE bit) and meets the prevailing priority
level will be able to wake-up the processor. The processor will process the interrupt and branch to the ISR.
The Sleep status bit in RCON register is set upon
wake-up.
Note:
21.5.2
IDLE MODE
21.6
1.
2.
3.
4.
DS70135C-page 150
Preliminary
dsPIC30F4011/4012
21.7
In-Circuit Debugger
2.
Preliminary
DS70135C-page 151
Bit 15
Bit 14
DS70135C-page 152
COSC<1:0>
Bit 12
TUN1
Bit 11
TUN0
Bit 10
F80004
F8000A
FGS
FWDTEN
MCLREN
F80002
FWDT
FBORPOR
Bit 14
Bit 13
Bit 12
PWMPIN
Bit 10
HPOL
LPOL
BOREN
Bit 7
CF
Bit 8
SLEEP
Bit 3
Bit 4
WDTO
FOS<1:0>
Bit 9
LOCK
SWDTEN
Bit 5
Note: Refer to dsPIC30F Family Reference Manual (DS70046) for descriptions of register bit fields.
FCKSM<1:0>
Bit 15
Bits 23-16
SWR
Bit 6
POST<1:0>
EXTR
Bit 7
Bit 11
Bit 8
NOSC<1:0>
Bit 9
Addr.
F80000
File Name
TABLE 21-8:
FOSC
Bit 13
Addr
.
RCON
SFR
Name
TABLE 21-7:
Bit 6
IDLE
Bit 2
POR
Bit 0
Depends on type of Reset.
Reset State
Bit 4
BORV<1:0>
FWPSA<1:0>
Bit 5
Bit 3
Bit 1
Bit 0
GCP
GWRP
FPWRT<1:0>
FWPSB<3:0>
FPR<3:0>
Bit 2
BOR
Bit 1
dsPIC30F4011/4012
Preliminary
dsPIC30F4011/4012
22.0
The W register (with or without an address modifier) or file register (specified by the value of Ws
or f)
The bit in the W register or file register
(specified by a literal value, or indirectly by the
contents of register Wb)
The literal instructions that involve data movement may
use some of the following operands:
A literal value to be loaded into a W register or file
register (specified by the value of k)
The W register or file register where the literal
value is to be loaded (specified by Wb or f)
However, literal instructions that involve arithmetic or
logical operations use some of the following operands:
The first source operand, which is a register Wb
without any address modifier
The second source operand, which is a literal
value
The destination of the result (only if not the same
as the first source operand), which is typically a
register Wd with or without an address modifier
The MAC class of DSP instructions may use some of the
following operands:
Preliminary
DS70135C-page 153
dsPIC30F4011/4012
Most single word instructions are executed in a single
instruction cycle, unless a conditional test is true or the
program counter is changed as a result of the instruction. In these cases, the execution takes two instruction
cycles with the additional instruction cycle(s) executed
as a NOP. Notable exceptions are the BRA (unconditional/computed branch), indirect CALL/GOTO, all
Table Reads and Writes and RETURN/RETFIE instructions, which are single word instructions, but take two
or three cycles. Certain instructions that involve skipping over the subsequent instruction, require either two
TABLE 22-1:
Field
#text
(text)
[text]
{ }
<n:m>
.b
.d
.S
.w
Acc
AWB
bit4
C, DC, N, OV, Z
Expr
f
lit1
lit4
lit5
lit8
lit10
lit14
lit16
lit23
None
OA, OB, SA, SB
PC
Slit10
Slit16
Slit6
DS70135C-page 154
Description
Means literal defined by text
Means content of text
Means the location addressed by text
Optional field or operation
Register bit field
Byte mode selection
Double-word mode selection
Shadow register select
Word mode selection (default)
One of two accumulators {A, B}
Accumulator write back destination address register {W13, [W13]+=2}
4-bit bit selection field (used in word addressed instructions) {0...15}
MCU status bits: Carry, Digit Carry, Negative, Overflow, Zero
Absolute address, label or expression (resolved by the linker)
File register address {0x0000...0x1FFF}
1-bit unsigned literal {0,1}
4-bit unsigned literal {0...15}
5-bit unsigned literal {0...31}
8-bit unsigned literal {0...255}
10-bit unsigned literal {0...255} for Byte mode, {0:1023} for Word mode
14-bit unsigned literal {0...16384}
16-bit unsigned literal {0...65535}
23-bit unsigned literal {0...8388608}; LSB must be 0
Field does not require an entry, may be blank
DSP status bits: AccA Overflow, AccB Overflow, AccA Saturate, AccB Saturate
Program Counter
10-bit signed literal {-512...511}
16-bit signed literal {-32768...32767}
6-bit signed literal {-16...16}
Preliminary
dsPIC30F4011/4012
TABLE 22-1:
Field
Wb
Wd
Wdo
Wm,Wn
Wm*Wm
Wm*Wn
Wn
Wnd
Wns
WREG
Ws
Wso
Wx
Wxd
Wy
Wyd
Description
Base W register {W0..W15}
Destination W register { Wd, [Wd], [Wd++], [Wd--], [++Wd], [--Wd] }
Destination W register
{ Wnd, [Wnd], [Wnd++], [Wnd--], [++Wnd], [--Wnd], [Wnd+Wb] }
Dividend, Divisor working register pair (direct addressing)
Multiplicand and Multiplier working register pair for Square instructions
{W4*W4,W5*W5,W6*W6,W7*W7}
Multiplicand and Multiplier working register pair for DSP instructions
{W4*W5,W4*W6,W4*W7,W5*W6,W5*W7,W6*W7}
One of 16 working registers {W0..W15}
One of 16 destination working registers {W0..W15}
One of 16 source working registers {W0..W15}
W0 (working register used in file register instructions)
Source W register { Ws, [Ws], [Ws++], [Ws--], [++Ws], [--Ws] }
Source W register
{ Wns, [Wns], [Wns++], [Wns--], [++Wns], [--Wns], [Wns+Wb] }
X data space pre-fetch address register for DSP instructions
{[W8]+=6, [W8]+=4, [W8]+=2, [W8], [W8]-=6, [W8]-=4, [W8]-=2,
[W9]+=6, [W9]+=4, [W9]+=2, [W9], [W9]-=6, [W9]-=4, [W9]-=2,
[W9+W12],none}
X data space pre-fetch destination register for DSP instructions {W4..W7}
Y data space pre-fetch address register for DSP instructions
{[W10]+=6, [W10]+=4, [W10]+=2, [W10], [W10]-=6, [W10]-=4, [W10]-=2,
[W11]+=6, [W11]+=4, [W11]+=2, [W11], [W11]-=6, [W11]-=4, [W11]-=2,
[W11+W12], none}
Y data space pre-fetch destination register for DSP instructions {W4..W7}
Preliminary
DS70135C-page 155
dsPIC30F4011/4012
TABLE 22-2:
Base
Instr
#
Assembly
Mnemonic
ADD
Description
# of
words
# of
cycle
s
Status Flags
Affected
Add Accumulators
OA,OB,SA,SB
f = f + WREG
C,DC,N,OV,Z
ADD
f,WREG
WREG = f + WREG
C,DC,N,OV,Z
ADD
#lit10,Wn
Wd = lit10 + Wd
C,DC,N,OV,Z
ADD
Wb,Ws,Wd
Wd = Wb + Ws
C,DC,N,OV,Z
ADD
Wb,#lit5,Wd
Wd = Wb + lit5
C,DC,N,OV,Z
ADD
ADDC
Acc
ADD
ADD
Wso,#Slit4,Acc
OA,OB,SA,SB
ADDC
f = f + WREG + (C)
C,DC,N,OV,Z
ADDC
f,WREG
C,DC,N,OV,Z
ADDC
C,DC,N,OV,Z
f = f .AND. WREG
N,Z
f,WREG
N,Z
#lit10,Wn
Wd = lit10 .AND. Wd
N,Z
Wb,Ws,Wd
Wd = Wb .AND. Ws
N,Z
Wb,#lit5,Wd
Wd = Wb .AND. lit5
N,Z
ASR
C,N,OV,Z
f,WREG
C,N,OV,Z
Ws,Wd
C,N,OV,Z
ASR
Wb,Wns,Wnd
N,Z
ASR
Wb,#lit5,Wnd
N,Z
BCLR
f,#bit4
Bit Clear f
None
BCLR
BRA
Wd = Wb + lit5 + (C)
ASR
Wb,#lit5,Wd
AND
ASR
BCLR
C,DC,N,OV,Z
AND
C,DC,N,OV,Z
AND
ASR
AND
Wd = Wb + Ws + (C)
AND
AND
Wd = lit10 + Wd + (C)
Wb,Ws,Wd
ADDC
3
#lit10,Wn
ADDC
Ws,#bit4
Bit Clear Ws
None
BRA
C,Expr
Branch if Carry
1 (2)
None
BRA
GE,Expr
1 (2)
None
BRA
GEU,Expr
1 (2)
None
BRA
GT,Expr
1 (2)
None
BRA
GTU,Expr
1 (2)
None
BRA
LE,Expr
1 (2)
None
BRA
LEU,Expr
1 (2)
None
BRA
LT,Expr
1 (2)
None
BRA
LTU,Expr
1 (2)
None
BRA
N,Expr
Branch if Negative
1 (2)
None
BRA
NC,Expr
1 (2)
None
BRA
NN,Expr
1 (2)
None
BRA
NOV,Expr
1 (2)
None
BRA
None
1 (2)
None
OB,Expr
1 (2)
None
OV,Expr
Branch if Overflow
1 (2)
None
SA,Expr
1 (2)
None
BRA
SB,Expr
1 (2)
None
BRA
Expr
Branch Unconditionally
None
BRA
Z,Expr
Branch if Zero
1 (2)
None
BRA
Wn
Computed Branch
None
BSET
f,#bit4
Bit Set f
None
BSET
Ws,#bit4
Bit Set Ws
None
Ws,Wb
None
Ws,Wb
None
BTG
f,#bit4
Bit Toggle f
None
BTG
BTG
BSW.C
BSW.Z
BSW
1 (2)
BRA
BRA
BSET
OA,Expr
BRA
NZ,Expr
BRA
Ws,#bit4
Bit Toggle Ws
None
DS70135C-page 156
Preliminary
dsPIC30F4011/4012
TABLE 22-2:
Base
Instr
#
Assembly
Mnemonic
10
BTSC
Description
# of
words
# of
cycle
s
Status Flags
Affected
1
(2 or
3)
None
Ws,#bit4
1
(2 or
3)
None
BTSS
f,#bit4
1
(2 or
3)
None
Ws,#bit4
1
(2 or
3)
None
BTST
f,#bit4
Bit Test f
Ws,#bit4
Bit Test Ws to C
BTST.Z
BTST
BTST.C
12
BTSS
BTSS
f,#bit4
BTSC
11
BTSC
Ws,#bit4
Bit Test Ws to Z
Z
C
BTST.C
13
BTSTS
Ws,Wb
BTST.Z
Ws,Wb
BTSTS
f,#bit4
BTSTS.C
14
Ws,#bit4
lit23
Call subroutine
None
Wn
None
CLR
f = 0x0000
None
CLR
WREG
WREG = 0x0000
None
CLR
Ws
Ws = 0x0000
None
CLR
CLR
CALL
CALL
15
CALL
Ws,#bit4
BTSTS.Z
Acc,Wx,Wxd,Wy,Wyd,AWB
Clear Accumulator
OA,OB,SA,SB
WDTO,Sleep
f=f
N,Z
COM
f,WREG
WREG = f
N,Z
COM
Ws,Wd
Wd = Ws
N,Z
CP
C,DC,N,OV,Z
CP
Wb,#lit5
C,DC,N,OV,Z
CP
Wb,Ws
C,DC,N,OV,Z
CP0
C,DC,N,OV,Z
CP0
Ws
C,DC,N,OV,Z
C,DC,N,OV,Z
16
CLRWDT
CLRWDT
17
COM
COM
18
19
CP
CP0
20
CP1
CP1
CP1
Ws
C,DC,N,OV,Z
21
CPB
CPB
C,DC,N,OV,Z
CPB
Wb,#lit5
C,DC,N,OV,Z
CPB
Wb,Ws
C,DC,N,OV,Z
22
CPSEQ
CPSEQ
Wb, Wn
1
(2 or
3)
None
23
CPSGT
CPSGT
Wb, Wn
1
(2 or
3)
None
24
CPSLT
CPSLT
Wb, Wn
1
(2 or
3)
None
25
CPSNE
CPSNE
Wb, Wn
1
(2 or
3)
None
26
DAW
DAW
Wn
Wn = decimal adjust Wn
27
DEC
DEC
f = f -1
C,DC,N,OV,Z
DEC
f,WREG
WREG = f -1
C,DC,N,OV,Z
DEC
Ws,Wd
Wd = Ws - 1
C,DC,N,OV,Z
DEC2
f = f -2
C,DC,N,OV,Z
DEC2
f,WREG
WREG = f -2
C,DC,N,OV,Z
DEC2
Ws,Wd
Wd = Ws - 2
C,DC,N,OV,Z
28
DEC2
Preliminary
DS70135C-page 157
dsPIC30F4011/4012
TABLE 22-2:
Base
Instr
#
Assembly
Mnemonic
Assembly Syntax
Description
# of
words
# of
cycle
s
Status Flags
Affected
29
DISI
DISI
#lit14
None
30
DIV
DIV.S
Wm,Wn
18
N,Z,C, OV
DIV.SD
Wm,Wn
18
N,Z,C, OV
DIV.U
Wm,Wn
18
N,Z,C, OV
DIV.UD
Wm,Wn
18
N,Z,C, OV
18
N,Z,C, OV
31
DIVF
DIVF
Wm,Wn
32
DO
DO
#lit14,Expr
None
DO
Wn,Expr
None
33
ED
ED
Wm*Wm,Acc,Wx,Wy,Wxd
OA,OB,OAB,
SA,SB,SAB
34
EDAC
EDAC
Wm*Wm,Acc,Wx,Wy,Wxd
Euclidean Distance
OA,OB,OAB,
SA,SB,SAB
35
EXCH
EXCH
Wns,Wnd
None
36
FBCL
FBCL
Ws,Wnd
37
FF1L
FF1L
Ws,Wnd
38
FF1R
FF1R
Ws,Wnd
39
GOTO
GOTO
Expr
Go to address
None
GOTO
Wn
Go to indirect
None
INC
f=f+1
C,DC,N,OV,Z
INC
f,WREG
WREG = f + 1
C,DC,N,OV,Z
INC
Ws,Wd
Wd = Ws + 1
C,DC,N,OV,Z
INC2
f=f+2
C,DC,N,OV,Z
INC2
f,WREG
WREG = f + 2
C,DC,N,OV,Z
40
41
INC
INC2
INC2
Ws,Wd
Wd = Ws + 2
C,DC,N,OV,Z
f = f .IOR. WREG
N,Z
f,WREG
N,Z
IOR
#lit10,Wn
Wd = lit10 .IOR. Wd
N,Z
IOR
IOR
IOR
IOR
42
Wb,Ws,Wd
Wd = Wb .IOR. Ws
N,Z
IOR
43
LAC
Wb,#lit5,Wd
Wd = Wb .IOR. lit5
N,Z
LAC
Wso,#Slit4,Acc
Load Accumulator
OA,OB,OAB,
SA,SB,SAB
44
LNK
LNK
#lit14
None
45
LSR
LSR
C,N,OV,Z
LSR
f,WREG
C,N,OV,Z
LSR
Ws,Wd
C,N,OV,Z
N,Z
LSR
N,Z
MAC
Wm*Wn,Acc,Wx,Wxd,Wy,Wyd,
AWB
OA,OB,OAB,
SA,SB,SAB
Wm*Wm,Acc,Wx,Wxd,Wy,Wyd
OA,OB,OAB,
SA,SB,SAB
MOV
f,Wn
Move f to Wn
None
Move f to f
N,Z
MOV
f,WREG
Move f to WREG
N,Z
MOV
#lit16,Wn
None
MOV.b
#lit8,Wn
None
MOV
Wn,f
Move Wn to f
None
MOV
Wso,Wdo
Move Ws to Wd
None
MOV
MOV
MOV
47
MAC
Wb,#lit5,Wnd
MAC
46
Wb,Wns,Wnd
LSR
WREG,f
Move WREG to f
N,Z
MOV.D
Wns,Wd
None
MOV.D
Ws,Wnd
None
48
MOVSAC
MOVSAC
None
49
MPY
MPY
Wm*Wn,Acc,Wx,Wxd,Wy,Wyd
Multiply Wm by Wn to Accumulator
OA,OB,OAB,
SA,SB,SAB
MPY
Wm*Wm,Acc,Wx,Wxd,Wy,Wyd
Square Wm to Accumulator
OA,OB,OAB,
SA,SB,SAB
MPY.N
Wm*Wn,Acc,Wx,Wxd,Wy,Wyd
None
50
MPY.N
DS70135C-page 158
Acc,Wx,Wxd,Wy,Wyd,AWB
Preliminary
dsPIC30F4011/4012
TABLE 22-2:
Base
Instr
#
Assembly
Mnemonic
51
MSC
52
MUL
Description
# of
words
# of
cycle
s
Status Flags
Affected
MSC
Wm*Wm,Acc,Wx,Wxd,Wy,Wyd,
AWB
OA,OB,OAB,
SA,SB,SAB
MUL.SS
Wb,Ws,Wnd
None
MUL.SU
Wb,Ws,Wnd
None
MUL.US
Wb,Ws,Wnd
None
MUL.UU
Wb,Ws,Wnd
None
MUL.SU
Wb,#lit5,Wnd
None
MUL.UU
Wb,#lit5,Wnd
None
MUL
53
NEG
W3:W2 = f * WREG
None
NEG
Acc
Negate Accumulator
OA,OB,OAB,
SA,SB,SAB
C,DC,N,OV,Z
NEG
WREG = f + 1
C,DC,N,OV,Z
Ws,Wd
Wd = Ws + 1
C,DC,N,OV,Z
POP
NOP
No Operation
None
NOPR
55
NOP
f=f+1
f,WREG
NEG
54
NEG
No Operation
None
None
POP
POP
Wdo
None
POP.D
Wnd
None
All
None
POP.S
56
PUSH
PUSH
PUSH
Wso
None
PUSH.D
Wns
None
PUSH.S
57
PWRSAV
58
RCALL
PWRSAV
#lit1
None
WDTO,Sleep
REPEAT
Expr
Relative Call
None
Wn
Computed Call
None
REPEAT
#lit14
None
REPEAT
59
RCALL
RCALL
Wn
None
60
RESET
RESET
None
61
RETFIE
RETFIE
3 (2)
None
62
RETLW
RETLW
3 (2)
None
63
RETURN
RETURN
3 (2)
None
64
RLC
RLC
C,N,Z
RLC
f,WREG
C,N,Z
RLC
Ws,Wd
C,N,Z
RLNC
N,Z
RLNC
f,WREG
N,Z
RLNC
Ws,Wd
N,Z
RRC
C,N,Z
RRC
f,WREG
C,N,Z
RRC
Ws,Wd
C,N,Z
RRNC
N,Z
RRNC
f,WREG
N,Z
RRNC
Ws,Wd
N,Z
SAC
Acc,#Slit4,Wdo
Store Accumulator
None
SAC.R
Acc,#Slit4,Wdo
None
SE
Ws,Wnd
C,N,Z
65
66
67
68
RLNC
RRC
RRNC
SAC
69
SE
70
SETM
#lit10,Wn
SETM
f = 0xFFFF
None
SETM
WREG
WREG = 0xFFFF
None
SETM
Ws
Ws = 0xFFFF
None
Preliminary
DS70135C-page 159
dsPIC30F4011/4012
TABLE 22-2:
Base
Instr
#
Assembly
Mnemonic
71
SFTAC
Description
# of
words
# of
cycle
s
Status Flags
Affected
OA,OB,OAB,
SA,SB,SAB
Acc,#Slit6
OA,OB,OAB,
SA,SB,SAB
SL
f = Left Shift f
C,N,OV,Z
SL
f,WREG
C,N,OV,Z
SL
Ws,Wd
Wd = Left Shift Ws
C,N,OV,Z
SL
SL
Acc,Wn
SFTAC
72
SFTAC
Wb,Wns,Wnd
N,Z
SL
N,Z
Subtract Accumulators
OA,OB,OAB,
SA,SB,SAB
f = f - WREG
C,DC,N,OV,Z
f,WREG
WREG = f - WREG
C,DC,N,OV,Z
#lit10,Wn
Wn = Wn - lit10
C,DC,N,OV,Z
SUB
Wb,Ws,Wd
Wd = Wb - Ws
C,DC,N,OV,Z
SUB
Wb,#lit5,Wd
Wd = Wb - lit5
C,DC,N,OV,Z
SUBB
f = f - WREG - (C)
C,DC,N,OV,Z
SUBB
SUBB
SUB
74
Wb,#lit5,Wnd
Acc
SUB
SUB
SUB
SUB
73
f,WREG
C,DC,N,OV,Z
SUBB
C,DC,N,OV,Z
C,DC,N,OV,Z
Wb,#lit5,Wd
Wd = Wb - lit5 - (C)
C,DC,N,OV,Z
SUBR
f = WREG - f
C,DC,N,OV,Z
f,WREG
WREG = WREG - f
C,DC,N,OV,Z
Wb,Ws,Wd
Wd = Ws - Wb
C,DC,N,OV,Z
SUBR
Wb,#lit5,Wd
Wd = lit5 - Wb
C,DC,N,OV,Z
SUBBR
f = WREG - f - (C)
C,DC,N,OV,Z
SUBBR
SUBBR
SUBR
76
Wd = Wb - Ws - (C)
SUBR
SUBR
Wn = Wn - lit10 - (C)
Wb,Ws,Wd
SUBB
75
#lit10,Wn
SUBB
f,WREG
C,DC,N,OV,Z
SUBBR
SWAP
Wd = Ws - Wb - (C)
C,DC,N,OV,Z
Wb,#lit5,Wd
Wd = lit5 - Wb - (C)
C,DC,N,OV,Z
SWAP.b
Wn
Wn = nibble swap Wn
None
SWAP
77
Wb,Ws,Wd
SUBBR
Wn
Wn = byte swap Wn
None
78
TBLRDH
TBLRDH
Ws,Wd
None
79
TBLRDL
TBLRDL
Ws,Wd
Read Prog<15:0> to Wd
None
None
80
TBLWTH
TBLWTH
Ws,Wd
81
TBLWTL
TBLWTL
Ws,Wd
Write Ws to Prog<15:0>
None
82
ULNK
ULNK
None
83
XOR
f = f .XOR. WREG
N,Z
N,Z
#lit10,Wn
Wd = lit10 .XOR. Wd
N,Z
XOR
Wb,Ws,Wd
Wd = Wb .XOR. Ws
N,Z
XOR
ZE
f
f,WREG
XOR
84
XOR
XOR
Wb,#lit5,Wd
Wd = Wb .XOR. lit5
N,Z
ZE
Ws,Wnd
Wnd = Zero-Extend Ws
C,Z,N
DS70135C-page 160
Preliminary
dsPIC30F4011/4012
23.0
DEVELOPMENT SUPPORT
23.1
23.2
MPASM Assembler
Preliminary
DS70135C-page 161
dsPIC30F4011/4012
23.3
23.6
23.4
23.5
DS70135C-page 162
23.7
The MPLAB SIM software simulator allows code development in a PC hosted environment by simulating the
PICmicro series microcontrollers on an instruction
level. On any given instruction, the data areas can be
examined or modified and stimuli can be applied from
a file, or user defined key press, to any pin. The execution can be performed in Single-Step, Execute Until
Break or Trace mode.
The MPLAB SIM simulator fully supports symbolic
debugging using the MPLAB C17 and MPLAB C18
C Compilers, as well as the MPASM assembler. The
software simulator offers the flexibility to develop and
debug code outside of the laboratory environment,
making it an excellent, economical software
development tool.
23.8
Preliminary
dsPIC30F4011/4012
23.9
Preliminary
DS70135C-page 163
dsPIC30F4011/4012
23.14 PICSTART Plus Development
Programmer
DS70135C-page 164
Preliminary
dsPIC30F4011/4012
23.20 PICDEM 17 Demonstration Board
The PICDEM 17 demonstration board is an evaluation
board that demonstrates the capabilities of several
Microchip microcontrollers, including PIC17C752,
PIC17C756A, PIC17C762 and PIC17C766. A programmed sample is included. The PRO MATE II device
programmer, or the PICSTART Plus development programmer, can be used to reprogram the device for user
tailored application development. The PICDEM 17
demonstration board supports program download and
execution from external on-board Flash memory. A
generous prototype area is available for user hardware
expansion.
Preliminary
DS70135C-page 165
dsPIC30F4011/4012
NOTES:
DS70135C-page 166
Preliminary
dsPIC30F4011/4012
24.0
ELECTRICAL CHARACTERISTICS
This section provides an overview of dsPIC30F electrical characteristics. Additional information will be provided in future
revisions of this document as it becomes available.
For detailed information about the dsPIC30F architecture and core, refer to dsPIC30F Family Reference Manual
(DS70046).
Absolute maximum ratings for the dsPIC30F family are listed below. Exposure to these maximum rating conditions for
extended periods may affect device reliability. Functional operation of the device at these or any other conditions above
the parameters indicated in the operation listings of this specification is not implied.
Stresses above those listed under Absolute Maximum Ratings may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above those
indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for
extended periods may affect device reliability.
24.1
DC Characteristics
TABLE 24-1:
VDD Range
Temp Range
dsPIC30F401x-30I
dsPIC30F401x-20I
dsPIC30F401x-20E
4.5-5.5V
-40C to 85C
30
20
4.5-5.5V
-40C to 125C
20
3.0-3.6V
-40C to 85C
20
15
3.0-3.6V
-40C to 125C
15
2.5-3.0V
-40C to 85C
10
7.5
Preliminary
DS70135C-page 167
dsPIC30F4011/4012
TABLE 24-2:
Symbol
Min
TJ
Typ
Max
Unit
-40
+125
TA
-40
+85
TJ
-40
+150
TA
-40
+85
TJ
-40
+150
TA
-40
+125
dsPIC30F401x-30I
dsPIC30F401x-20I
dsPIC30F401x-20E
Power Dissipation:
Internal chip power dissipation:
P INT = V DD ( I D D I O H)
PD
PINT + PI/O
PDMAX
(TJ - TA) / JA
TABLE 24-3:
Symbol
Typ
JA
JA
Unit
Notes
41
C/W
45
C/W
JA
37
C/W
JA
40
C/W
JA
28
C/W
Junction to ambient thermal resistance, Theta-ja (JA) numbers are achieved by package simulations.
TABLE 24-4:
DC CHARACTERISTICS
Param
No.
Max
Symbol
Min
Characteristic
Typ(1)
Max
Units
5.5
Industrial temperature
Extended temperature
Conditions
Operating Voltage(2)
VDD
Supply Voltage
2.5
DC11
VDD
Supply Voltage
3.0
5.5
DC12
VDR
1.5
DC16
VPOR
VSS
DC17
SVDD
0.05
DC10
Note 1:
2:
3:
Data in Typ column is at 5V, 25C unless otherwise stated. Parameters are for design guidance only and
are not tested.
These parameters are characterized but not tested in manufacturing.
This is the limit to which VDD can be lowered without losing RAM data.
DS70135C-page 168
Preliminary
dsPIC30F4011/4012
TABLE 24-5:
DC CHARACTERISTICS
Parameter
No.
Typical(1)
Max
Units
Conditions
mA
-40C
DC20a
2.5
mA
25C
3.3V
DC20b
mA
85C
DC20c
mA
125C
1 MIPS EC mode
DC20d
mA
-40C
DC20e
4.5
mA
25C
5V
DC20f
mA
85C
DC20g
mA
125C
DC23
mA
-40C
DC23a
11
mA
25C
3.3V
DC23b
mA
85C
DC23c
mA
125C
4 MIPS EC mode, 4X PLL
DC23d
mA
-40C
DC23e
18
mA
25C
5V
DC23f
mA
85C
DC23g
mA
125C
DC24
mA
-40C
DC24a
25
mA
25C
3.3V
DC24b
mA
85C
DC24c
mA
125C
10 MIPS EC mode, 4X PLL
DC24d
mA
-40C
DC24e
43
mA
25C
5V
DC24f
mA
85C
DC24g
mA
125C
DC25
mA
-40C
DC25a
24
mA
25C
3.3V
DC25b
mA
85C
DC25c
mA
125C
8 MIPS EC mode, 8X PLL
DC25d
mA
-40C
DC25e
41
mA
25C
5V
DC25f
mA
85C
DC25g
mA
125C
Note 1: Data in Typical column is at 5V, 25C unless otherwise stated. Parameters are for design guidance only
and are not tested.
2: The supply current is mainly a function of the operating voltage and frequency. Other factors such as I/O
pin loading and switching rate, oscillator type, internal code execution pattern and temperature also have
an impact on the current consumption. The test conditions for all IDD measurements are as follows: OSC1
driven with external square wave from rail to rail. All I/O pins are configured as Inputs and pulled to VDD.
MCLR = VDD, WDT, FSCM, LVD and BOR are disabled. CPU, SRAM, Program Memory and Data
Memory are operational. No peripheral modules are operating.
Preliminary
DS70135C-page 169
dsPIC30F4011/4012
TABLE 24-5:
DC CHARACTERISTICS
Parameter
No.
Typical(1)
Max
Units
Conditions
mA
-40C
DC27a
52
mA
25C
3.3V
DC27b
mA
85C
DC27c
mA
-40C
20 MIPS EC mode, 8X PLL
DC27d
94
mA
25C
5V
DC27e
mA
85C
DC27f
mA
125C
DC28
mA
-40C
DC28a
41
mA
25C
3.3V
DC28b
mA
85C
DC28c
mA
-40C
16 MIPS EC mode, 16X PLL
DC28d
74
mA
25C
5V
DC28e
mA
85C
DC28f
mA
125C
DC29
mA
-40C
DC29a
132
mA
25C
5V
30 MIPS EC mode, 16X PLL
DC29b
mA
85C
DC29c
mA
125C
DC30
mA
-40C
DC30a
7
mA
25C
3.3V
DC30b
mA
85C
DC30c
mA
125C
FRC (~ 2 MIPS)
DC30d
mA
-40C
DC30e
12
mA
25C
5V
DC30f
mA
85C
DC30g
mA
125C
DC31
mA
-40C
DC31a
1
mA
25C
3.3V
DC31b
mA
85C
DC31c
mA
125C
LPRC (~ 512 kHz)
DC31d
mA
-40C
DC31e
2
mA
25C
5V
DC31f
mA
85C
DC31g
mA
125C
Note 1: Data in Typical column is at 5V, 25C unless otherwise stated. Parameters are for design guidance only
and are not tested.
2: The supply current is mainly a function of the operating voltage and frequency. Other factors such as I/O
pin loading and switching rate, oscillator type, internal code execution pattern and temperature also have
an impact on the current consumption. The test conditions for all IDD measurements are as follows: OSC1
driven with external square wave from rail to rail. All I/O pins are configured as Inputs and pulled to VDD.
MCLR = VDD, WDT, FSCM, LVD and BOR are disabled. CPU, SRAM, Program Memory and Data
Memory are operational. No peripheral modules are operating.
DS70135C-page 170
Preliminary
dsPIC30F4011/4012
TABLE 24-6:
DC CHARACTERISTICS
Parameter
No.
Typical(1)
Max
Units
Conditions
mA
-40C
DC40a
1.5
mA
25C
DC40b
mA
85C
DC40c
mA
125C
DC40d
mA
-40C
DC40e
mA
25C
DC40f
mA
85C
3.3V
DC40g
mA
mA
-40C
DC43a
mA
25C
DC43b
mA
85C
5V
125C
DC43
1 MIPS EC mode
DC43c
mA
125C
DC43d
mA
-40C
DC43e
12
mA
25C
DC43f
mA
85C
3.3V
DC43g
mA
mA
-40C
DC44a
17
mA
25C
DC44b
mA
85C
DC44c
mA
125C
DC44d
mA
-40C
DC44e
27
mA
25C
DC44f
mA
85C
DC44g
mA
125C
DC45
mA
-40C
DC45a
15
mA
25C
DC45b
mA
85C
DC45c
mA
125C
DC45d
mA
-40C
DC45e
26
mA
25C
DC45f
mA
85C
DC45g
mA
5V
125C
DC44
125C
Note 1:
2:
3.3V
10 MIPS EC mode, 4X PLL
5V
3.3V
8 MIPS EC mode, 8X PLL
5V
Data in Typical column is at 5V, 25C unless otherwise stated. Parameters are for design guidance only
and are not tested.
Base IIDLE current is measured with Core off, Clock on and all modules turned off.
Preliminary
DS70135C-page 171
dsPIC30F4011/4012
TABLE 24-6:
DC CHARACTERISTICS
Parameter
No.
Typical(1)
Max
Units
Conditions
mA
-40C
DC47a
33
mA
25C
DC47b
mA
85C
DC47c
mA
56
mA
25C
DC47e
mA
85C
DC47f
mA
-40C
DC47d
3.3V
125C
DC48
mA
-40C
DC48a
26
mA
25C
5V
DC48b
mA
85C
DC48c
mA
-40C
DC48d
46
mA
25C
DC48e
mA
85C
3.3V
DC48f
mA
mA
-40C
DC49a
85
mA
25C
DC49b
mA
85C
DC49c
mA
125C
DC50
mA
-40C
DC50a
mA
25C
DC50b
mA
85C
DC50c
mA
125C
DC50d
mA
-40C
DC50e
mA
25C
DC50f
mA
85C
DC50g
mA
125C
DC51
mA
-40C
DC51a
0.5
mA
25C
DC51b
mA
85C
DC51c
mA
125C
DC51d
mA
-40C
DC51e
0.9
mA
25C
DC51f
mA
85C
DC51g
mA
5V
125C
DC49
125C
Note 1:
2:
5V
3.3V
FRC (~ 2 MIPS)
5V
3.3V
LPRC (~ 512 kHz)
5V
Data in Typical column is at 5V, 25C unless otherwise stated. Parameters are for design guidance only
and are not tested.
Base IIDLE current is measured with Core off, Clock on and all modules turned off.
DS70135C-page 172
Preliminary
dsPIC30F4011/4012
TABLE 24-7:
DC CHARACTERISTICS
Parameter
No.
Typical(1)
Max
Units
Conditions
-40C
DC60a
25C
DC60b
85C
DC60c
125C
DC60d
-40C
DC60e
25C
DC60f
85C
DC60g
125C
DC61
-40C
DC61a
25C
DC61b
85C
DC61c
125C
DC61d
-40C
DC61e
10
25C
DC61f
85C
DC61g
125C
DC62
-40C
DC62a
5.5
25C
DC62b
85C
DC62c
125C
DC62d
-40C
DC62e
7.5
25C
DC62f
85C
DC62g
125C
DC63
32
25C
DC63b
85C
DC63c
38
25C
DC63f
85C
DC63g
3.3V
Watchdog Timer Current: IWDT(3)
5V
3.3V
Timer 1 w/32 kHz Crystal: ITI32(3)
5V
-40C
DC63e
5V
125C
DC63d
-40C
DC63a
3.3V
125C
Note 1:
2:
3:
3.3V
BOR On: IBOR(3)
5V
Data in the Typical column is at 5V, 25C unless otherwise stated. Parameters are for design guidance
only and are not tested.
Base IPD is measured with all peripherals and clocks shut down. All I/Os are configured as inputs and
pulled high. LVD, BOR, WDT, etc. are all switched off.
The current is the additional current consumed when the module is enabled. This current should be
added to the base IPD current.
Preliminary
DS70135C-page 173
dsPIC30F4011/4012
TABLE 24-8:
DC CHARACTERISTICS
Param
Symbol
No.
VIL
DI10
Min
Typ(1)
Max
Units
VSS
Characteristic
0.2 VDD
Conditions
DI15
MCLR
VSS
0.2 VDD
DI16
VSS
0.2 VDD
(3)
DI17
VSS
0.3 VDD
DI18
SDA, SCL
TBD
TBD
SM bus disabled
SDA, SCL
TBD
TBD
SM bus enabled
I/O pins:
with Schmitt Trigger buffer
0.8 VDD
VDD
DI25
MCLR
0.8 VDD
VDD
DI26
VDD
DI27
(3)
0.9 VDD
VDD
DI28
SDA, SCL
TBD
TBD
SM bus disabled
DI29
SDA, SCL
TBD
TBD
SM bus enabled
50
250
400
TBD
TBD
TBD
DI19
VIH
DI20
ICNPU
CNXX Pull-up
Current(2)
DI30
DI31
IIL
DI50
I/O ports
0.01
DI51
0.50
DI55
MCLR
0.05
DI56
OSC1
0.05
Note 1:
2:
3:
4:
5:
Data in Typ column is at 5V, 25C unless otherwise stated. Parameters are for design guidance only and
are not tested.
These parameters are characterized but not tested in manufacturing.
In RC oscillator configuration, the OSC1/CLKl pin is a Schmitt Trigger input. It is not recommended that
the dsPIC30F device be driven with an external clock while in RC mode.
The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified
levels represent normal operating conditions. Higher leakage current may be measured at different input
voltages.
Negative current is defined as current sourced by the pin.
DS70135C-page 174
Preliminary
dsPIC30F4011/4012
TABLE 24-9:
DC CHARACTERISTICS
Param
Symbol
No.
VOL
Characteristic
Min
Typ(1)
Max
Units
0.6
Conditions
DO10
I/O ports
TBD
DO16
OSC2/CLKOUT
0.6
TBD
VDD 0.7
TBD
VOH
DO20
DO26
OSC2/CLKOUT
(RC or EC Osc mode)
VDD 0.7
TBD
COSC2
OSC2/SOSC2 pin
15
pF
DO56
CIO
50
pF
RC or EC Osc mode
DO58
CB
SCL, SDA
400
pF
In I2C mode
Note 1:
2:
Data in Typ column is at 5V, 25C unless otherwise stated. Parameters are for design guidance only and
are not tested.
These parameters are characterized but not tested in manufacturing.
FIGURE 24-1:
BO10
(Device in Brown-out Reset)
BO15
Preliminary
DS70135C-page 175
dsPIC30F4011/4012
TABLE 24-10: ELECTRICAL CHARACTERISTICS: BOR
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
DC CHARACTERISTICS
Param
No.
Typ(1)
Max
Units
BORV = 00(3)
BORV = 01
2.7
2.86
4.2
4.46
BORV = 11
VBOR
BO10
Min
BORV = 10
4.5
4.78
Symbol
mV
Characteristic
BOR Voltage(2) on
VDD transition high to
low
Conditions
Not in operating
range
BO15
VBHYS
Note 1:
Data in Typ column is at 5V, 25C unless otherwise stated. Parameters are for design guidance only and
are not tested.
These parameters are characterized but not tested in manufacturing.
00 values not in usable operating range.
2:
3:
DC CHARACTERISTICS
Param
Symbol
No.
Min
Characteristic
Typ(1)
Max
Units
Conditions
ED
Byte Endurance
100K
1M
E/W
D121
VDRW
VMIN
5.5
-40C TA +85C
Using EECON to read/write
VMIN = Minimum operating
voltage
D122
TDEW
ms
D123
TRETD
Characteristic Retention
40
100
Year
D124
IDEW
10
30
mA
Row Erase
-40C TA +85C
(2)
EP
Cell Endurance
10K
100K
E/W
D131
VPR
VMIN
5.5
D132
VEB
4.5
5.5
D133
VPEW
3.0
5.5
D134
TPEW
ms
D135
TRETD
Characteristic Retention
40
100
Year
D136
TEB
ms
D137
IPEW
10
30
mA
Row Erase
D138
IEB
10
30
mA
Bulk Erase
Note 1:
2:
DS70135C-page 176
Preliminary
dsPIC30F4011/4012
24.2
The information contained in this section defines dsPIC30F AC characteristics and timing parameters.
AC CHARACTERISTICS
FIGURE 24-2:
VDD/2
RL
CL
Pin
VSS
CL
Pin
RL = 464
CL = 50 pF for all pins except OSC2
5 pF for OSC2 output
VSS
FIGURE 24-3:
Q1
Q2
Q3
Q4
Q1
OSC1
OS20
OS30
OS25
OS30
OS31
OS31
CLKOUT
OS40
Preliminary
OS41
DS70135C-page 177
dsPIC30F4011/4012
TABLE 24-13: EXTERNAL CLOCK TIMING REQUIREMENTS
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
Symbol
No.
Min
Typ(1)
Max
Units
DC
4
4
4
40
10
10
7.5
MHz
MHz
MHz
MHz
EC
EC with 4x PLL
EC with 8x PLL
EC with 16x PLL
Oscillator Frequency(2)
FOSC
OS10
Characteristic
DC
0.4
4
4
4
4
10
31
7.3728
512
4
4
10
10
10
7.5
25
33
MHz
MHz
MHz
MHz
MHz
MHz
MHz
kHz
MHz
kHz
RC
XTL
XT
XT with 4x PLL
XT with 8x PLL
XT with 16x PLL
HS
LP
FRC internal
LPRC internal
Conditions
OS20
TOSC
TOSC = 1/FOSC
OS25
TCY
33
DC
ns
OS30
TosL,
TosH
.45 x TOSC
ns
EC
OS31
TosR,
TosF
20
ns
EC
OS40
TckR
10
ns
OS41
TckF
10
ns
Note 1:
2:
3:
4:
Data in Typ column is at 5V, 25C unless otherwise stated. Parameters are for design guidance only and
are not tested.
These parameters are characterized but not tested in manufacturing.
Instruction cycle period (TCY) equals four times the input oscillator time-base period. All specified values
are based on characterization data for that particular oscillator type under standard operating conditions
with the device executing code. Exceeding these specified limits may result in an unstable oscillator
operation and/or higher than expected current consumption. All devices are tested to operate at min.
values with an external clock applied to the OSC1/CLKI pin. When an external clock input is used, the
Max. cycle time limit is DC (no clock) for all devices.
Measurements are taken in EC or ERC modes. The CLKOUT signal is measured on the OSC2 pin.
CLKOUT is low for the Q1-Q2 period (1/2 TCY) and high for the Q3-Q4 period (1/2 TCY).
DS70135C-page 178
Preliminary
dsPIC30F4011/4012
TABLE 24-14: PLL CLOCK TIMING SPECIFICATIONS (VDD = 2.5 TO 5.5 V)
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
No.
Characteristic(1)
Symbol
Min
Typ(2)
Max
Units
Conditions
OS50
FPLLI
10
MHz
OS51
FSYS
16
120
MHz
OS52
TLOC
20
50
OS53
DCLK
TBD
TBD
Note 1:
2:
FOSC
(MHz)(1)
TCY (sec)(2)
MIPS(3)
w/o PLL
MIPS(3)
w PLL x4
MIPS(3)
w PLL x8
MIPS(3)
w PLL x16
EC
0.200
20.0
0.05
1.0
4.0
8.0
16.0
0.4
2.5
10.0
20.0
25
XT
1.0
10
0.16
6.25
Note 1:
2:
3:
1.0
1.0
4.0
8.0
16.0
10
0.4
2.5
10.0
20.0
Preliminary
DS70135C-page 179
dsPIC30F4011/4012
TABLE 24-16: AC CHARACTERISTICS: INTERNAL RC ACCURACY
AC CHARACTERISTICS
Param
No.
Characteristic
Typ
Max
Units
Conditions
TBD
+25C
VDD = 3.0-3.6V
TBD
+25C
VDD = 4.5-5.5V
TBD
-40C TA +85C
VDD = 3.0-3.6V
TBD
-40C TA +85C
VDD = 4.5-5.5V
TBD
-40C TA +125C
VDD = 4.5-5.5V
+25C
VDD = 3.0-3.6V
+25C
VDD = 4.5-5.5V
TBD
-40C TA +85C
VDD = 3.0-3.6V
TBD
-40C TA +85C
VDD = 4.5-5.5V
TBD
FRC with x8 PLL
TBD
TBD
-40C TA +125C
VDD = 4.5-5.5V
TBD
+25C
VDD = 3.0-3.6V
TBD
+25C
VDD = 4.5-5.5V
TBD
-40C TA +85C
VDD = 3.0-3.6V
TBD
-40C TA +85C
VDD = 4.5-5.5V
TBD
-40C TA +125C
VDD = 4.5-5.5V
+25C
VDD = 3.0-3.6V
+25C
VDD = 4.5-5.5V
TBD
-40C TA +85C
VDD = 3.0-3.6V
TBD
-40C TA +85C
VDD = 4.5-5.5V
TBD
Note 1:
TBD
TBD
-40C TA +125C
VDD = 4.5-5.5V
Frequency calibrated at 25C and 5V. TUN bits can be used to compensate for temperature drift.
DS70135C-page 180
Preliminary
dsPIC30F4011/4012
TABLE 24-17: AC CHARACTERISTICS: INTERNAL RC JITTER
AC CHARACTERISTICS
Param
No.
Characteristic
Min
Typ
Max
Units
Conditions
VDD = 3.0-3.6V
TBD
+25C
TBD
+25C
VDD = 4.5-5.5V
TBD
-40C TA +85C
VDD = 3.0-3.6V
TBD
-40C TA +85C
VDD = 4.5-5.5V
TBD
-40C TA +125C
VDD = 4.5-5.5V
+25C
VDD = 3.0-3.6V
+25C
VDD = 4.5-5.5V
TBD
-40C TA +85C
VDD = 3.0-3.6V
TBD
-40C TA +85C
VDD = 4.5-5.5V
TBD
-40C TA +125C
VDD = 4.5-5.5V
TBD
+25C
VDD = 3.0-3.6V
TBD
+25C
VDD = 4.5-5.5V
TBD
-40C TA +85C
VDD = 3.0-3.6V
TBD
-40C TA +85C
VDD = 4.5-5.5V
TBD
TBD
TBD
-40C TA +125C
VDD = 4.5-5.5V
+25C
VDD = 3.0-3.6V
+25C
VDD = 4.5-5.5V
TBD
-40C TA +85C
VDD = 3.0-3.6V
TBD
-40C TA +85C
VDD = 4.5-5.5V
TBD
Note 1:
TBD
TBD
-40C TA +125C
VDD = 4.5-5.5V
Frequency calibrated at 25C and 5V. TUN bits can be used to compensate for temperature drift.
Param
No.
Characteristic
Typ
Max
Units
Conditions
F20
TBD
TBD
-40C to +85C
VDD = 3V
F21
TBD
TBD
-40C to +85C
VDD = 5V
Note 1:
Preliminary
DS70135C-page 181
dsPIC30F4011/4012
FIGURE 24-4:
I/O Pin
(Input)
DI35
DI40
I/O Pin
(Output)
New Value
Old Value
DO31
DO32
AC CHARACTERISTICS
Param
No.
DO31
Symbol
TIOR
Characteristic(1)(2)(3)
Typ(4)
Max
Units
Conditions
Min
10
25
ns
DO32
TIOF
10
25
ns
DI35
TINP
20
ns
TRBP
2 TCY
ns
DI40
Note 1:
2:
3:
4:
These parameters are asynchronous events not related to any internal clock edges
Measurements are taken in RC mode and EC mode where CLKOUT output is 4 x TOSC.
These parameters are characterized but not tested in manufacturing.
Data in Typ column is at 5V, 25C unless otherwise stated.
DS70135C-page 182
Preliminary
dsPIC30F4011/4012
FIGURE 24-5:
VDD
SY12
MCLR
SY10
Internal
POR
SY11
PWRT
Time-out
OSC
Time-out
SY30
Internal
RESET
Watchdog
Timer
RESET
SY13
SY20
SY13
I/O Pins
SY35
FSCM
Delay
Note: Refer to Figure 24-2 for load conditions.
Preliminary
DS70135C-page 183
dsPIC30F4011/4012
TABLE 24-20: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER
AND BROWN-OUT RESET TIMING REQUIREMENTS
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
Symbol
No.
Characteristic(1)
SY10
TmcL
TPWRT
Typ(2)
Max
Units
Conditions
-40C to +85C
TBD
TBD
TBD
TBD
0
4
16
64
TBD
TBD
TBD
TBD
ms
-40C to +85C
User programmable
-40C to +85C
SY11
Min
SY12
TPOR
10
30
SY13
TIOZ
100
ns
SY20
TWDT1
1.8
2.0
2.2
ms
1.9
2.1
2.3
ms
SY25
TBOR
100
SY30
TOST
1024 TOSC
SY35
TFSCM
100
-40C to +85C
TWDT2
Note 1:
2:
3:
FIGURE 24-6:
0V
Enable Band Gap
(see Note)
Band Gap
Stable
SY40
Param
No.
SY40
Note 1:
2:
Symbol
TBGAP
Characteristic(1)
Min
Typ(2)
Max
Units
20
50
Conditions
Defined as the time between the
instant that the band gap is enabled
and the moment that the band gap
reference voltage is stable.
RCON<13>Status bit
DS70135C-page 184
Preliminary
dsPIC30F4011/4012
FIGURE 24-7:
TxCK
Tx11
Tx10
Tx15
Tx20
OS60
TMRX
AC CHARACTERISTICS
Param
No.
TA15
TTXP
Units
Conditions
Synchronous,
no prescaler
0.5 TCY + 20
ns
10
ns
10
ns
Synchronous,
no prescaler
0.5 TCY + 20
ns
10
ns
Asynchronous
TTXL
Max
Synchronous,
with prescaler
TA11
Characteristic
TxCK High Time
Typ
Asynchronous
TTXH
Min
Synchronous,
with prescaler
TA10
Symbol
10
ns
TCY + 10
ns
Greater of:
20 ns or
(TCY + 40)/N
OS60
Ft1
TA20
20
50
kHz
6 TOSC
N = prescale
value
(1, 8, 64, 256)
ns
DC
2 TOSC
Preliminary
DS70135C-page 185
dsPIC30F4011/4012
TABLE 24-23: TIMER2 AND TIMER4 EXTERNAL CLOCK TIMING REQUIREMENTS
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
No.
TB15
TtxL
TtxP
Characteristic
TxCK High Time
Typ
Max
Units
Synchronous,
no prescaler
0.5 TCY + 20
ns
10
ns
Synchronous,
no prescaler
0.5 TCY + 20
ns
Synchronous,
with prescaler
TB11
TtxH
Min
Synchronous,
with prescaler
TB10
Symbol
10
ns
TCY + 10
ns
6 TOSC
TB20
Greater of:
20 ns or
(TCY + 40)/N
2 TOSC
Conditions
Must also meet
parameter TB15
N = prescale
value
(1, 8, 64, 256)
AC CHARACTERISTICS
Param
No.
Symbol
Characteristic
Min
Typ
Max
Units
Conditions
TC10
TtxH
Synchronous
0.5 TCY + 20
ns
TC11
TtxL
Synchronous
0.5 TCY + 20
ns
TC15
TtxP
TCY + 10
ns
N = prescale
value
(1, 8, 64, 256)
6 TOSC
Synchronous,
with prescaler
TC20
DS70135C-page 186
Greater of:
20 ns or
(TCY + 40)/N
2 TOSC
Preliminary
dsPIC30F4011/4012
FIGURE 24-8:
QEB
TQ11
TQ10
TQ15
TQ20
POSCNT
AC CHARACTERISTICS
Param
No.
Characteristic(1)
Symbol
Min
Typ
Max
Units
Conditions
TQ10
TtQH
Synchronous,
with prescaler
TCY + 20
ns
TQ11
TtQL
Synchronous,
with prescaler
TCY + 20
ns
TQ15
TtQP
2 * TCY + 40
ns
TQ20
Tosc
5 Tosc
ns
Note 1:
Preliminary
DS70135C-page 187
dsPIC30F4011/4012
FIGURE 24-9:
IC10
IC11
IC15
AC CHARACTERISTICS
Param
No.
Characteristic(1)
Symbol
IC10
TccL
IC11
TccH
IC15
TccP
Min
No Prescaler
Max
Units
0.5 TCY + 20
ns
With Prescaler
No Prescaler
10
ns
0.5 TCY + 20
ns
With Prescaler
Note 1:
Conditions
10
ns
(2 TCY + 40)/N
ns
N = prescale
value (1, 4, 16)
FIGURE 24-10:
OCx
(Output Compare
or PWM Mode)
OC10
OC11
Param
Symbol
No.
Characteristic(1)
Typ(2)
Max
Units
Conditions
OC10
TccF
10
25
ns
OC11
TccR
10
25
ns
Note 1:
2:
DS70135C-page 188
Preliminary
dsPIC30F4011/4012
FIGURE 24-11:
OCFA/OCFB
OC15
OCx
AC CHARACTERISTICS
Param
Symbol
No.
Characteristic(1)
Min
Typ(2)
Max
Units
25
ns
OC15 TFD
OC20 TFLT
Conditions
VDD = 3V
ns
VDD = 5V
50
ns
VDD = 3V
TBD
Note 1:
2:
TBD
ns
-40C to +85C
VDD = 5V
-40C to +85C
Preliminary
DS70135C-page 189
dsPIC30F4011/4012
FIGURE 24-12:
FLTA/B
MP20
PWMx
FIGURE 24-13:
PWMx
Note: Refer to Figure 24-2 for load conditions.
Param
No.
Symbol
Characteristic(1)
Min
Typ(2)
Max
Units
Conditions
MP10
TFPWM
10
25
ns
VDD = 5V
-40C to +85C
MP11
TRPWM
10
25
ns
VDD = 5V
-40C to +85C
MP12
TFPWM
TBD
TBD
ns
VDD = 3V
-40C to +85C
MP13
MP20
MP30
Note 1:
2:
TRPWM
TBD
TBD
ns
VDD = 3V
-40C to +85C
TFD
25
ns
VDD = 3V
-40C to +85C
TFH
TBD
ns
VDD = 5V
50
ns
VDD = 3V
TBD
ns
VDD = 5V
-40C to +85C
DS70135C-page 190
Preliminary
dsPIC30F4011/4012
FIGURE 24-14:
QEA
(input)
TQ30
TQ31
TQ35
QEB
(input)
TQ41
TQ40
TQ30
TQ31
TQ35
QEB
Internal
AC CHARACTERISTICS
Param
No.
Characteristic(1)
Symbol
Typ(2)
Max
Units
Conditions
6 TCY
ns
TQ30
TQUL
TQ31
TQUH
6 TCY
ns
TQ35
TQUIN
12 TCY
ns
TQ36
TQUP
3 TCY
ns
TQ40
TQUFL
3 * N * TCY
ns
TQ41
TQUFH
3 * N * TCY
ns
Note 1:
2:
Preliminary
DS70135C-page 191
dsPIC30F4011/4012
FIGURE 24-15:
QEA
(input)
QEB
(input)
Ungated
Index
TQ50
TQ51
Index Internal
TQ55
Position
Param
No.
Symbol
Min
Max
Units
Conditions
TQ50
TqIL
3 * N * TCY
ns
TQ51
TqiH
3 * N * TCY
ns
TQ55
Tqidxr
3 TCY
ns
Note 1:
2:
DS70135C-page 192
Preliminary
dsPIC30F4011/4012
FIGURE 24-16:
SCKx
(CKP = 0)
SP11
SP10
SP21
SP20
SP20
SP21
SCKx
(CKP = 1)
SP35
BIT14 - - - - - -1
MSb
SDOx
SP31
SDIx
LSb
SP30
MSb IN
LSb IN
BIT14 - - - -1
SP40 SP41
AC CHARACTERISTICS
Param
No.
Symbol
Characteristic(1)
Min
Typ(2)
Max
Units
Conditions
ns
TscL
TCY / 2
SP11
TscH
Time(3)
TCY / 2
ns
SP20
TscF
10
25
ns
SP21
TscR
10
25
ns
SP30
TdoF
10
25
ns
SP10
(4)
SP31
TdoR
10
25
ns
SP35
TscH2doV,
TscL2doV
30
ns
SP40
TdiV2scH,
TdiV2scL
20
ns
SP41
TscH2diL,
TscL2diL
20
ns
Note 1:
2:
3:
4:
Preliminary
DS70135C-page 193
dsPIC30F4011/4012
FIGURE 24-17:
SCKX
(CKP = 0)
SP11
SP10
SP21
SP20
SP20
SP21
SCKX
(CKP = 1)
SP35
SDOX
BIT14 - - - - - -1
MSb
SP40
SDIX
LSb
SP30,SP31
MSb IN
BIT14 - - - -1
LSb IN
SP41
AC CHARACTERISTICS
Param
No.
Symbol
Characteristic(1)
Min
Typ(2)
Max
Units
Conditions
SP10
TscL
TCY / 2
ns
SP11
TscH
TCY / 2
ns
10
25
ns
10
25
ns
10
25
ns
10
25
ns
time(4)
SP20
TscF
SP21
TscR
SP30
TdoF
SP31
TdoR
SP35
30
ns
SP36
30
ns
SP40
20
ns
SP41
TscH2diL,
TscL2diL
20
ns
Note 1:
2:
3:
4:
DS70135C-page 194
Preliminary
dsPIC30F4011/4012
FIGURE 24-18:
SSX
SP52
SP50
SCKX
(CKP = 0)
SP71
SP70
SP73
SP72
SP72
SP73
SCKX
(CKP = 1)
SP35
MSb
SDOX
LSb
BIT14 - - - - - -1
SP51
SP30,SP31
SDIX
MSb IN
SP40
BIT14 - - - -1
LSb IN
SP41
AC CHARACTERISTICS
Param
No.
Symbol
Characteristic(1)
Min
Typ(2)
Max
Units
Conditions
30
ns
SP70
TscL
SP71
TscH
30
ns
SP72
TscF
10
25
ns
SP73
TscR
10
25
ns
10
25
ns
10
25
ns
Time(3)
SP30
TdoF
SP31
TdoR
SP35
30
ns
SP40
20
ns
SP41
20
ns
SP50
120
ns
SP51
10
50
ns
SP52
ns
Note 1:
2:
3:
Preliminary
DS70135C-page 195
dsPIC30F4011/4012
FIGURE 24-19:
SSX
SP52
SP50
SCKX
(CKP = 0)
SP71
SP70
SP73
SP72
SP72
SP73
SCKX
(CKP = 1)
SP35
SP52
MSb
SDOX
BIT14 - - - - - -1
LSb
SP30,SP31
SDIX
MSb IN
SP51
BIT14 - - - -1
LSb IN
SP41
SP40
DS70135C-page 196
Preliminary
dsPIC30F4011/4012
TABLE 24-35: SPI MODULE SLAVE MODE (CKE = 1) TIMING REQUIREMENTS
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
No.
Symbol
Characteristic(1)
Min
Typ(2)
Max
Units
Conditions
SP70
TscL
30
ns
SP71
TscH
30
ns
SP72
TscF
10
25
ns
SP73
TscR
10
25
ns
(3)
SP30
TdoF
10
25
ns
SP31
TdoR
10
25
ns
SP35
30
ns
SP40
20
ns
SP41
20
ns
SP50
120
ns
SP51
10
50
ns
SP52
1.5 TCY + 40
ns
SP60
50
ns
Note 1:
2:
3:
4:
Preliminary
DS70135C-page 197
dsPIC30F4011/4012
FIGURE 24-20:
SCL
IM31
IM34
IM30
IM33
SDA
Stop
Condition
Start
Condition
Note: Refer to Figure 24-2 for load conditions.
FIGURE 24-21:
IM21
IM11
IM10
SCL
IM11
IM26
IM10
IM25
IM33
SDA
In
IM40
IM40
IM45
SDA
Out
Note: Refer to Figure 24-2 for load conditions.
DS70135C-page 198
Preliminary
dsPIC30F4011/4012
TABLE 24-36: I2C BUS DATA TIMING REQUIREMENTS (MASTER MODE)
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
Symbol
No.
Min(1)
Max
Units
Conditions
TCY / 2 (BRG + 1)
TCY / 2 (BRG + 1)
1 MHz mode(2)
TCY / 2 (BRG + 1)
TCY / 2 (BRG + 1)
TCY / 2 (BRG + 1)
Characteristic
IM10
THI:SCL
IM11
(2)
TCY / 2 (BRG + 1)
300
ns
20 + 0.1 CB
300
ns
1 MHz mode(2)
100
ns
1000
ns
20 + 0.1 CB
300
ns
1 MHz mode(2)
300
ns
250
ns
100
ns
1 MHz mode(2)
TBD
ns
ns
0.9
1 MHz mode(2)
TBD
ns
TCY / 2 (BRG + 1)
TCY / 2 (BRG + 1)
1 MHz mode(2)
TCY / 2 (BRG + 1)
TCY / 2 (BRG + 1)
TCY / 2 (BRG + 1)
1 MHz mode(2)
TCY / 2 (BRG + 1)
TCY / 2 (BRG + 1)
TCY / 2 (BRG + 1)
1 MHz mode(2)
TCY / 2 (BRG + 1)
TCY / 2 (BRG + 1)
ns
1 MHz mode
TF:SCL
IM20
TR:SCL
IM21
IM25
IM26
TSU:STA
IM30
Start Condition
Setup Time
IM31
IM33
IM34
CB is specified to be
from 10 to 400 pF
CB is specified to be
from 10 to 400 pF
TAA:SCL
IM40
Output Valid
From Clock
TCY / 2 (BRG + 1)
ns
1 MHz mode(2)
Hold Time
TCY / 2 (BRG + 1)
ns
3500
ns
1000
ns
(2)
1 MHz mode
CB
IM50
2:
ns
4.7
1.3
1 MHz mode(2)
Note 1:
IM45
TBD
400
pF
BRG is the value of the I2C Baud Rate Generator. Refer to Section 21 Inter-Integrated Circuit (I2C)
in the dsPIC30F Family Reference Manual.
Maximum pin capacitance = 10 pF for all I2C pins (for 1 MHz mode only).
Preliminary
DS70135C-page 199
dsPIC30F4011/4012
FIGURE 24-22:
SCL
IS34
IS31
IS30
IS33
SDA
Stop
Condition
Start
Condition
FIGURE 24-23:
IS21
IS11
IS10
SCL
IS30
IS26
IS31
IS25
IS33
SDA
In
IS40
IS40
IS45
SDA
Out
DS70135C-page 200
Preliminary
dsPIC30F4011/4012
TABLE 24-37: I2C BUS DATA TIMING REQUIREMENTS (SLAVE MODE)
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
No.
IS20
TF:SCL
4.7
1.3
0.5
4.0
0.6
1 MHz mode(1)
THI:SCL
Units
IS11
Characteristic
Clock Low Time
Max
1 MHz mode(1)
TLO:SCL
Min
IS10
Symbol
0.5
300
ns
IS21
TR:SCL
20 + 0.1 CB
300
ns
1 MHz mode(1)
100
1000
ns
THD:DAT
Data Input
Setup Time
300
ns
300
250
ns
100
100
ns
THD:STO
Stop Condition
Setup Time
Stop Condition
Hold Time
IS40
TAA:SCL
ns
0.9
0.3
4.7
0.6
0.25
4.0
0.6
0.25
4.7
0.6
0.6
4000
ns
600
ns
250
Note 1:
CB
3500
1000
ns
350
ns
4.7
1.3
1 MHz mode(1)
IS50
TBF:SDA
ns
IS45
1 MHz mode(1)
IS34
TSU:STO
Start Condition
Hold Time
1 MHz mode(1)
IS33
THD:STA
Start Condition
Setup Time
1 MHz mode(1)
IS31
TSU:STA
CB is specified to be from
10 to 400 pF
ns
1 MHz mode(1)
IS30
CB is specified to be from
10 to 400 pF
ns
1 MHz mode(1)
IS26
Data Input
Hold Time
20 + 0.1 CB
1 MHz mode(1)
TSU:DAT
IS25
ns
Conditions
0.5
400
pF
Bus Capacitive
Loading
ns
Maximum pin capacitance = 10 pF for all I2C pins (for 1 MHz mode only).
Preliminary
DS70135C-page 201
dsPIC30F4011/4012
FIGURE 24-24:
CXTX Pin
(output)
New Value
Old Value
CA10 CA11
CXRX Pin
(input)
CA20
Param
No.
Symbol
Min
Typ(2)
Max
Units
Conditions
CA10
TioF
10
25
ns
CA11
TioR
10
25
ns
CA20
Tcwf
500
ns
Note 1:
2:
DS70135C-page 202
Preliminary
dsPIC30F4011/4012
TABLE 24-39: 10-BIT HIGH-SPEED A/D MODULE SPECIFICATIONS
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
No.
Symbol
Characteristic
Min.
Typ
Max.
Units
Conditions
Device Supply
AD01
AVDD
Greater of
VDD - 0.3
or 2.7
Lesser of
VDD + 0.3
or 5.5
AD02
AVSS
Vss - 0.3
VSS + 0.3
AD05
VREFH
AVDD
AVss
AVDD - 2.7
AVss - 0.3
AVDD + 0.3
300
3
A
A
A/D operating
A/D off
VREFH
Reference Inputs
AD06
VREFL
AD07
VREF
AD08
IREF
Current Drain
AD10
AVss+2.7
200
.001
Analog Input
VREFL
AD11
VIN
AVDD + 0.3
AD12
Leakage Current
AVSS - 0.3
0.001
0.244
AD13
Leakage Current
0.001
0.244
AD15
RSS
Switch Resistance
5K
AD16
AD17
RIN
Recommended Impedance
Of Analog Voltage Source
bits
5K
pF
2.5
DC Accuracy
AD20
Nr
Resolution
AD21
INL
Integral Nonlinearity
0.5
< 1
AD21A INL
Integral Nonlinearity
0.5
< 1
AD22
DNL
Differential Nonlinearity
0.5
< 1
AD22A DNL
Differential Nonlinearity
0.5
< 1
GERR
Gain Error
0.75
TBD
AD23A GERR
Gain Error
0.75
TBD
AD23
Note 1:
2:
10 data bits
Because the sample caps will eventually lose charge, clock rates below 10 kHz can affect linearity
performance, especially at elevated temperatures.
The A/D conversion result never decreases with an increase in the input voltage, and has no missing
codes.
Preliminary
DS70135C-page 203
dsPIC30F4011/4012
TABLE 24-39: 10-BIT HIGH-SPEED A/D MODULE SPECIFICATIONS (CONTINUED)
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
No.
Symbol
Characteristic
Min.
Typ
Max.
Units
Conditions
EOFF
Offset Error
0.75
TBD
AD24A EOFF
Offset Error
0.75
TBD
AD25
Monotonicity(2)
AD26
CMRR
Common-Mode Rejection
TBD
dB
AD27
PSRR
TBD
dB
AD28
CTLK
Channel to Channel
Crosstalk
TBD
dB
AD30
THD
TBD
dB
AD31
SINAD
TBD
dB
AD32
SFDR
TBD
dB
AD33
FNYQ
250
kHz
AD34
ENOB
TBD
TBD
bits
AD24
Guaranteed
Dynamic Performance
Note 1:
2:
Because the sample caps will eventually lose charge, clock rates below 10 kHz can affect linearity
performance, especially at elevated temperatures.
The A/D conversion result never decreases with an increase in the input voltage, and has no missing
codes.
DS70135C-page 204
Preliminary
dsPIC30F4011/4012
FIGURE 24-25:
ADCLK
Instruction
Execution SET SAMP
CLEAR SAMP
SAMP
ch0_dischrg
ch0_samp
ch1_dischrg
ch1_samp
eoc
AD61
AD60
TSAMP
AD55
AD55
DONE
ADIF
ADRES(0)
ADRES(1)
Preliminary
DS70135C-page 205
dsPIC30F4011/4012
FIGURE 24-26:
ADCLK
Instruction
Execution SET ADON
SAMP
ch0_dischrg
ch0_samp
ch1_dischrg
ch1_samp
eoc
TSAMP
TSAMP
AD55
TCONV
AD55
DONE
ADIF
ADRES(0)
ADRES(1)
5 - Convert bit 0.
3 - Convert bit 9.
4 - Convert bit 8.
DS70135C-page 206
Preliminary
dsPIC30F4011/4012
TABLE 24-40: 10-BIT HIGH-SPEED A/D CONVERSION TIMING REQUIREMENTS
Standard Operating Conditions: 2.5V to 5.5V
(unless otherwise stated)
Operating temperature -40C TA +85C for Industrial
-40C TA +125C for Extended
AC CHARACTERISTICS
Param
Symbol
No.
Characteristic
Min.
Typ
Max.
Units
Conditions
Clock Parameters
AD50
TAD
154
256
AD51
tRC
700
AD55
tCONV
Conversion Time
AD56
FCNV
Throughput Rate
AD57
TSAMP
Sample Time
AD60
tPCS
AD61
tPSS
AD62
AD63
ns
900
1100
VDD = 5V (Note 1)
VDD = 2.7V (Note 1)
ns
ns
Conversion Rate
13 TAD
VDD = VREF = 5V
VDD = VREF = 2.7V
500
100
1 TAD
ksps
ksps
ns
VDD = 3-5.5V
Timing Parameters
Note 1:
TAD
ns
0.5 TAD
1.5 TAD
ns
tCSS
Conversion Completion to
Sample Start (ASAM = 1)
TBD
ns
tDPU
TBD
Because the sample caps will eventually lose charge, clock rates below 10 kHz can affect linearity
performance, especially at elevated temperatures.
Preliminary
DS70135C-page 207
dsPIC30F4011/4012
NOTES:
DS70135C-page 208
Preliminary
dsPIC30F4011/4012
25.0
PACKAGING INFORMATION
25.1
Example
dsPIC30F4012
30I/SP e3
0510017
XXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXX
YYWWNNN
28-Lead SOIC
Example
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
YYWWNNN
dsPIC30F4012
30I/SO e3
0510017
44-Lead QFN
Example
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
YYWWNNN
dsPIC
30F4012
30I/ML e3
0510017
40-Lead PDIP
Example
XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX
YYWWNNN
Legend: XX...X
Y
YY
WW
NNN
e3
Note:
dsPIC30F4011
30I/P e3
0510017
Customer-specific information
Year code (last digit of calendar year)
Year code (last 2 digits of calendar year)
Week code (week of January 1 is week 01)
Alphanumeric traceability code
Pb-free JEDEC designator for Matte Tin (Sn)
This package is Pb-free. The Pb-free JEDEC designator ( e3 )
can be found on the outer packaging for this package.
In the event the full Microchip part number cannot be marked on one line, it will
be carried over to the next line, thus limiting the number of available
characters for customer-specific information.
* Standard PICmicro device marking consists of Microchip part number, year code, week code and
traceability code. For PICmicro device marking beyond this, certain price adders apply. Please check with
your Microchip Sales Office. For QTP devices, any special marking adders are included in QTP price.
Preliminary
DS70135C-page 209
dsPIC30F4011/4012
Package Marking Information (Continued)
44-Lead TQFP
Example
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
YYWWNNN
dsPIC
30F4011
30I/PT e3
0510017
44-Lead QFN
Example
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
YYWWNNN
DS70135C-page 210
dsPIC
30F4011
30I/ML e3
0510017
Preliminary
dsPIC30F4011/4012
25.2
Package Details
28-Lead Skinny Plastic Dual In-line (SP) 300 mil Body (PDIP)
E1
2
n
A2
A
L
B1
A1
eB
Units
Number of Pins
Pitch
Dimension Limits
n
p
INCHES*
MIN
NOM
MILLIMETERS
MAX
MIN
NOM
28
MAX
28
.100
2.54
.140
.150
.160
3.56
3.81
4.06
A2
.125
.130
.135
3.18
3.30
3.43
A1
.015
0.38
.300
.310
.325
7.62
7.87
8.26
E1
.275
.285
.295
6.99
7.24
7.49
Overall Length
1.345
1.365
1.385
34.16
34.67
35.18
.125
.130
.135
3.18
3.30
3.43
Lead Thickness
L
c
.008
.012
.015
0.20
0.29
0.38
B1
.040
.053
.065
1.02
1.33
1.65
.016
.019
.022
0.41
0.48
0.56
eB
.320
.350
.430
8.13
8.89
10.92
10
15
10
15
10
15
10
15
* Controlling Parameter
Significant Characteristic
Notes:
Dimension D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
.010 (0.254mm) per side.
JEDEC Equivalent: MO-095
Preliminary
DS70135C-page 211
dsPIC30F4011/4012
28-Lead Plastic Small Outline (SO) Wide, 300 mil Body (SOIC)
E
E1
p
B
2
1
n
h
45
c
A2
L
Units
Dimension Limits
n
p
Number of Pins
Pitch
Overall Height
Molded Package Thickness
Standoff
Overall Width
Molded Package Width
Overall Length
Chamfer Distance
Foot Length
Foot Angle Top
Lead Thickness
Lead Width
Mold Draft Angle Top
Mold Draft Angle Bottom
* Controlling Parameter
Significant Characteristic
A
A2
A1
E
E1
D
h
L
c
B
A1
MIN
.093
.088
.004
.394
.288
.695
.010
.016
0
.009
.014
0
0
INCHES*
NOM
28
.050
.099
.091
.008
.407
.295
.704
.020
.033
4
.011
.017
12
12
MAX
.104
.094
.012
.420
.299
.712
.029
.050
8
.013
.020
15
15
MILLIMETERS
NOM
28
1.27
2.36
2.50
2.24
2.31
0.10
0.20
10.01
10.34
7.32
7.49
17.65
17.87
0.25
0.50
0.41
0.84
0
4
0.23
0.28
0.36
0.42
0
12
0
12
MIN
MAX
2.64
2.39
0.30
10.67
7.59
18.08
0.74
1.27
8
0.33
0.51
15
15
Notes:
Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
.010 (0.254mm) per side.
JEDEC Equivalent: MS-013
Drawing No. C04-052
DS70135C-page 212
Preliminary
dsPIC30F4011/4012
40-Lead Plastic Dual In-line (P) 600 mil Body (PDIP)
E1
2
1
n
E
A2
B1
A1
eB
B
Units
Dimension Limits
n
p
MIN
INCHES*
NOM
40
.100
.175
.150
MAX
MILLIMETERS
NOM
40
2.54
4.06
4.45
3.56
3.81
0.38
15.11
15.24
13.46
13.84
51.94
52.26
3.05
3.30
0.20
0.29
0.76
1.27
0.36
0.46
15.75
16.51
5
10
5
10
MIN
Number of Pins
Pitch
Top to Seating Plane
A
.160
.190
Molded Package Thickness
A2
.140
.160
Base to Seating Plane
.015
A1
Shoulder to Shoulder Width
E
.595
.600
.625
Molded Package Width
.530
.545
.560
E1
Overall Length
D
2.045
2.058
2.065
Tip to Seating Plane
L
.120
.130
.135
c
Lead Thickness
.008
.012
.015
Upper Lead Width
B1
.030
.050
.070
Lower Lead Width
B
.014
.018
.022
eB
Overall Row Spacing
.620
.650
.680
Preliminary
MAX
4.83
4.06
15.88
14.22
52.45
3.43
0.38
1.78
0.56
17.27
15
15
DS70135C-page 213
dsPIC30F4011/4012
44-Lead Plastic Thin Quad Flatpack (PT) 10x10x1 mm Body, 1.0/0.10 mm Lead Form (TQFP)
E
E1
#leads=n1
p
D1
2
1
B
n
CH x 45
A
c
A1
A2
(F)
Units
Dimension Limits
n
p
Number of Pins
Pitch
Pins per Side
Overall Height
Molded Package Thickness
Standoff
Foot Length
Footprint (Reference)
Foot Angle
Overall Width
Overall Length
Molded Package Width
Molded Package Length
Lead Thickness
Lead Width
Pin 1 Corner Chamfer
Mold Draft Angle Top
Mold Draft Angle Bottom
* Controlling Parameter
Significant Characteristic
n1
A
A2
A1
L
(F)
E
D
E1
D1
c
B
CH
MIN
.039
.037
.002
.018
0
.463
.463
.390
.390
.004
.012
.025
5
5
INCHES
NOM
44
.031
11
.043
.039
.004
.024
.039
3.5
.472
.472
.394
.394
.006
.015
.035
10
10
MAX
.047
.041
.006
.030
7
.482
.482
.398
.398
.008
.017
.045
15
15
MILLIMETERS*
NOM
44
0.80
11
1.00
1.10
0.95
1.00
0.05
0.10
0.45
0.60
1.00
0
3.5
11.75
12.00
11.75
12.00
9.90
10.00
9.90
10.00
0.09
0.15
0.30
0.38
0.64
0.89
5
10
5
10
MIN
MAX
1.20
1.05
0.15
0.75
7
12.25
12.25
10.10
10.10
0.20
0.44
1.14
15
15
Notes:
Dimensions D1 and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
.010 (0.254mm) per side.
JEDEC Equivalent: MS-026
Drawing No. C04-076
DS70135C-page 214
Preliminary
dsPIC30F4011/4012
44-Lead Plastic Quad Flat No Lead Package (ML) 8x8 mm Body (QFN)
Preliminary
DS70135C-page 215
dsPIC30F4011/4012
NOTES:
DS70135C-page 216
Preliminary
dsPIC30F4011/4012
INDEX
Numerics
10-bit High Speed A/D
A/D Acquisition Requirements .................................. 135
Aborting a Conversion .............................................. 134
ADCHS ..................................................................... 131
ADCON1 ................................................................... 131
ADCON2 ................................................................... 131
ADCON3 ................................................................... 131
ADCSSL.................................................................... 131
ADPCFG ................................................................... 131
Configuring Analog Port Pins.................................... 137
Connection Considerations....................................... 137
Conversion Operation ............................................... 133
Effects of a Reset...................................................... 136
Operation During CPU Idle Mode ............................. 136
Operation During CPU Sleep Mode.......................... 136
Output Formats ......................................................... 136
Power-down Modes .................................................. 136
Programming the Start of Conversion Trigger .......... 134
Register Map............................................................. 138
Result Buffer ............................................................. 133
Sampling Requirements............................................ 135
Selecting the Conversion Clock ................................ 134
Selecting the Conversion Sequence......................... 133
10-Bit High Speed Analog-to-Digital (A/D)
Converter Module ..................................................... 131
16-bit Up/Down Position Counter Mode.............................. 86
Count Direction Status ................................................ 86
Error Checking ............................................................ 86
8-Output PWM
Register Map............................................................. 100
A
AC Characteristics ............................................................ 177
Load Conditions ........................................................ 177
AC Temperature and Voltage Specifications .................... 177
Address Generator Units .................................................... 35
Alternate 16-bit Timer/Counter............................................ 87
Alternate Vector Table ........................................................ 45
Assembler
MPASM Assembler................................................... 161
Automatic Clock Stretch.................................................... 108
During 10-bit Addressing (STREN = 1)..................... 108
During 7-bit Addressing (STREN = 1)....................... 108
Receive Mode ........................................................... 108
Transmit Mode .......................................................... 108
B
Bandgap Start-up Time
Requirements............................................................ 184
Timing Characteristics .............................................. 184
Barrel Shifter ....................................................................... 22
Bit-Reversed Addressing .................................................... 38
Example ...................................................................... 38
Implementation ........................................................... 38
Modifier Values (table) ................................................ 39
Sequence Table (16-Entry)......................................... 39
Block Diagrams
10-bit High Speed A/D Functional............................. 132
16-bit Timer1 Module .................................................. 64
16-bit Timer4............................................................... 74
16-bit Timer5............................................................... 75
C
C Compilers
MPLAB C17.............................................................. 162
MPLAB C18.............................................................. 162
MPLAB C30.............................................................. 162
CAN Module ..................................................................... 121
CAN1 Register Map.................................................. 128
I/O Timing Characteristics ........................................ 202
I/O Timing Requirements.......................................... 202
Overview................................................................... 121
Center Aligned PWM .......................................................... 95
CLKOUT and I/O Timing
Characteristics.......................................................... 182
Requirements ........................................................... 182
Code Examples
Data EEPROM Block Erase ....................................... 54
Data EEPROM Block Write ........................................ 56
Data EEPROM Read.................................................. 53
Data EEPROM Word Erase ....................................... 54
Data EEPROM Word Write ........................................ 55
Erasing a Row of Program Memory ........................... 49
Initiating a Programming Sequence ........................... 50
Loading Write Latches................................................ 50
Code Protection ................................................................ 139
Complementary PWM Operation........................................ 95
Configuring Analog Port Pins.............................................. 58
Control Registers ................................................................ 48
NVMADR .................................................................... 48
NVMADRU ................................................................. 48
NVMCON.................................................................... 48
NVMKEY .................................................................... 48
Core Overview .................................................................... 15
Core Register Map.............................................................. 31
Customer Change Notification Service............................. 223
Customer Notification Service .......................................... 223
Customer Support............................................................. 223
Preliminary
DS70135C-page 217
dsPIC30F4011/4012
D
Data Access from Program Memory Using
Program Space Visibility ............................................. 26
Data Accumulators and Adder/Subtractor........................... 20
Data Space Write Saturation ...................................... 22
Overflow and Saturation ............................................. 20
Round Logic ................................................................ 21
Write Back................................................................... 21
Data Address Space ........................................................... 27
Alignment .................................................................... 30
Alignment (Figure) ...................................................... 30
Effect of Invalid Memory Accesses ............................. 30
MCU and DSP (MAC Class) Instructions Example..... 29
Memory Map ......................................................... 27, 28
Near Data Space ........................................................ 31
Software Stack ............................................................ 31
Spaces ........................................................................ 30
Width........................................................................... 30
Data EEPROM Memory ...................................................... 53
Erasing ........................................................................ 54
Erasing, Block ............................................................. 54
Erasing, Word ............................................................. 54
Protection Against Spurious Write .............................. 56
Reading....................................................................... 53
Write Verify ................................................................. 56
Writing ......................................................................... 55
Writing, Block .............................................................. 56
Writing, Word .............................................................. 55
DC Characteristics ............................................................ 167
BOR .......................................................................... 176
Brown-out Reset ....................................................... 175
I/O Pin Input Specifications ....................................... 174
I/O Pin Output Specifications .................................... 175
Idle Current (IIDLE) .................................................... 171
Operating Current (IDD)............................................. 169
Power-Down Current (IPD) ........................................ 173
Program and EEPROM............................................. 176
Temperature and Voltage Specifications .................. 167
Dead-Time Generators ....................................................... 96
Ranges........................................................................ 96
Demonstration Boards
PICDEM 1 ................................................................. 164
PICDEM 17 ............................................................... 165
PICDEM 18R ............................................................ 165
PICDEM 2 Plus ......................................................... 164
PICDEM 3 ................................................................. 164
PICDEM 4 ................................................................. 164
PICDEM LIN ............................................................. 165
PICDEM USB............................................................ 165
PICDEM.net Internet/Ethernet .................................. 164
Development Support ....................................................... 161
Device Configuration
Register Map............................................................. 152
Device Configuration Registers......................................... 150
FBORPOR ................................................................ 150
FGS........................................................................... 150
FOSC ........................................................................ 150
FWDT........................................................................ 150
Device Overview ................................................................... 7
Divide Support..................................................................... 18
DSP Engine......................................................................... 18
Multiplier...................................................................... 20
dsPIC30F6010 Port Register Map ................................ 59, 60
DS70135C-page 218
E
Edge Aligned PWM............................................................. 94
Electrical Characteristics .................................................. 167
AC............................................................................. 177
DC ............................................................................ 167
Equations
A/D Conversion Clock............................................... 134
Baud Rate......................................................... 117, 127
PWM Period................................................................ 94
PWM Resolution ......................................................... 94
Serial Clock Rate ...................................................... 110
Errata .................................................................................... 6
Evaluation and Programming Tools.................................. 165
Exception Processing
Interrupt Priority .......................................................... 42
Exception Sequence
Trap Sources .............................................................. 43
External Clock Timing Characteristics
Timer 1, 2, 3, 4 and 5 ............................................... 185
External Clock Timing Requirements ............................... 178
Timer1 ...................................................................... 185
Timer2 and Timer4 ................................................... 186
Timer3 and Timer5 ................................................... 186
External Interrupt Requests ................................................ 45
F
Fast Context Saving ........................................................... 45
Flash Program Memory ...................................................... 47
In-Circuit Serial Programming (ICSP)......................... 47
Run Time Self-Programming (RTSP) ......................... 47
Table Instruction Operation Summary ........................ 47
I
I/O Pin Specifications
Input.......................................................................... 174
Output ....................................................................... 175
I/O Ports.............................................................................. 57
Parallel I/O (PIO) ........................................................ 57
I2C 10-bit Slave Mode Operation...................................... 107
Reception ................................................................. 108
Transmission ............................................................ 107
I2C 7-bit Slave Mode Operation........................................ 107
Reception ................................................................. 107
Transmission ............................................................ 107
I2C Master Mode
Baud Rate Generator ............................................... 110
Clock Arbitration ....................................................... 110
Multi-Master Communication, Bus Collision
and Bus Arbitration ........................................... 110
Reception ................................................................. 110
Transmission ............................................................ 109
I2C Module........................................................................ 105
Addresses................................................................. 107
Bus Data Timing Characteristics
Master Mode..................................................... 198
Slave Mode....................................................... 200
Bus Data Timing Requirements
Master Mode..................................................... 199
Slave Mode....................................................... 201
Bus Start/Stop Bits Timing Characteristics
Master Mode..................................................... 198
Slave Mode....................................................... 200
Preliminary
dsPIC30F4011/4012
General Call Address Support .................................. 109
Interrupts................................................................... 109
IPMI Support ............................................................. 109
Master Operation ...................................................... 109
Master Support ......................................................... 109
Operating Function Description ................................ 105
Operation During CPU Sleep and Idle Modes .......... 110
Pin Configuration ...................................................... 105
Programmers Model................................................. 105
Register Map............................................................. 111
Registers................................................................... 105
Slope Control ............................................................ 109
Software Controlled Clock Stretching (STREN = 1).. 108
Various Modes .......................................................... 105
Idle Current (IIDLE) ............................................................ 171
In-Circuit Serial Programming (ICSP) ............................... 139
Independent PWM Output .................................................. 97
Initialization Condition for RCON Register Case 1 ........... 148
Initialization Condition for RCON Register Case 2 ........... 148
Input Capture (CAPx) Timing Characteristics ................... 188
Input Capture Interrupts ...................................................... 79
Register Map............................................................... 80
Input Capture Module ......................................................... 77
In CPU Sleep Mode .................................................... 78
Simple Capture Event Mode ....................................... 78
Input Capture Timing Requirements ................................. 188
Input Change Notification Module ....................................... 61
Register Map (bits 7-0) ............................................... 61
Input Characteristics
QEA/QEB.................................................................. 191
Instruction Addressing Modes............................................. 35
File Register Instructions ............................................ 35
Fundamental Modes Supported.................................. 35
MAC Instructions......................................................... 36
MCU Instructions ........................................................ 35
Move and Accumulator Instructions............................ 36
Other Instructions........................................................ 36
Instruction Set Overview ................................................... 156
Instruction Set Summary................................................... 153
Internal Clock Timing Examples ....................................... 179
Internet Address................................................................ 223
Interrupt Controller
Register Map............................................................... 46
Interrupt Priority
Traps........................................................................... 43
Interrupt Sequence ............................................................. 45
Interrupt Stack Frame ................................................. 45
Interrupts ............................................................................. 41
L
Load Conditions ................................................................ 177
M
Memory Organization.......................................................... 23
Microchip Internet Web Site .............................................. 223
Modulo Addressing ............................................................. 36
Applicability ................................................................. 38
Operation Example ..................................................... 37
Start and End Address................................................ 37
W Address Register Selection .................................... 37
Motor Control PWM Module................................................ 91
Fault Timing Characteristics ..................................... 190
Timing Characteristics .............................................. 190
Timing Requirements................................................ 190
MPLAB ASM30 Assembler, Linker, Librarian ................... 162
O
OC/PWM Module Timing Characteristics ......................... 189
Operating Current (IDD) .................................................... 169
Operating Frequency vs Voltage
dsPIC30FXXXX-20 (Extended) ................................ 167
Oscillator
Operating Modes (Table).......................................... 140
Oscillator Configurations................................................... 142
Fail-Safe Clock Monitor ............................................ 144
Fast RC (FRC).......................................................... 143
Initial Clock Source Selection ................................... 142
Low Power RC (LPRC)............................................. 143
LP Oscillator Control................................................. 142
Phase Locked Loop (PLL) ........................................ 143
Start-up Timer (OST)................................................ 142
Oscillator Selection ........................................................... 139
Oscillator Start-up Timer
Timing Characteristics .............................................. 183
Timing Requirements ............................................... 184
Output Compare Interrupts ................................................. 83
Output Compare Mode
Register Map .............................................................. 84
Output Compare Module .................................................... 81
Timing Characteristics .............................................. 188
Timing Requirements ............................................... 188
Output Compare Operation During CPU Idle Mode ........... 83
Output Compare Sleep Mode Operation ............................ 83
P
Packaging ......................................................................... 209
Marking..................................................................... 209
PICkit 1 Flash Starter Kit .................................................. 165
PICSTART Plus Development Programmer..................... 164
Pinout Descriptions....................................................... 10, 12
PLL Clock Timing Specifications ...................................... 179
POR. See Power-on Reset
Port Write/Read Example ................................................... 58
Position Measurement Mode .............................................. 87
Power Saving Modes........................................................ 149
Idle............................................................................ 150
Sleep ........................................................................ 149
Power Saving Modes (Sleep and Idle) ............................. 139
Power-Down Current (IPD)................................................ 173
Power-on Reset (POR)..................................................... 139
Oscillator Start-up Timer (OST)................................ 139
Power-up Timer (PWRT) .......................................... 139
Power-up Timer
Timing Characteristics .............................................. 183
Timing Requirements ............................................... 184
PRO MATE II Universal Device Programmer ................... 163
Program Address Space..................................................... 23
Construction ............................................................... 24
Data Access From Program Memory Using
Table Instructions ............................................... 25
Data Access from, Address Generation ..................... 24
Memory Map............................................................... 23
Preliminary
DS70135C-page 219
dsPIC30F4011/4012
Table Instructions
TBLRDH.............................................................. 25
TBLRDL .............................................................. 25
TBLWTH ............................................................. 25
TBLWTL.............................................................. 25
Program and EEPROM Characteristics ............................ 176
Program Counter................................................................. 16
Program Data Table Access ............................................... 26
Program Space Visibility
Window into Program Space Operation...................... 27
Programmable................................................................... 139
Programmable Digital Noise Filters..................................... 87
Programmers Model........................................................... 16
Diagram ...................................................................... 17
Programming Operations .................................................... 49
Algorithm for Program Flash ....................................... 49
Erasing a Row of Program Memory ............................ 49
Initiating the Programming Sequence ......................... 50
Loading Write Latches ................................................ 50
Protection Against Accidental Writes to OSCCON ........... 144
PWM Duty Cycle Comparison Units ................................... 95
Duty Cycle Register Buffers ........................................ 95
PWM Fault Pins .................................................................. 98
Enable Bits.................................................................. 98
Fault States ................................................................. 98
Modes ......................................................................... 98
Cycle-by-Cycle.................................................... 98
Latched ............................................................... 98
PWM Operation During CPU Idle Mode.............................. 99
PWM Operation During CPU Sleep Mode .......................... 99
PWM Output and Polarity Control ....................................... 98
Output Pin Control ...................................................... 98
PWM Output Override......................................................... 97
Complementary Output Mode ..................................... 97
Synchronization .......................................................... 97
PWM Period ........................................................................ 94
PWM Special Event Trigger ................................................ 99
Postscaler ................................................................... 99
PWM Time Base ................................................................. 93
Continuous Up/Down Counting Modes ....................... 93
Double Update Mode .................................................. 94
Free Running Mode .................................................... 93
Postscaler ................................................................... 94
Prescaler ..................................................................... 94
Single Shot Mode........................................................ 93
PWM Update Lockout ......................................................... 99
Q
QEA/QEB Input Characteristics ........................................ 191
QEI Module
External Clock Timing Requirements........................ 187
Index Pulse Timing Characteristics........................... 192
Index Pulse Timing Requirements ............................ 192
Operation During CPU Idle Mode ............................... 88
Operation During CPU Sleep Mode ............................ 87
Register Map............................................................... 89
Timer Operation During CPU Idle Mode ..................... 88
Timer Operation During CPU Sleep Mode.................. 87
Quadrature Decoder Timing Requirements ...................... 191
Quadrature Encoder Interface (QEI) Module ...................... 85
Quadrature Encoder Interface Interrupts ............................ 88
Quadrature Encoder Interface Logic ................................... 86
DS70135C-page 220
R
Reset ........................................................................ 139, 145
Reset Sequence ................................................................. 43
Reset Sources ............................................................ 43
Reset Timing Characteristics............................................ 183
Reset Timing Requirements ............................................. 184
Resets
BOR, Programmable ................................................ 147
POR .......................................................................... 145
POR with Long Crystal Start-up Time....................... 147
POR, Operating without FSCM and PWRT .............. 147
S
Simple Capture Event Mode
Capture Buffer Operation............................................ 78
Capture Prescaler....................................................... 78
Hall Sensor Mode ....................................................... 78
Input Capture in CPU Idle Mode................................. 79
Timer2 and Timer3 Selection Mode............................ 78
Simple OC/PWM Mode Timing Requirements ................. 189
Simple Output Compare Match Mode ................................ 82
Simple PWM Mode ............................................................. 82
Input Pin Fault Protection ........................................... 82
Period ......................................................................... 83
Single Pulse PWM Operation ............................................. 97
Software Simulator (MPLAB SIM) .................................... 162
Software Simulator (MPLAB SIM30) ................................ 162
Software Stack Pointer, Frame Pointer .............................. 16
CALL Stack Frame ..................................................... 31
SPI Mode
Slave Select Synchronization ................................... 103
SPI1 Register Map.................................................... 104
SPI Module ....................................................................... 101
Framed SPI Support ................................................. 101
Operating Function Description ................................ 101
SDOx Disable ........................................................... 101
Timing Characteristics
Master Mode (CKE = 0).................................... 193
Master Mode (CKE = 1).................................... 194
Slave Mode (CKE = 1).............................. 195, 196
Timing Requirements
Master Mode (CKE = 0).................................... 193
Master Mode (CKE = 1).................................... 194
Slave Mode (CKE = 0)...................................... 195
Slave Mode (CKE = 1)...................................... 197
Word and Byte Communication ................................ 101
SPI Operation During CPU Idle Mode .............................. 103
SPI Operation During CPU Sleep Mode........................... 103
Status Register ................................................................... 16
Symbols Used in Opcode Descriptions ............................ 154
System Integration............................................................ 139
Overview................................................................... 139
Register Map ............................................................ 152
T
Temperature and Voltage Specifications
AC............................................................................. 177
DC ............................................................................ 167
Timer1 Module.................................................................... 63
16-bit Asynchronous Counter Mode ........................... 63
16-bit Synchronous Counter Mode ............................. 63
16-bit Timer Mode....................................................... 63
Preliminary
dsPIC30F4011/4012
Gate Operation ........................................................... 64
Interrupt....................................................................... 65
Operation During Sleep Mode .................................... 64
Prescaler..................................................................... 64
Real-Time Clock ......................................................... 65
RTC Interrupts .................................................... 65
RTC Oscillator Operation.................................... 65
Register Map............................................................... 66
Timer2 and Timer3 Selection Mode .................................... 82
Timer2/3 Module ................................................................. 67
32-bit Synchronous Counter Mode ............................. 67
32-bit Timer Mode....................................................... 67
ADC Event Trigger...................................................... 70
Gate Operation ........................................................... 70
Interrupt....................................................................... 70
Operation During Sleep Mode .................................... 70
Register Map............................................................... 71
Timer Prescaler........................................................... 70
Timer4/5 Module ................................................................. 73
Register Map............................................................... 76
TimerQ (QEI Module) External Clock Timing
Characteristics .......................................................... 187
Timing Characteristics
A/D Conversion
10-Bit High-speed (CHPS = 01,
SIMSAM = 0, ASAM = 0,
SSRC = 000) ............................................ 205
10-Bit High-speed (CHPS = 01,
SIMSAM = 0, ASAM = 1,
SSRC = 111, SAMC = 00001) .................. 206
Bandgap Start-up Time............................................. 184
CAN Module I/O........................................................ 202
CLKOUT and I/O....................................................... 182
External Clock........................................................... 177
I2C Bus Data
Master Mode ..................................................... 198
Slave Mode ....................................................... 200
I2C Bus Start/Stop Bits
Master Mode ..................................................... 198
Slave Mode ....................................................... 200
Input Capture (CAPx)................................................ 188
Motor Control PWM Module...................................... 190
Motor Control PWM Module Falult............................ 190
OC/PWM Module ...................................................... 189
Oscillator Start-up Timer ........................................... 183
Output Compare Module........................................... 188
Power-up Timer ........................................................ 183
QEI Module Index Pulse ........................................... 192
Reset......................................................................... 183
SPI Module
Master Mode (CKE = 0) .................................... 193
Master Mode (CKE = 1) .................................... 194
Slave Mode (CKE = 0) ...................................... 195
Slave Mode (CKE = 1) ...................................... 196
Timer 1, 2, 3, 4 and 5 External Clock........................ 185
TimerQ (QEI Module) External Clock ....................... 187
Watchdog Timer........................................................ 183
Timing Diagrams
Center Aligned PWM .................................................. 95
Dead-Time .................................................................. 96
Edge Aligned PWM..................................................... 94
PWM Output ............................................................... 83
Time-out Sequence on Power-up
(MCLR Not Tied to VDD), Case 1...................... 146
U
UART
Address Detect Mode ............................................... 117
Auto Baud Support ................................................... 118
Baud Rate Generator ............................................... 117
Enabling and Setting Up UART ................................ 115
Alternate I/O ..................................................... 115
Disabling........................................................... 115
Enabling ........................................................... 115
Setting Up Data, Parity and Stop Bit
Selections................................................. 115
Loopback Mode ........................................................ 117
Module Overview...................................................... 113
Operation During CPU Sleep and Idle Modes.......... 118
Receiving Data ......................................................... 116
In 8-bit or 9-bit Data Mode................................ 116
Interrupt ............................................................ 116
Receive Buffer (UxRCB)................................... 116
Reception Error Handling ......................................... 116
Framing Error (FERR) ...................................... 117
Idle Status ........................................................ 117
Parity Error (PERR) .......................................... 117
Receive Break .................................................. 117
Receive Buffer Overrun Error (OERR Bit) ........ 116
Preliminary
DS70135C-page 221
dsPIC30F4011/4012
Transmitting Data...................................................... 115
In 8-bit Data Mode ............................................ 115
In 9-bit Data Mode ............................................ 115
Interrupt............................................................. 116
Transmit Buffer (UxTXB)................................... 115
UART1 Register Map ................................................ 119
UART2 Register Map ................................................ 119
Unit ID Locations............................................................... 139
Universal Asynchronous Receiver Transmitter
Module (UART) ......................................................... 113
DS70135C-page 222
W
Wake-up from Sleep ......................................................... 139
Wake-up from Sleep and Idle ............................................. 45
Watchdog Timer
Timing Characteristics .............................................. 183
Timing Requirements................................................ 184
Watchdog Timer (WDT)............................................ 139, 149
Enabling and Disabling ............................................. 149
Operation .................................................................. 149
WWW Address ................................................................. 223
WWW, On-Line Support ....................................................... 6
Preliminary
dsPIC30F4011/4012
THE MICROCHIP WEB SITE
CUSTOMER SUPPORT
Distributor or Representative
Local Sales Office
Field Application Engineer (FAE)
Technical Support
Development Systems Information Line
Customers should contact their distributor, representative or field application engineer (FAE) for support.
Local sales offices are also available to help
customers. A listing of sales offices and locations is
included in the back of this document.
Technical support is available through the web site
at: http://support.microchip.com
In addition, there is a Development Systems Information Line which lists the latest versions of Microchips
development systems software products. This line also
provides information on how customers can receive
currently available upgrade kits.
The Development
numbers are:
Systems
Information
Line
Preliminary
DS70135C-page 223
dsPIC30F4011/4012
READER RESPONSE
It is our intention to provide you with the best documentation possible to ensure successful use of your Microchip product. If you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation
can better serve you, please FAX your comments to the Technical Publications Manager at (480) 792-4150.
Please list the following information, and use this outline to provide us with your comments about this document.
To:
RE:
Reader Response
From: Name
Company
Address
City / State / ZIP / Country
Telephone: (_______) _________ - _________
Application (optional):
Would you like a reply?
Device: dsPIC30F4011/4012
N
Literature Number: DS70135C
Questions:
1. What are the best features of this document?
2. How does this document meet your hardware and software development needs?
3. Do you find the organization of this document easy to follow? If not, why?
4. What additions to the document do you think would enhance the structure and subject?
5. What deletions from the document could be made without affecting the overall usefulness?
DS70135C-page 224
Preliminary
dsPIC30F4011/4012
PRODUCT IDENTIFICATION SYSTEM
To order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office.
d s P I C 3 0 F 6 0 1 0 AT- 3 0 I / P F - 0 0 0
Custom ID (3 digits) or
Engineering Sample (ES)
Trademark
Architecture
Package
PF = TQFP 14x14
S = Die (Waffle Pack)
W = Die (Wafers)
Flash
Memory Size in Bytes
0 = ROMless
1 = 1K to 6K
2 = 7K to 12K
3 = 13K to 24K
4 = 25K to 48K
5 = 49K to 96K
6 = 97K to 192K
7 = 193K to 384K
8 = 385K to 768K
9 = 769K and Up
Temperature
I = Industrial -40C to +85C
E = Extended High Temp -40C to +125C
Speed
20 = 20 MIPS
30 = 30 MIPS
Device ID
Example:
dsPIC30F6010AT-30I/PF = 30 MIPS, Industrial temp., TQFP package, Rev. A
Preliminary
DS70135C-page 225
ASIA/PACIFIC
ASIA/PACIFIC
EUROPE
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http:\\support.microchip.com
Web Address:
www.microchip.com
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
India - Bangalore
Tel: 91-80-2229-0061
Fax: 91-80-2229-0062
China - Beijing
Tel: 86-10-8528-2100
Fax: 86-10-8528-2104
Austria - Weis
Tel: 43-7242-2244-399
Fax: 43-7242-2244-393
Denmark - Ballerup
Tel: 45-4420-9895
Fax: 45-4420-9910
China - Chengdu
Tel: 86-28-8676-6200
Fax: 86-28-8676-6599
Japan - Kanagawa
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
France - Massy
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
China - Fuzhou
Tel: 86-591-8750-3506
Fax: 86-591-8750-3521
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Germany - Ismaning
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Atlanta
Alpharetta, GA
Tel: 770-640-0034
Fax: 770-640-0307
Boston
Westford, MA
Tel: 978-692-3848
Fax: 978-692-3821
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
Kokomo, IN
Tel: 765-864-8360
Fax: 765-864-8387
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
China - Shunde
Tel: 86-757-2839-5507
Fax: 86-757-2839-5571
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
England - Berkshire
Tel: 44-118-921-5869
Fax: 44-118-921-5820
Taiwan - Hsinchu
Tel: 886-3-572-9526
Fax: 886-3-572-6459
China - Qingdao
Tel: 86-532-502-7355
Fax: 86-532-502-7205
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
San Jose
Mountain View, CA
Tel: 650-215-1444
Fax: 650-961-0286
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
10/20/04
DS70135C-page 226
Preliminary