Six External Interrupts (Power Drive
Protect, Reset, NMI, and Three Maskable
Interrupts)
D
Four Power-Down Modes for Low-Power
Operation
D
Scan-Based Emulation
D
Development Tools Available:
– Texas Instruments (TI) ANSI
C Compiler, Assembler/Linker, and
C-Source Debugger
– Scan-Based Self-Emulation (XDS510)
– Third-Party Digital Motor Control and
Fuzzy-Logic Development Support
description
The TMS320C240 and TMS320F240 devices are the first members of a new family of DSP controllers based
on the TMS320C2xx generation of 16-bit fixed-point digital signal processors (DSPs). Unless otherwise noted,
the term ’x240 refers to both the TMS320C240 and the TMS320F240. Table 1 provides a comparison of the
features of each device. The only difference between these two devices is the type of program memory: the
’C240 contains 16K words of ROM and the ’F240 contains 16K words of flash. This new family is optimized for
digital motor/motion control applications. The DSP controllers combine the enhanced TMS320 architectural
design of the ’C2xLP core CPU for low-cost, high-performance processing capabilities and several advanced
peripherals optimized for motor/motion control applications. These peripherals include the event manager
module, which provides general-purpose timers and compare registers to generate up to 12 PWM outputs, and
a dual10-bit analog-to-digital converter (ADC), which can perform two simultaneous conversions within 6.1 µs.
See the functional block diagram.
Please be aware that an important notice concerning availability, standard warranty, and use in critical applications of
Texas Instruments semiconductor products and disclaimers thereto appears at the end of this data sheet.
TI and XDS510 are trademarks of Texas Instruments Incorporated.
PRODUCTION DATA information is current as of publication date.
Products conform to specifications per the terms of Texas Instruments
standard warranty. Production processing does not necessarily include
testing of all parameters.
Parallel address bus A0 [least significant bit (LSB)] through A15 [most significant bit (MSB)]. A15–A0
are multiplexed to address external data/program memory or I/O. A15–A0 are placed in
high-impedance state when EMU1/OFF
modes.
Parallel data bus D0 (LSB) through D15 (MSB). D15–D0 are multiplexed to transfer data between the
TMS320x240 and external data/program memory and I/O space (devices). D15–D0 are placed in the
high-impedance state when not outputting, when in power-down mode, when reset (RS
or when EMU1/OFF
EXTERNAL INTERFACE CONTROL SIGNALS
Data, program, and I/O space select signals. DS, PS, and IS are always high unless low-level asserted
for communication to a particular external space. They are placed in the high-impedance state during
reset, power down, and when EMU1/OFF
Data ready. READY indicates that an external device is prepared for the bus transaction to be
completed. If the device is not ready (READY is low), the processor waits one cycle and checks
READY again.
Read/write signal. R/W indicates transfer direction during communication to an external device. It is
normally in read mode (high), unless low level is asserted for performing a write operation. It is placed
in the high-impedance state during reset, power down, and when EMU1/OFF
Strobe. STRB is always high unless asserted low to indicate an external bus cycle. It is placed in the
high-impedance state during reset, power down, and when EMU1/OFF
Write enable. The falling edge of WE indicates that the device is driving the external data bus
(D15–D0). Data can be latched by an external device on the rising edge of WE
external program, data, and I/O writes. WE
EMU1/OFF
Write/read. W/R is an inverted form of R/W and can connect directly to the output enable of external
devices. W/R
Terminal Functions
is active low and hold their previous states in power-down
) is asserted,
is active low.
is active low.
is active low.
is active low.
. WE is active on all
goes in the high-impedance state following reset and when
is active low.
is placed in the high-impedance state following reset and when EMU1/OFF is active low.
Bus request. BR is asserted during access of external global data memory space. BR can be
used to extend the data memory address space by up to 32K words. BR
high-impedance state during reset, power down, and when EMU1/OFF
Flash-programming voltage supply. If V
ENTIRE on-chip flash memory block—that is, for programming the flash. If V
WRITE/ERASE of the flash memory is not allowed, thereby protecting the entire memory block
from being overwritten. WDDIS also functions as a hardware watchdog disable. The watchdog
timer is disabled when V
ADC INPUTS (UNSHARED)
p
p
BIT I/O AND SHARED FUNCTIONS PINS
Bidirectional digital I/O.
Analog input to the first ADC.
ADCIN0/IOPA0 is configured as a digital input by all device resets.
Bidirectional digital I/O.
Analog input to the first ADC.
ADCIN1/IOPA1 is configured as a digital input by all device resets.
Bidirectional digital I/O.
Analog input to the second ADC.
ADCIN9/IOPA2 is configured as a digital input by all device resets.
Bidirectional digital I/O.
Analog input to the second ADC.
ADCIN8/IOPA3 is configured as a digital input by all device resets.
Bidirectional digital I/O. Simple compare/PWM 1 output. The state of PWM7/CMP7/IOPB0 is
determined by the simple compare/PWM and the simple action control register (SACTR). It
goes to the high-impedance state when unmasked PDPINT
PWM7/CMP7/IOPB0 is configured as a digital input by all device resets.
Bidirectional digital I/O. Simple compare/PWM 2 output. The state of PWM8/CMP8/IOPB1 is
determined by the simple compare/PWM and the SACTR. It goes to the high-impedance state
when unmasked PDPINT
by all device resets.
Bidirectional digital I/O. Simple compare/PWM 3 output. The state of PWM9/CMP9/IOPB2 is
determined by the simple compare/PWM and SACTR. It goes to the high-impedance state
when unmasked PDPINT
by all device resets.
CCP/WDDIS
.
/WDDIS = 5 V and bit 6 in WDCR is set to 1.
CCP
goes active low. PWM8/CMP8/IOPB1 is configured as a digital input
goes active low. PWM9/CMP9/IOPB2 is configured as a digital input
= 5 V, then WRITE/ERASE can be made to the
CCP
goes in the
is active low.
CCP
goes active low.
= 0 V , then
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
7
TMS320C240, TMS320F240
TYPE
†
DESCRIPTION
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
Terminal Functions (Continued)
TERMINAL
NAMENO.
BIT I/O AND SHARED FUNCTIONS PINS (CONTINUED)
T1PWM/T1CMP/
IOPB3
T2PWM/T2CMP/
IOPB4
T3PWM/T3CMP/
IOPB5
TMRDIR/IOPB6108I/O
TMRCLK/IOPB7109I/O
ADCSOC/IOPC063I/O
CAP1/QEP1/IOPC467I/O
CAP2/QEP2/IOPC568I/O
CAP3/IOPC669I/O
CAP4/IOPC770I/O
XF/IOPC265I/O
BIO/IOPC366I/O
CLKOUT/IOPC164I/O
SCITXD/IO44I/O
SCIRXD/IO43I/O
†
I = input, O = output, Z = high impedance
105I/O/Z
106I/O/Z
107I/O/Z
SERIAL COMMUNICATIONS INTERFACE (SCI) AND BIT I/O PINS
Bidirectional digital I/O. Timer 1 compare output. T1PWM/T1CMP/IOPB3 goes to the highimpedance state when unmasked PDPINT
input by all device resets.
Bidirectional digital I/O. Timer 2 compare output. T2PWM/T2CMP/IOPB4 goes to the highimpedance state when unmasked PDPINT
input by all device resets.
Bidirectional digital I/O. Timer 3 compare output. T3PWM/T3CMP/IOPB5 goes to the highimpedance state when unmasked PDPINT
input by all device resets.
Bidirectional digital I/O. Direction signal for the timers. Up-counting direction if TMRDIR/IOPB6
is low, down-counting direction if this pin is high.
This pin is configured as a digital input by all device resets.
Bidirectional digital I/O.
External clock input for general-purpose timers.
This pin is configured as a digital input by all device resets.
Bidirectional digital I/O.
External start of conversion input for ADC.
This pin is configured as a digital input by all device resets.
Bidirectional digital I/O.
Capture 1 or QEP 1 input.
This pin is configured as a digital input by all device resets.
Bidirectional digital I/O.
Capture 2 or QEP 2 input.
This pin is configured as a digital input by all device resets.
Bidirectional digital I/O.
Capture 3 input.
This pin is configured as a digital input by all device resets.
Bidirectional digital I/O.
Capture 4 input.
This pin is configured as a digital input by all device resets.
Bidirectional digital I/O. External flag output (latched software-programmable signal). XF is
used for signaling other processors in multiprocessing configurations or as a general-purpose
output pin. This pin is configured as an external flag output by all device resets.
Bidirectional digital I/O. Branch control input. BIO is polled by the BIOZ instruction. If BIO is low,
the CPU executes a branch. If BIO
as a branch-control input by all device resets.
Bidirectional digital I/O. Clock output. Clock output is selected by the CLKSRC bits in the
SYSCR register. This pin is configured as a DSP clock output by a power-on reset.
SCI asynchronous serial port transmit data, or general-purpose bidirectional I/O. This pin is
configured as a digital input by all device resets.
SCI asynchronous serial port receive data, or general-purpose bidirectional I/O. This pin is
configured as a digital input by all device resets.
goes active low. This pin is configured as a digital
goes active low. This pin is configured as a digital
goes active low. This pin is configured as a digital
is not used , it should be pulled high. This pin is configured
8
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
TYPE
†
DESCRIPTION
Terminal Functions (Continued)
TERMINAL
NAMENO.
SERIAL PERIPHERAL INTERFACE (SPI) AND BIT I/O PINS
XINT153IExternal user interrupt no. 1
XINT2/IO54I/O
XINT3/IO55I/O
PDPINT52I
XTAL257O
XTAL1/CLKIN58I/Z
OSCBYP56IBypass oscillator if low
†
I = input, O = output, Z = high impedance
94
95
96
97
98
99
O/Z
SPI slave in, master out , or general-purpose bidirectional I/O. This pin is configured as a digital
input by all device resets.
SPI slave out, master in, or general-purpose bidirectional I/O. This pin is configured as a digital
input by all device resets.
SPI clock, or general-purpose bidirectional I/O. This pin is configured as a digital input by all
device resets.
SPI slave transmit enable (optional), or general-purpose bidirectional I/O. This pin is configured
as a digital input by all device resets.
COMPARE SIGNALS
Compare units compare or PWM outputs. The state of these pins is determined by the
compare/PWM and the full action control register (ACTR). CMP1–CMP6 go to the highimpedance state when unmasked PDPINT
INTERRUPT AND MISCELLANEOUS SIGNALS
Reset input. RS causes the TMS320x240 to terminate execution and sets PC = 0. When RS
is brought to a high level, execution begins at location zero of program memory. RS af fects (or
sets to zero) various registers and status bits.
MP/MC (microprocessor/microcomputer) select. If MP/MC is low, internal program memory is
selected. If it is high, external program memory is selected.
Nonmaskable interrupt. When NMI is activated, the device is interrupted regardless of the state
of the INTM bit of the status register. NMI has programmable polarity.
Power-on reset. PORESET causes the TMS320x240 to terminate execution and sets PC = 0.
When PORESET
memory. PORESET
tion, PORESET
External user interrupt no. 2. General-purpose bidirectional I/O. This pin is configured as a
digital input by all device resets.
External user interrupt no. 3. General-purpose bidirectional I/O. This pin is configured as a
digital input by all device resets.
Maskable power-drive protection interrupt. If PDPINT is unmasked and it goes active low, the
timer compare outputs immediately go to the high-impedance state.
PLL oscillator output. XT AL2 is tied to one side of a reference crystal when the device is in PLL
mode (CLKMD[1:0] = 1x, CKCR0.7–6). This pin can be left unconnected in oscillator bypass
mode (OSCBYP
low.
PLL oscillator input. XTAL1/CLKIN is tied to one side of a reference crystal in PLL mode
(CLKMD[1:0] = 1x, CKCR0.7–6), or is connected to an external clock source in oscillator
bypass mode (OSCBYP
is brought to a high level, execution begins at location zero of program
affects (or sets to zero) the same registers and status bits as RS. In addi-
initializes the PLL control registers.
CLOCK SIGNALS
≤ VIL). This pin goes in the high-impedance state when EMU1/OFF is active
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
goes active low, and when reset (RS) is asserted.
≤ VIL).
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
9
TMS320C240, TMS320F240
TYPE
†
DESCRIPTION
V
I
Digital logic ground reference
DV
I
Digital I/O logic suppl
oltage
CV
I
Digital core logic suppl
oltage
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
Terminal Functions (Continued)
TERMINAL
NAMENO.
CV
SS
SS
8IDigital core logic ground reference
3
14
20
29
46
59
61
71
92
104
113
120
SUPPLY SIGNALS
V
SSA
DD
DD
V
CCA
V
REFHI
V
REFLO
TCK30I
TDI31I
TDO34O/Z
TMS33I
†
I = input, O = output, Z = high impedance
87IAnalog ground reference
2
13
21
47
62
93
103
121
7
60
84IAnalog supply voltage
85IADC analog voltage reference high
86IADC analog voltage reference low
pp
y v
pp
y v
TEST SIGNALS
IEEE standard test clock. TCK is normally a free-running clock signal with a 50% duty cycle. The
changes on test-access port (TAP) input signals (TMS and TDI) are clocked into the TAP controller,
instruction register, or selected test data register of the ’C2xx core on the rising edge of TCK. Changes
at the TAP output signal (TDO) occur on the falling edge of TCK.
IEEE standard test data input (TDI). TDI is clocked into the selected register (instruction or data) on
a rising edge of TCK.
IEEE standard test data output (TDO). The contents of the selected register (instruction or data) are
shifted out of TDO on the falling edge of TCK. TDO is in the high-impedance state when OFF
low.
IEEE standard test mode select. This serial control input is clocked into the TAP controller on the rising
edge of TCK.
is active
10
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
TYPE
†
DESCRIPTION
TERMINAL
NAMENO.
TRST32I
EMU038I/O/Z
EMU1/OFF39I/O/Z
RESERVED42I
†
I = input, O = output, Z = high impedance
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
Terminal Functions (Continued)
TEST SIGNALS (CONTINUED)
IEEE standard test reset. TRST, when active low, gives the scan system control of the operations of
the device. If this signal is not connected or driven low, the device operates in its functional mode, and
the test reset signals are ignored.
Emulator pin 0. When TRST is driven low, EMU0 must be high for activation of the /OFF condition.
When TRST
as input/output through the scan.
Emulator pin 1/disable all outputs. When TRST is driven high, EMU1/OFF is used as an interrupt to
or from the emulator system and is defined as input/output through JTAG scan. When TRST
low, this pin is configured as OFF
high-impedance state. OFF
multiprocessing applications); therefore, for OFF
low, EMU0 = high, EMU1/OFF
Reserved for test. This pin has an internal pulldown and must be left unconnected for the ’F240. On
the ’C240, this pin is a no connect.
is driven high, EMU0 is used as an interrupt to or from the emulator system and is defined
is driven
. When EMU1/OFF is active low, it puts all output drivers in the
is used exclusively for testing and emulation purposes (not for
condition, the following conditions apply: TRST =
= low.
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
11
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
functional block diagram
Data Bus
Memory
Control
Interrupts
Initialization
Program Bus
Program
Controller
EEPROM
Instruction
Register
ARAU
Status/
Control
Registers
Auxiliary
Registers
Memory-
Mapped
Registers
†
DARAMROM or Flash
B0
Input
Shifter
ALU
Accumulator
Output
Shifter
DARAM
B1/B2
Multiplier
TREG
PREG
Product
Shifter
’C2xx
CPU
Test/
Emulation
External
Memory
Interface
Software
Wait-State
Generation
Event
Manager
General-
Purpose
Timers
Compare
Units
Capture/
Quadrature
Encoder
Pulse (QEP)
7
41
4
9
4
Clock
3
†
The ’C240 device contains ROM; the ’F240 device contains Flash EEPROM.
Module
Dual 10-Bit
Analog-
to-Digital
Converter
System-Interface
Module
Serial-
Peripheral
Interface
4
Serial-
Communications
Interface
216
4
Interrupts
20
Digital Input/Output
Reset
Watchdog
Timer
PDPINT
Peripheral Bus
12
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
(V)
(ns)
PIN COUNT
description (continued)
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
Table 1. Characteristics of the ’x240 DSP Controllers
The functional block diagram provides a high-level description of each component in the ’x240 DSP controller.
The TMS320x240 devices are composed of three main functional units: a ’C2xx DSP core, internal memory,
and peripherals. In addition to these three functional units, there are several system-level features of the ’x240
that are distributed. These system features include the memory map, device reset, interrupts, digital
input/output (I/O), clock generation, and low-power operation.
system-level functions
device memory map
The TMS320x240 implements three separate address spaces for program memory, data memory, and I /O.
Each space accommodates a total of 64K 16-bit words. Within the 64K words of data space, the 256 to
32K words at the top of the address range can be defined to be external global memory in increments of powers
of two, as specified by the contents of the global memory allocation register (GREG). Access to global memory
is arbitrated using the global memory bus request (BR) signal.
On the ’x240, the first 96 (0–5Fh) data memory locations are either allocated for memory-mapped registers or
are reserved. This memory-mapped register space contains various control and status registers including those
for the CPU.
All the on-chip peripherals of the ’x240 device are mapped into data memory space. Access to these registers
is made by the CPU instructions addressing their data-memory locations. Figure 1 shows the memory map.
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
13
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
device memory map (continued)
Program
Program
Data
Hex
0000
003F
0040
FDFF
FE00
On-Chip DARAM B0
External (CNF = 0)
FEFF
FF00
FFFF
Microprocessor
Hex
0000
FEFF
FF00
FF0E
FF0F
FF10
FFFE
FFFF
Wait-state Generator
Interrupts
(External)
External
(CNF = 1)
or
Reserved
= 1
MP/MC
Mode
I/O
External
Reserved
Flash Control
Mode Register
Reserved
Control Register
Hex
0000
003F
0040
3FFF
4000
FDFF
FE00
FEFF
FF00
FFFF
†
ROM/Flash memory includes
address range 0000h–003Fh
Interrupts
(On-Chip)
On-Chip ROM
(Flash EEPROM)
(8 x 2K Segments)
External
On-Chip DARAM B0
(CNF = 1)
External (CNF = 0)
Reserved
MP/MC = 0
Microcomputer
Mode
†
or
Hex
0000
005F
0060
007F
0080
01FF
0200
02FF
0300
03FF
0400
07FF
0800
6FFF
7000
73FF
7400
743F
7440
77FF
7800
7FFF
8000
FFFF
Memory-Mapped
Registers and
Reserved
On-Chip
DARAM B2
Reserved
On-Chip DARAM B0
(CNF = 0)
or
Reserved (CNF = 1)
On-Chip
DARAM B1
Reserved
Illegal
Peripheral Memory-
Mapped Registers
(System, WD,
ADC, SPI, SCI,
Interrupts, I/O)
Peripheral
Memory-Mapped
Registers
(Event Manager)
Reserved
Illegal
External
14
Figure 1. TMS320x240 Memory Map
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
peripheral memory map
The TMS320x240 system and peripheral control register frame contains all the data, status, and control bits
to operate the system and peripheral modules on the device (excluding the event manager).
Hex
0000
0003
0004
0005
0006
0007
005F
Hex
0000
005F
0060
007F
0080
Memory-Mapped Registers
and Reserved
On-Chip DARAM B2
Reserved
Interrupt-Mask Register
Global-Memory Allocation
Register
Interrupt Flag Register
Emulation Registers
and Reserved
01FF
0200
02FF
0300
03FF
0400
07FF
0800
6FFF
7000
73FF
7400
743F
7440
77FF
7800
7FFF
8000
FFFF
Reserved
On-Chip DARAM
B0 (CNF = 0)
Reserved (CNF = 1)
On-Chip
DARAM B1
Reserved
Illegal
Peripheral Frame 1
Peripheral Frame 2
Reserved
Illegal
External
Illegal
System Configuration and
Control Registers
Watchdog Timer and
PLL Control Registers
ADC
SPI
SCI
Illegal
External-Interrupt Registers
Illegal
Digital-I/O Control Registers
Illegal
General-Purpose
Timer Registers
Reserved
Compare, PWM, and
Deadband Registers
Reserved
Capture & QEP Registers
Reserved
Interrupt Mask, Vector and
Flag Registers
Reserved
7000–700F
7010–701F
7020–702F
7030–703F
7040–704F
7050–705F
7060–706F
7070–707F
7080–708F
7090–709F
70A0–73FF
7400–740C
740D–7410
7411–741C
741D–741F
7420–7426
7427–742B
742C–7434
7435–743F
Figure 2. Peripheral Memory Map
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
15
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
digital I/O and shared pin functions
The ’C240 has a total of 28 pins shared between primary functions and I/Os. These pins are divided into two
groups:
D
Group1 — Primary functions shared with I/Os belonging to dedicated I/O ports, Port A, Port B, and Port C.
D
Group2 — Primary functions belonging to peripheral modules which also have a built-in I/O feature as a
secondary function (for example, SCI, SPI, external interrupts, and PLL clock modules).
description of group1 shared I/O pins
The control structure for Group1 type shared I/O pins is shown in Figure 3. The only exception to this
configuration is the CLKOUT/IOPC1 pin. In Figure 3, each pin has three bits that define its operation:
D
Mux control bit — this bit selects between the primary function (1) and I/O function (0) of the pin.
D
I/O direction bit — if the I/O function is selected for the pin (mux control bit is set to 0), this bit determines
whether the pin is an input (0) or an output (1).
D
I/O data bit — if the I/O function is selected for the pin (mux control bit is set to 0) and the direction selected
is an input, data is read from this bit; if the direction selected is an output, data is written to this bit.
The mux control bit, I/O direction bit, and I/O data bit are in the I/O control registers.
IOP DIR Bit
0 = Input
1 = Output
IOP Data Bit
(Read/Write)
InOut
Figure 3. Shared Pin Configuration
Primary
Function
or I/O Pin
Primary
Function
01
Pin
Note:
When the MUX control bit = 1, the primary
function is selected in all cases except
for the following pins:
Valid only if the I/O function is selected on the pin.
PIN FUNCTION SELECTEDI/O PORT DATA AND DIRECTION
(CRx.n = 1)(CRx.n = 0)REGISTERDATA BIT #DIR BIT #
†
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
17
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
description of group2 shared I/O pins
Group2 shared pins belong to peripherals that have built-in general-purpose I/O capability. Control and
configuration for these pins are achieved by setting the appropriate bits within the control and configuration
registers of the peripherals. Table 3 lists the Group2 shared pins.
Table 4 lists the registers available to the digital I/O module. As with other ’x240 peripherals, the registers are
memory-mapped to the data space.
Table 4. Addresses of Digital I/O Control Registers
ADDRESSREGISTERNAME
7090hOCRAI/O mux control register A
7092hOCRBI/O mux control register B
7098hPADATDIRI/O port A data and direction register
709AhPBDATDIRI/O port B data and direction register
709ChPCDATDIRI/O port C data and direction register
device reset and interrupts
The TMS320x240 software-programmable interrupt structure supports flexible on-chip and external interrupt
configurations to meet real-time interrupt-driven application requirements. The ’x240 recognizes three types of
interrupt sources:
D
Reset (hardware- or software-initiated) is unarbitrated by the CPU and takes immediate priority over any
other executing functions. All maskable interrupts are disabled until the reset service routine enables them.
D
Hardware-generated interrupts are requested by external pins or by on-chip peripherals. There are two
types:
–
External interrupts
are generated by one of five external pins corresponding to the interrupts XINT1,
XINT2, XINT3, PDPINT , and NMI. The first four can be masked both by dedicated enable bits and by t he
CPU’ s interrup t mask regi ster (IMR ), which c an mask ea ch maskab le interr upt line a t the DSP cor e. NMI,
which is not maskable, takes priority over peripheral interrupts and software-generated interrupts. It can
be locked out only by an already executing NMI or a reset.
18
–
Peripheral interrupts
are initiated internally by these on-chip peripheral modules: the event manager,
SPI, SCI, watchdog/real-time interrupt (WD/RTI), and ADC. They can be masked both by enable bits
for each event in each peripheral and by the CPU’s IMR, which can mask each maskable interrupt line at
the DSP core.
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
device reset and interrupts (continued)
D
Software-generated interrupts for the ’x240 device include:
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
The INTR instruction.
–
This instruction allows initialization of any ’x240 interrupt with software. Its
operand indicates to which interrupt vector location the CPU branches. This instruction globally
disables maskable interrupts (sets the INTM bit to 1).
–
The NMI instruction.
This instruction forces a branch to interrupt vector location 24h, the same location
used for the nonmaskable hardware interrupt NMI. NMI can be initiated by driving the NMI pin low or by
executing an NMI instruction. This instruction globally disables maskable interrupts.
–
The TRAP instruction.
TRAP instruction does
This instruction forces the CPU to branch to interrupt vector location 22h. The
not
disable maskable interrupts (INTM is not set to 1); therefore, when the CPU
branches to the interrupt service routine, that routine can be interrupted by the maskable hardware
interrupts.
–
An emulator trap.
This interrupt can be generated with either an INTR instruction or a TRAP instruction.
reset
The reset operation ensures an orderly startup sequence for the device. There are five possible causes of a
reset, as shown in Figure 4. Three of these causes are internally generated; the other two causes, the RS and
PORESET pins, are controlled externally.
To Device
Watchdog Timer Reset
Software-Generated Reset
Illegal Address Reset
Power-On Reset (PORESET
Reset (RS
) Pin Active
) Pin
Active
Reset
Signal
To Reset Out
Figure 4. Reset Signals
The five possible reset signals are generated as follows:
D
Watchdog timer reset. A watchdog-timer-generated reset occurs if the watchdog timer overflows or an
improper value is written to either the watchdog key register or the watchdog control register. (Note that
when the device is powered on, the watchdog timer is automatically active.)
D
Software-generated reset. This is implemented with the system control register (SYSCR). Clearing the
RESET0 bit (bit 14) or setting the RESET1 bit (bit 15) causes a system reset.
D
Illegal address reset. The system and peripheral module control register frame address map contains
unimplemented address locations in the ranges labeled illegal. Any access to an address located in the
Illegal ranges generate an illegal-address reset.
D
Reset pin active. To generate an external reset pulse on the RS pin, a low-level pulse duration of as little
as a few nanoseconds is usually effective; however , pulses of one SYSCLK cycle are necessary to ensure
that the device recognizes the reset signal.
D
Power-on reset pin active. To generate a power-on reset pulse on the PORESET pin, a low-level pulse
of one SYSCLK cycle is necessary to ensure that the device recognizes the reset signal.
Once a reset source is activated, the external RS
pin is driven (active) low for a minimum of eight SYSCLK
cycles. This allows the TMS320x240 device to reset external system components. Additionally , if a brown-out
condition (VCC < VCCmin for several microseconds causing PORESET to go low) occurs or the RS pin is held
low, then the reset logic holds the device in a reset state for as long as these actions are active.
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
19
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
reset (continued)
The occurrence of a reset condition causes the TMS320x240 to terminate program execution and affects
various registers and status bits. During a reset, RAM contents remain unchanged, and all control bits that are
affected by a reset are initialized to their reset state. In the case of a power-on reset, the PLL control registers
are initialized to zero. The program needs to recognize power-on resets and configure the PLL for correct
operation.
After a reset, the program can check the power-on reset flag (PORST flag, SYSSR.15), the illegal address flag
(ILLADR flag, SYSSR.12), the software reset flag (SWRST flag, SYSSR.10), and the watchdog reset flag
(WDRST flag, SYSSR.9) to determine the source of the reset. A reset does not clear these flags.
RS
and PORESET must be held low until the clock signal is valid and VCC is within the operating range. In
addition, PORESET must be driven low when VCC drops below the minimum operating voltage.
hardware-generated interrupts
All the hardware interrupt lines of the DSP core are given a priority rank from 1 to 10 (1 being highest). When
more than one of these hardware interrupts is pending acknowledgment, the interrupt of highest rank gets
acknowledged first. The others are acknowledged in order after that. Of those ten lines, six are for maskable
interrupt lines (INT1–INT6) and one is for the nonmaskable interrupt (NMI) line. INT1–INT6 and NMI have the
priorities shown in Table 5.
Table 5. Interrupt Priorities at the Level of the DSP Core
INTERRUPT
RESET1
TI RESERVED
NMI3
INT14
INT25
INT36
INT47
INT58
INT69
TI RESERVED
†
TI Reserved means that the address space is
reserved for Texas Instruments.
†
†
PRIORITY AT THE
DSP CORE
2
10
The inputs to these lines are controlled by the system module and the event manager as summarized in T able 6
and shown in Figure 5.
Table 6. Interrupt Lines Controlled by the System Module and Event Manager
PERIPHERALINTERRUPT LINES
INT1
System Module
Event Manager
INT5
INT6
INT2
INT3
INT4
NMI
20
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
hardware-generated interrupts (continued)
DSP Core
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
Address
Lines 5–1
5
Address
Lines 5–1
IACK
INT6 INT5 INT4 INT3 INT2 INT1 NMI
NCNCNC
INT6 INT5 INT4 INT3 INT2 INT1 NMIIACK
System ModuleEvent Manager
INTC INTB INTA
Figure 5. DSP Interrupt Structure
At the level of the system module and the event manager, each of the maskable interrupt lines (INT1–INT6) is
connected to multiple maskable interrupt sources. Sources connected to interrupt line INT1 are called Level 1
interrupts; sources connected to interrupt line INT2 are called Level 2 interrupts; and so on. For each interrupt
line, the multiple sources also have a set priority ranking. The source with the highest priority has its interrupt
request responded to by the DSP core first.
Figure 6 shows the sources and priority ranking for the interrupts controlled by the system module. For each
interrupt chain, the interrupt source of highest priority is at the top. Priority decreases from the top of the chain
to the bottom. Figure 7 shows the interrupt sources and priority ranking for the event manager interrupts.
Each of the interrupt sources has its own control register with a flag bit and an enable bit. When an interrupt
request is received, the flag bit in the corresponding control register is set. If the enable bit is also set, a signal
is sent to arbitration logic, which can simultaneously receive similar signals from one or more of the other control
registers. The arbitration logic compares the priority level of competing interrupt requests, and it passes the
interrupt of highest priority to the CPU. The corresponding flag is set in the interrupt flag register (IFR), indicating
that the interrupt is pending. The CPU then must decide whether to acknowledge the request. Maskable
hardware interrupts are acknowledged only after certain conditions are met:
D
Priority is highest. When more than one hardware interrupt is requested at the same time, the ’x240
services them according to the set priority ranking.
D
INTM bit is 0. The interrupt mode (INTM) bit, bit 9 of status register ST0, enables or disables all maskable
interrupts:
–When INTM = 0, all unmasked interrupts are enabled.
–When INTM = 1, all unmasked interrupts are disabled.
INTM is set to 1 automatically when the CPU acknowledges an interrupt (except when initiated by the TRAP
instruction) and at reset. It can be set and cleared by software.
D
IMR mask bit is 1. Each of the maskable interrupt lines has a mask bit in the interrupt mask register (IMR).
To unmask an interrupt line, set its IMR bit to 1.
When the CPU acknowledges a maskable hardware interrupt, it jams the instruction bus with the INTR
instruction. This instruction forces the PC to the appropriate address from which the CPU fetches the software
vector. This vector leads to an interrupt service routine.
Usually, the interrupt service routine reads the peripheral-vector-address offset from the peripheral-vectoraddress register (see Table 7) to branch to code that is meant for the specific interrupt source that initiated the
interrupt request. The ’x240 includes a phantom-interrupt vector offset (0000h), which is a system interrupt
integrity feature that allows a controlled exit from an improper interrupt sequence. If the CPU acknowledges a
request from a peripheral when, in fact, no peripheral has requested an interrupt, the phantom-interrupt vector
is read from the interrupt-vector register.
Table 7 summarizes the interrupt sources, overall priority, vector address/offset, source, and function of each
interrupt available on the TMS320x240.
XINT3
RESERVED41000EhN/AYDSP CoreUsed for analysis
TRAPN/A0022hN/AN/ATRAP instruction vector
OVERALL
PRIORITY
38
40
DSP-CORE
INTERRUPT,
AND
ADDRESS
000Ah
(System)
000Ch
(System)
PERIPHERAL
VECTOR
ADDRESS
(701Eh)
PERIPHERAL
VECTOR
ADDRESS
OFFSET
0005hYSPILow-priority SPI interrupt
0006hYSCI
0007hYSCI
0001h
001Fh
MASKABLE?
Y
Y
’x240
SOURCE
PERIPHERAL
MODULE
ExternalLow-priority external
pins
FUNCTION
INTERRUPT
SCI receiver interrupt
(low priority)
SCI transmitter interrupt
(low priority)
user interrupts
external interrupts
The ’x240 has five external interrupts. These interrupts include:
D
XINT1. Type A interrupt. The XINT1 control register (at 7070h) provides control and status for this interrupt.
XINT1 can be used as a high-priority (Level 1) or low-priority (Level 6) maskable interrupt or as a
general-purpose input pin. XINT1 can also be programmed to trigger an interrupt on either the rising or the
falling edge.
D
NMI. T ype A inter rupt. The NMI control register (at 7072h) provides control and status for this interrupt. NMI
is a nonmaskable external interrupt or a general-purpose input pin. NMI can also be programmed to trigger
an interrupt on either the rising or the falling edge.
D
XINT2. Type C interrupt. The XINT2 control register (at 7078h) provides control and status for this interrupt.
XINT2 can be used as a high-priority (Level 1) or low-priority (Level 6) maskable interrupt or a
general-purpose I/O pin. XINT2 can also be programmed to trigger an interrupt on either the rising or the
falling edge.
D
XINT3. Type C interrupt. The XINT3 control register (at 707Ah) provides control and status for this interrupt.
XINT3 can be used as a high-priority (Level 1) or low-priority (Level 6) maskable interrupt or as a
general-purpose I/O pin. XINT3 can also be programmed to trigger an interrupt on either the rising or the
falling edge.
D
PDPINT. This interrupt is provided for safe operation of the power converter and motor drive. This maskable
interrupt can put the timers and PWM output pins in the high-impedance state and inform the CPU in case
of motor drive abnormalities such as overvoltage, overcurrent, and excessive temperature rise. PDP IN T is
a Level 2 interrupt.
26
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
external interrupts (continued)
Table 8 is a summary of the external interrupt capability of the ’x240.
Table 8. External Interrupt Types and Functions
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
EXTERNAL
INTERRUPT
XINT1XINT1CR7070hANoInput only
NMINMICR7072hAYesInput onlyNo
XINT2XINT2CR7078hCNoI/O
XINT3XINT3CR707AhCNoI/O
PDPINTEVIMRA742ChN/AN/AN/A
CONTROL
REGISTER
NAME
CONTROL
REGISTER
ADDRESS
INTERRUPT
TYPE
CAN DO
NMI?
DIGITAL
I/O PIN
MASKABLE?
(Level 1 or 6)
(Level 1 or 6)
(Level 1 or 6)
clock generation
The TMS320x240 has an on-chip, PLL-based clock module. This module provides all the necessary clocking
signals for the device, as well as control for low-power mode entry . The only external component necessary for
this module is an external fundamental crystal, or oscillator.
The PLL-based clock module provides two basic modes of operation: oscillator mode and clock-in mode.
D
oscillator mode
This mode allows the use of a 4-, 6-, or 8-MHz external reference crystal to provide the time base to the
device. The internal oscillator circuitry is initialized by software to select the desired CPUCLK frequency,
which can be the input clock frequency , the input clock frequency divided by 2 (default), or a clock frequency
determined by the PLL.
Yes
Yes
Yes
Yes
(Level 2)
D
Clock-in mode
This mode allows the internal crystal oscillator circuitry to be bypassed. The device clocks are generated
from an external clock source input on the XTAL1/CLKIN pin. The device can be configured by software
to operate on the input clock frequency, the input clock frequency divided by 2, or a clock frequency
determined by the PLL.
The ’x240 runs on two clock frequencies: the CPU clock (CPUCLK) frequency , and the system clock (SYSCLK)
frequency . The CPU, memories, external memory interface, and event manager run at the CPUCLK frequency .
All other peripherals run at the SYSCLK frequency . The CPUCLK runs at 2x or 4x the frequency of the SYSCLK;
for example, for 2x, CPUCLK = 20 MHz and SYSCLK = 10 MHz. There is also a clock for the watchdog timer,
WDCLK. This clock has a nominal frequency of 16384 Hz (214 Hz) when XTAL1/CLKIN is a power of two or
a sum of two powers of two; for example, 4194304 Hz (222 Hz), 6291456 (222 + 221 Hz), or 8388608 Hz
(223 Hz).
The clock module includes three external pins:
1. XTAL1/CLKINclock source/crystal input
2. XTAL2output to crystal
3. OSCBYPoscillator bypass
For the external pins, if OSCBYP ≥ VIH, then the oscillator is enabled and if OSCBYP ≤ VIL, then the oscillator
is bypassed and the device is in clock-in mode. In clock-in mode, an external TTL clock must be applied to the
XTAL1/CLKIN pin. The XTAL2 pin can be left unconnected.
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
27
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
clock generation (continued)
OSCBYP
XTAL1/CLKIN
XTAL
OSC
XTAL2
Clock Frequency and PLL Multiply Bits (CKCR1.7–4)
PLL
Div 2
Div 2
PLL divide-by-2 bit
(CKCR1.3)
MUXMUX
Phase
Detector
Feedback
Divider
Div 1, 2, 3, 4, 5,
or 9
VCO
Synchronizing
Clock Switch
Clock Mode Bits
(CKCR0.7–6)
PLL multiply ratio
(CKCR1.2–0)
CPUCLK
1-MHz Clock Prescaler
Prescale Bit (CKCR0.0)
SYSCLK Prescaler Div 2 or 4
Figure 8. PLL Clock Module Block Diagram
Watchdog Clock Prescaler
ACLK
WDCLK
SYSCLK
28
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
low-power modes
The TMS320x240 has four low-power modes (idle 1, idle 2, PLL power down, and oscillator power down). The
low-power modes reduce the operating power by reducing or stopping the activity of various modules (by
stopping their clocks). The two PLLPM bits of the clock module control register, CKCR0, select which of the
low-power modes the device enters when executing an IDLE instruction. Reset or an unmasked interrupt from
any source causes the device to exit from idle 1 low-power mode. A real-time interrupt from the watchdog timer
module causes the device to exit from all low-power modes except oscillator power down. This is a wake-up
interrupt. When enabled, reset or any of the four external interrupts (NMI, XINT1, XINT2, or XINT3) causes the
device to exit from any of the low-power modes (idle 1, idle 2, PLL power down, and oscillator power down).
The external interrupts are all wake-up interrupts. The maskable external interrupts (XINT1, XINT2, and XINT3)
must be enabled individually and globally to bring the device out of a low-power mode properly . It is, therefore,
important to ensure that the desired low-power-mode exit path is enabled before entering a low-power mode.
Figure 9 shows the wake-up sequence from a power down. Table 9 summarizes the low-power modes.
Watchdog Timer
and
Real-Time Interrupt
Module
Wake-up
Signal
Wake-up Signal
to CPU
NMI
XINT1
XINT2
XINT3
External-Interrupt Logic
Reset
Signal
Reset Logic
System Module
Figure 9. Waking Up the Device From Power Down
Table 9. Low-Power Modes
LOW-
POWER
MODE
RunXXOnOnOnOnOn–80 mA
Idle 100OffOnOnOnOn
Idle 201OffOffOnOnOn
PLL Power
Down
OSC Power
Down
PLLPM(x)
BITS IN
CKCR0[2:3]
10OffOffOnOffOn
11OffOffOffOffOff
CPUCLK
STATUS
SYSCLK
STATUS
WDCLK
STATUS
PLL
STATUS
OSC
STATUS
EXIT
CONDITION
Any interrupt
or reset
Wake-up
interrupt or
reset
Wake-up
interrupt or
reset
Wake-up
interrupt or
reset
TYPICAL
POWER
50 mA
7 mA
1 mA
400 mA
POST OFFICE BOX 1443 • HOUSTON, TEXAS 77251–1443
29
TMS320C240, TMS320F240
DSP CONTROLLERS
SPRS042D – OCTOBER 1996 – REVISED NOVEMBER 1998
functional block diagram of the TMS320x240 DSP CPU