Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications,
enhancements, improvements, and other changes to its products and services at any time and to discontinue
any product or service without notice. Customers should obtain the latest relevant information before placing
orders and should verify that such information is current and complete. All products are sold subject to TI’s terms
and conditions of sale supplied at the time of order acknowledgment.
TI warrants performance of its hardware products to the specifications applicable at the time of sale in
accordance with TI’s standard warranty. Testing and other quality control techniques are used to the extent TI
deems necessary to support this warranty . Except where mandated by government requirements, testing of all
parameters of each product is not necessarily performed.
TI assumes no liability for applications assistance or customer product design. Customers are responsible for
their products and applications using TI components. To minimize the risks associated with customer products
and applications, customers should provide adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right,
copyright, mask work right, or other TI intellectual property right relating to any combination, machine, or process
in which TI products or services are used. Information published by TI regarding third-party products or services
does not constitute a license from TI to use such products or services or a warranty or endorsement thereof.
Use of such information may require a license from a third party under the patents or other intellectual property
of the third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of information in TI data books or data sheets is permissible only if reproduction is without
alteration and is accompanied by all associated warranties, conditions, limitations, and notices. Reproduction
of this information with alteration is an unfair and deceptive business practice. TI is not responsible or liable for
such altered documentation.
Resale of TI products or services with statements different from or beyond the parameters stated by TI for that
product or service voids all express and any implied warranties for the associated TI product or service and
is an unfair and deceptive business practice. TI is not responsible or liable for any such statements.
Following are URLs where you can obtain information on other Texas Instruments products and application
solutions:
ProductsApplications
Amplifiersamplifier.ti.comAudiowww.ti.com/audio
Data Convertersdataconverter.ti.comAutomotivewww.ti.com/automotive
DSPdsp.ti.comBroadbandwww.ti.com/broadband
Interfaceinterface.ti.comDigital Controlwww.ti.com/digitalcontrol
Logiclogic.ti.comMilitarywww.ti.com/military
Power Mgmtpower.ti.comOptical Networkingwww.ti.com/opticalnetwork
Microcontrollersmicrocontroller.ti.comSecuritywww.ti.com/security
Telephonywww.ti.com/telephony
Video & Imagingwww.ti.com/video
Wirelesswww.ti.com/wireless
Mailing Address:Texas Instruments
Post Office Box 655303 Dallas, Texas 75265
Copyright 2004, Texas Instruments Incorporated
Page 3
Preface
Read This First
About This Manual
This manual describes the central processing unit (CPU) and the assembly language instructions of the
TMS320C28x 32-bit fixed-point digital signal processors (DSPs). It also describes emulation features
available on these DSPs. A summary of the chapters and appendixes follows:
Chapter 1Architectural Overview
This chapter introduces the T320C2800 DSP core that is at the heart of each
TMS320C28x DSP. The chapter includes a memory map and a high-level description of the memory interface that connects the core with memory and
peripheral devices.
Chapter 2Central Processing Unit
This chapter describes the architecture, registers, and primary functions of
the CPU. The chapter includes detailed descriptions of the flag and control
bits in the most important CPU registers, status registers ST0 and ST1.
Chapter 3Interrupts and Reset
This chapter describes the interrupts and how they are handled by the CPU.
The chapter also explains the effects of a reset on the CPU and includes discussion of the automatic context save performed by the CPU prior to servicing an interrupt.
Chapter 4Pipeline
This chapter describes the phases and operation of the instruction pipeline.
The chapter is primarily for readers interested in increasing the efficiency of
their programs by preventing pipeline delays.
Chapter 5Addressing Modes
This chapter explains the modes by which the assembly language instructions accept data and access register and memory locations. The chapter includes a description of how addressing-mode information is encoded in opcodes.
Chapter 6Assembly Language Instructions
This chapter provides summaries of the instruction set and detailed descriptions (including examples) for the instructions. The chapter includes an explanation of how 32-bit accesses are aligned to even addresses.
iiiRead This First
Page 4
Notational Conventions
About This Manual / Notational Conventions
Chapter 7Emulation Features
This chapter describes the TMS320C28x emulation features that can be
used with only a JTAG port and two additional emulation pins.
Appendix ARegister Quick Reference
This appendix is a concise central resource for information about the status
and control registers of the CPU. The chapter includes figures that summarize the bit fields of the registers.
Appendix BSubmitting ROM Codes to TI
This appendix describes the procedures for getting code-customized ROM
in a Texas Instruments (TI) DSP.
Appendix CC2xLP and C28x Architectural Differences
This appendix describes the differences in the architecture of the C2xLP and
the C28x.
Appendix DMigration From C2xLP
This appendix explains how to migrate code from the C2xLP to the C28x.
Appendix EC2xLP Instruction Set Compatibility
This appendix describes the instruction set compatibility with the C2xLP.
Appendix FMigration From C27x to C28x
This appendix explains how to migrate code from the C27x to the C28x.
Appendix GGlossary
This appendix explains abbreviations, acronyms, and special terminology
used throughout this document.
Notational Conventions
This document uses the following conventions:
- The device number TMS320C28x is very often abbreviated as ’28x.
- Program examples are shown in a special typeface. Here is a sam-
ple line of program code:
PUSH IER
- Portions of an instruction syntax that are in bold should be entered as
shown; portions of a syntax that are in italics are variables indicating information that should be entered. Here is an example of an instruction
syntax:
MOV ARx, *−SP[6bit]
MOV is the instruction mnemonic. This instruction has two operands, indicated by ARx and *−SP[6bit]. Where the variable x appears, you type a
iv
Page 5
Notational Conventions
value from 0 to 5; where the 6bit appears, you type a 6-bit constant. The
rest of the instruction, including the square brackets, must be entered as
shown.
- When braces or brackets enclose an operand, as in {operand}, the oper-
and is optional. If you use an optional operand, you specify the information
within the braces; you do not enter the braces themselves. In the following
syntax, the operand << shift is optional:
MOV ACC, *−SP[6bit] {<<shift}
MOV ACC, *−SP{6bit} {<<shift}
For example, you could use either of the following instructions:
MOV ACC, *−SP[5]
MOV ACC, *−SP[5]<< 4
- In most cases, hexadecimal numbers are shown with a subscript of 16. For
example, the hexadecimal number 40 would be shown as 40
. An excep-
16
tion to this rule is a hexadecimal number in a code example; these hexadecimal numbers have the suffix h. For example, the number 40 in the following code is a hexadecimal 40.
MOVB AR0,#40h
Similarly, binary numbers usually are shown with a subscript of 2. For example, the binary number 4 would be shown as 0100
. Binary numbers in
2
example code have the suffix b. For example, the following code uses a
binary 4.
MOVB AR0,#0100b
- Bus signals and bits are sometimes represented with the following nota-
tions:
NotationDescriptionExample
Bus(n:m)Signals n through m of busPRDB(31:0) represents the 32
signals of the program-read data
bus (PRDB).
Register(n:m)Bits n through m of registerT(3:0) represents the 4 least sig-
nificant bits of the T register.
Register(n)
Bit n of registerIER(4) represents bit 4 of the in-
terrupt enable register (IER).
vRead This First
Page 6
Related Documentation From Texas Instruments
Notational Conventions / Related Documentation From Texas Instruments
Concatenated values are represented with the following notation:
-
NotationDescriptionExample
x:yx concatenated with yAR1:AR0 is the concatenation of
- If a signal is from an active-low pin, the name of the signal is qualified with
an overbar (for example, INT1
). If a signal is from an active-high pin or from
hardware inside the the DSP (in which case, the polarity is irrelevant), the
name of the signal is left unqualified (for example, DLOGINT).
Related Documentation From Texas Instruments
The following books describe the TMS320C28x DSP and related support
tools. The documents are available for downloading on the Texas Instruments
website (www.ti.com).
TMS320C2xx User’s Guide (literature number SPRU127) discusses the
hardware aspects of the TMS320C2xx 16-bit fixed-point digital signal
processors. It describes the architecture, the instruction set, and the onchip peripherals.
TMS320C28x Assembly Language Tools User’s Guide (literature number
SPRU513) describes the assembly language tools (assembler and other
tools used to develop assembly language code), assembler directives,
macros, common object file format, and symbolic debugging directives
for the TMS320C28x device.
the 16-bit registers AR1 and
AR0. AR0 is the low word. AR1
is the high word.
vi
TMS320C28x Optimizing C Compiler User’s Guide (literature number
SPRU514) describes the TMS320C28x C/C++ compiler. This compiler
accepts ANSI standard C/C++ source code and produces TMS320
DSP assembly language source code for the TMS320C28x device.
TMS320C2811, and TMS320C2812 Digital Signal Processors
(literature number SPRS174) data sheet contains the electrical and
timing specifications for these devices, as well as signal descriptions and
pinouts for all of the available packages.
TMS320F2801, TMS320F2806, TMS320F2808 Digital Signal Processors
(literature number SPRS230) data sheet contains the pinout, signal descriptions, as well as electrical and timing specifications for the F280x
devices.
Page 7
Related Documentation From Texas Instruments
TMS320C2800 Digital Signal Processor (literature number SPRS178) data
sheet contains the block diagram, component descriptions, timing
information, and electrical specifications for the TMP320C2800 DSP.
ture number SPRU060) describes the ADC module. The module is a
12−bit pipelined ADC. The analog circuits of this converter, referred to
as the core in this document, include the front-end analog multiplexers
(MUXs), sample−and−hold (S/H) circuits, the conversion core, voltage
regulators, and other analog supporting circuits. Digital circuits, referred
to as the wrapper in this document, include programmable conversion
sequencer, result registers, interface to analog circuits, interface to device peripheral bus, and interface to other on-chip modules.
TMS320C28x Boot ROM Reference Guide (literature number SPRU095)
describes the purpose and features of the bootloader (factory-programmed boot-loading software). It also describes other contents of the
device on-chip boot ROM and identifies where all of the information is located within that memory.
TMS320C28x Enhanced Controller Area Network (eCAN) Reference
Guide (literature number SPRU074) describes the eCAN that uses es-
tablished protocol to communicate serially with other controllers in electrically noisy environments. With 32 fully configurable mailboxes and
time-stamping feature, the eCAN module provides a versatile and robust
serial communication interface. The eCAN module implemented in the
C28x DSP is compatible with the CAN 2.0B standard (active).
TMS320C28x Event Manager (EV) Reference Guide (literature number
SPRU065) describes the EV modules that provide a broad range of functions and features that are particularly useful in motion control and motor
control applications. The EV modules include general-purpose (GP) timers, full-compare/PWM units, capture units, and quadrature-encoder
pulse (QEP) circuits.
ber SPRU067) describes the various interrupts and system control features of the 28x digital signal processors (DSPs).
TMS320C28x Multi-channel Buffered Serial Ports (McBSPs) Reference
Guide (literature number SPRU061) describes the McBSP) available on
the C28x devices. The McBSPs allow direct interface between a DSP
and other devices in a system.
TMS320C28x Peripheral Reference Guide (literature number SPRU566)
describes the peripheral reference guides of the 28x digital signal processors (DSPs).
viiRead This First
Page 8
Trademarks
TMS320C28x Serial Communication Interface (SCI) Reference Guide (lit-
erature number SPRU051) describes the SCI that is a two-wire asynchronous serial port, commonly known as a UART. The SCI modules
support digital communications between the CPU and other asynchronous peripherals that use the standard non-return-to-zero (NRZ) format.
TMS320C28x Serial Peripheral Interface (SPI) Reference Guide (literature
number SPRU059) describes the SPI − a high-speed synchronous serial
input/output (I/O) port that allows a serial bit stream of programmed
length (one to sixteen bits) to be shifted into and out of the device at a
programmed bit−transfer rate. The SPI is used for communications be-
tween the DSP controller and external peripherals or another controller.
TMS320C28x System Control and Interrupts Reference Guide (literature
number SPRU078) describes the various interrupts and system control
features of the 28x digital signal processors (DSPs).
Trademarks
320 Hotline On-line is a trademark of Texas Instruments Incorporated.
HP-UX is a trademark of Hewlett-Packard Company.
IBM and PC are trademarks of International Business Machines Corporation.
Intel is a trademark of Intel Corporation.
MS-DOS is a registered trademark of Microsoft Corporation.
is a registered trademark of Advanced Micro Devices, Inc.
PAL
SunOS is a trademark of Sun Microsystems, Inc.
C2xLP, C27x, C28x, TMS320C28x, and XDS510 are trademarks of Texas Instruments Incorporated.
7−1.Initialization Code for Data Logging With Word Counter7-28. . . . . . . . . . . . . . . . . . . . . . . . . . .
7−2.Initialization Code for Data Logging With End Address7-29. . . . . . . . . . . . . . . . . . . . . . . . . . . .
xviii
Page 19
Chapter 1
Architectural Overview
The TMS320C28xt is one of several fixed-point generations of digital signal
processors (DSPs) in the TMS320 family. The C28xt is source-code and object-code compatible with the C27xt. In addition, much of the code written for
the C2xLP CPU can be reassembled to run on a C28x device.
The C2xLP CPU is used in all TMS320F24xx and TMS320C20x DSPs and
their derivatives. This document refers to C2xLP as a generic name for the
DSP CPU used in these devices.
This chapter provides an overview of the architectural structure and components of the C28x CPU.
The CPU is a low-cost 32-bit fixed-point digital signal processor (DSP). This
device draws from the best features of digital signal processing; reduced
instruction set computing (RISC); and microcontroller architectures, firmware,
and tool sets. The DSP features include a modified Harvard architecture and
circular addressing. The RISC features are single-cycle instruction execution,
register-to-register operations, and modified Harvard architecture (usable in
Von Neumann mode). The microcontroller features include ease of use
through an intuitive instruction set, byte packing and unpacking, and bit manipulation.
The modified Harvard architecture of the CPU enables instruction and data
fetches to be performed in parallel. The CPU can read instructions and data
while it writes data simultaneously to maintain the single-cycle instruction operation across the pipeline. The CPU does this over six separate address/data
buses.
1.1.1Compatibility With Other TMS320 CPUs
The C28x DSP features compatibility modes that minimize the migration effort
from the C27x and C2xLP CPUs. The operating mode of the device is
determined by a combination of the OBJMODE and AMODE bits in status
register 1 (ST1) as shown in Table 1−1. The OBJMODE bit allows you to select
between code compiled for a C28x (OBJMODE == 1) and code compiled for
a C27x (OBJMODE == 0). The AMODE bit allows you to select between
C28x/C27x instruction addressing modes (AMODE == 0) and C2xLP
compatible instruction addressing modes (AMODE == 1).
Table 1−1. Compatibility Modes
C28x Mode10
C2xLP Source-compatible Mode11
C27x Object-compatible Mode
†
The C28x is in C27x-compatible mode at reset.
- C28x Mode: In C28x mode, you can take advantage of all the C28x native
features, addressing modes, and instructions. To operate in C28x mode
from reset, your code must first set the OBJMODE bit by using the
”C28OBJ” (or ”SETC OBJMODE”) instruction. This book assumes you are
operating in C28x mode unless stated otherwise.
lows you to run C2xLP source code which has been reassembled using
1-2
OBJMODEAMODE
†
00
Page 21
the C28x code-generation tools. For more information on operating in this
mode and migration from a C2xLP CPU, see Appendices C, D, and E.
- C27x Object-Compatible Mode: At reset, the C28x CPU operates in C27x
object-compatible mode. In this mode, the C28x is 100% object-code and
cycle-count compatible with the C27x CPU. For detailed information on
operating in C27x object-compatible mode and migrating from the C27x,
see Appendix F.
1.1.2Switching to C28x Mode From Reset
At reset, the C28x CPU is in C27x Object-Compatible Mode (OBJMODE ==
0, AMODE == 0) and is 100% compatible with the C27x CPU. To take advantage of the enhanced C28x instruction set, you must instead operate the device in C28x mode. To do this, after a reset your code must first set the OBJMODE bit in ST1 by using the ”C28OBJ” (or ”SETC OBJMODE”) instruction.
Introduction to the CPU
1-3Architectural Overview
Page 22
Components of the CPU
1.2Components of the CPU
As shown in Figure 1−1, the CPU contains:
- A CPU for generating data- and program-memory addresses; decoding
and executing instructions; performing arithmetic, logical, and shift operations; and controlling data transfers among CPU registers, data memory,
and program memory
- Emulation logic for monitoring and controlling various parts and functiona-
lities of the DSP and for testing device operation
- Signals for interfacing with memory and peripherals, clocking and control-
ling the CPU and the emulation logic, showing the status of the CPU and
the emulation logic, and using interrupts
The CPU does not contain memory, a clock generator, or peripheral devices.
For information about interfacing to these items, see the C28x PeripheralUser’s Guide (literature number SPRU566) and the data sheet that corresponds to your DSP.
Figure 1−1. High-Level Conceptual Diagram of the CPU
1.2.1Central Processing Unit (CPU)
The CPU is discussed in more detail in Chapter 2, but following is a list of its
major features:
- Protected pipeline. The CPU implements an 8-phase pipeline that pre-
vents a write to and a read from the same location from occurring out of
order.
- Independent register space. The CPU contains registers that are not
mapped to data space. These registers function as system-control
C28x CPU
Memory-interface signals
CPU
Clock and control signals
Reset and interrupt signals
Emulation
logic
Emulation signals
1-4
Page 23
- Arithmetic logic unit (ALU). The 32-bit ALU performs 2s-complement arith-
- Address register arithmetic unit (ARAU). The ARAU generates data-
- Barrel shifter. This shifter performs all left and right shifts of data. It can shift
- Multiplier. The multiplier performs 32-bit × 32-bit 2s-complement multi-
1.2.2Emulation Logic
Components of the CPU
registers, math registers, and data pointers. The system-control registers
are accessed by special instructions. The other registers are accessed by
special instructions or by a special addressing mode (register addressing
mode).
metic and Boolean logic operations.
memory addresses and increments or decrements pointers in parallel with
ALU operations.
data to the left by up to 16 bits and to the right by up to 16 bits.
plication with a 64-bit result. The multiplication can be performed with two
signed numbers, two unsigned numbers, or one signed number and one
unsigned number.
The emulation logic includes the following features. For more details about
these features, see Chapter 7, Emulation Features.
- Debug-and-test direct memory access (DT-DMA). A debug host can gain
direct access to the content of registers and memory by taking control of
the memory interface during unused cycles of the instruction pipeline.
- Data logging. The emulation logic enables application-initiated transfers
of memory contents between the C28x and a debug host.
- A counter for performance benchmarking
- Multiple debug events. Any of the following debug events can cause a
break in program execution:
J A breakpoint initiated by the ESTOP0 or ESTOP1 instruction
J An access to a specified program-space or data-space location
J A request from the debug host or other hardware
When a debug event causes the C28x to enter the debug-halt state, the
event is called a break event.
- Real-time mode of operation. When the C28x is in this mode and a break
event occurs, the main body of program code comes to a halt, but time-critical interrupts can still be serviced.
1-5Architectural Overview
Page 24
Components of the CPU
1.2.3Signals
The CPU has four main types of signals:
- Memory-interface signals. These signals transfer data among the CPU,
memory, and peripherals; indicate program-memory accesses and datamemory accesses; and differentiate between accesses of different sizes
(16-bit or 32-bit).
- Clock and control signals. These provide clocking for the CPU and the
emulation logic, and they are used to control and monitor the CPU.
- Reset and interrupt signals. These are used for generating a hardware re-
set and interrupts, and for monitoring the status of interrupts.
- Emulation signals. These signals are used for testing and debugging.
1-6
Page 25
1.3Memory Map
The CPU contains no memory, but can access memory elsewhere on the C28x
DSP or outside the DSP.
The C28x uses 32-bit data addresses and 22-bit program addresses. This allows for a total address reach of 4G words (1 word = 16 bits) in data space and
4M words in program space. Memory blocks on all C28x designs are uniformly
mapped to both program and data space. Figure 1−2 shows a high-level view
of how addresses are allocated in program space and data space.
The memory map in Figure 1−2 has been divided into the following segments:
- On-chip program/data
- Reserved
- CPU interrupt vectors
For specific details about each of the map segments, see the data sheet for
your DSP. See Appendix D for more information on the C2xLP compatible
memory space.
1.3.1On-Chip Program/Data
All C28x-based CPU devices contain two blocks of single access on-chip
memory referred to as M0 and M1. Each of these blocks is 1K words in size.
M0 is mapped at addresses 00 0000
dresses 00 0400
vices, M0 and M1 are mapped to both program and data space. Therefore, you
can use M0 and M1 to execute code or for data variables. At reset, the stack
pointer is set to the top of block M1.
Memory Map
− 00 03FF16 and M1 is mapped at ad-
16
− 00 07FF16. Like all other memory blocks on the C28x de-
16
Depending on the device, it may also have additional random-access memory
(RAM), read-only memory (ROM), or flash memory.
1.3.2Reserved
Addresses 0000 0800−0000 09FF in data space are reserved for CPU Emulation Registers on all C28x designs.
1.3.3CPU Interrupt Vectors
Sixty-four addresses in program space are set aside for a table of 32 CPU interrupt vectors. The CPU vectors can be mapped to the top or bottom of program space by way of the VMAP bit. For more information about the CPU vectors, see Section 3.2, Interrupt Vectors and Priorities on page 3-4.
For devices with a peripheral interrupt expansion (PIE) block, the interrupt vectors will reside in the PIE vector table and this memory can be used as program
memory.
1-7Architectural Overview
Page 26
Memory Map
Figure 1−2. TMS320C28x High-Level Memory Map
High 64K
C2xLP
Compatible
Program
Space
0000
3FF
400
7FF
3F 0000
Program
Vectors in RAM M0
(VMAP = 0)
Block M0 1 K × 16
Block M1 1 K × 16
Reserved
Memory or
Peripherals
Data
Vectors in RAM M0
(VMAP = 0)
Block M0 1 K × 16
Block M1 1 K × 16
Reserved
Memory or
Peripherals
<−SP
(Reset)
800
9FF
1000
A000
Low 64K
C2xLP
Compatible
Data Space
1-8
3F FFFF
Vectors (VMAP = 1)
FFFF FFFF
See the data sheet for your specific device for details of the exact memory
map.
Page 27
1.4Memory Interface
The C28x memory map is accessible outside the CPU by the memory interface, which connects the CPU logic to memories, peripherals, or other interfaces. The memory interface includes separate buses for program space and
data space. This means an instruction can be fetched from program memory
while data memory is being accessed.
The interface also includes signals that indicate the type of read or write being
requested by the CPU. These signals can select a specified memory block or
peripheral for a given bus transaction. In addition to 16-bit and 32-bit accesses, the C28x supports special byte-access instructions which can access
the least significant byte (LSByte) or most significant byte (MSByte) of an addressed word. Strobe signals indicate when such an access is occurring on
a data bus.
1.4.1Address and Data Buses
The memory interface has three address buses:
PABProgram address bus. The PAB carries addresses for reads and
writes from program space. PAB is a 22-bit bus.
Memory Interface
DRABData-read address bus. The 32-bit DRAB carries addresses for
reads from data space.
DWAB Data-write address bus. The 32-bit DWAB carries addresses for
writes to data space.
The memory interface also has three data buses:
PRDBProgram-read data bus. The PRDB carries instructions or data dur-
ing reads from program space. PRDB is a 32-bit bus.
DRDBData-read data bus. The DRDB carries data during reads from data
space. PRDB is a 32-bit bus.
DWDB Data-/Program-write data bus. The 32-bit DWDB carries data during
writes to data space or program space.
1-9Architectural Overview
Page 28
Memory Interface
Table 1−2 summarizes how these buses are used during accesses.
Table 1−2. Summary of Bus Use During Data-Space and Program-Space Accesses
Access Type
Read from program spacePAB
Read from data space
Write to program spacePABDWDB
Write to data space
A program-space read and a program-space write cannot happen simultaneously because both use the PAB. Similarly, a program-space write and a
data-space write cannot happen simultaneously because both use the DWDB.
Transactions that use different buses can happen simultaneously. For example, the CPU can read from program space (using PAB and PRDB), read from
data space (using DRAB and DRDB), and write to data space (using DWAB
and DWDB) at the same time.
1.4.2Special Bus Operations
Typically, PAB and PRDB are used only for reading instructions from program
space, and DWDB is used only for writing data to data space. However, the
instructions in Table 1−3 are exceptions to this behavior. For more details
about using these instructions, see Chapter 6, Assembly Language Instruc-tions.
Address Bus
DRAB
DWABDWDB
Data Bus
PRDB
DRDB
1-10
Page 29
Table 1−3. Special Bus Operations
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Memory Interface
Instruction
PREAD
ÁÁ
ÁÁ
ÁÁ
ÁÁ
PWRITE
ÁÁ
ÁÁ
ÁÁ
ÁÁ
MAC
ÁÁ
DMAC
ÁÁ
QMACL
IMACL
ÁÁ
XMAC
ÁÁ
XMACD
ÁÁ
Special Bus Operation
This instruction reads a data value rather than an instruction from pro-
ББББББББББББББББББ
gram space. It then transfers that value to data space or a register.
ББББББББББББББББББ
For the read from program space, the CPU places the source address
on the program address bus (PAB), sets the appropriate program-
ББББББББББББББББББ
space select signals, and reads the data value from the program-read
ББББББББББББББББББ
data bus (PRDB).
This instruction writes a data value to program space. The value is
ББББББББББББББББББ
read from from data space or a register.
ББББББББББББББББББ
For the write to program space, the CPU places the destination address on the program address bus (PAB), sets the appropriate pro-
ББББББББББББББББББ
gram-space select signals, and writes the data value to the data-/pro-
ББББББББББББББББББ
gram-write data bus (DWDB).
As part of their operation, these instructions multiply two data values,
ББББББББББББББББББ
one of which is read from program space.
ББББББББББББББББББ
For the read from program space, the CPU places the program-space
ББББББББББББББББББ
source address on the program address bus (PAB), sets the appropriate program-space select signals, and reads the program data value
ББББББББББББББББББ
from the program read data bus (PRDB).
ББББББББББББББББББ
1.4.3Alignment of 32-Bit Accesses to Even Addresses
The C28x CPU expects memory wrappers or peripheral-interface logic to align
any 32-bit read or write to an even address. If the address-generation logic
generates an odd address, the CPU must begin reading or writing at the previous even address. This alignment does not affect the address values generated by the address-generation logic.
Most instruction fetches from program space are performed as 32-bit read operations and are aligned accordingly. However, alignment of instruction
fetches are effectively invisible to a programmer. When instructions are stored
to program space, they do not have to be aligned to even addresses. Instruction boundaries are decoded within the CPU.
You need to be concerned with alignment when using instructions that perform
32-bit reads from or writes to data space.
1-11Architectural Overview
Page 30
1-12
Page 31
Chapter 2
Central Processing Unit
The central processing unit (CPU) is responsible for controlling the flow of a
program and the processing of instructions. It performs arithmetic, Booleanlogic, multiply, and shift operations. When performing signed math, the CPU
uses 2s-complement notation. This chapter describes the architecture, registers, and primary functions of the CPU.
All C28x devices contain a central processing unit (CPU), emulation logic, and
signals for interfacing with memory and peripherals. Included with these signals are three address buses and three data buses. Figure 2−1 shows the major blocks and data paths of the C28x CPU. It does not reflect the actual silicon
implementation. The shaded buses are memory-interface buses that are external to the CPU. The operand bus supplies the values for multiplier, shifter,
and ALU operations, and the result bus carries the results to registers and
memory. The main blocks of the CPU are:
- Program and data control logic. This logic stores a queue of instructions
- Real-Time emulation and visibility
- Address register arithmetic unit (ARAU). The ARAU generates ad-
that have been fetched from program memory.
dresses for values that must be fetched from data memory. For a data
read, it places the address on the data-read address bus (DRAB); for a
data write, it loads the data-write address bus (DWAB). The ARAU also
increments or decrements the stack pointer (SP) and the auxiliary registers (XAR0, XAR1, XAR2, XAR3, XAR4, XAR5, XAR6, and XAR7).
- Atomic arithmetic logic unit (ALU). The 32-bit ALU performs 2s-com-
plement arithmetic and Boolean logic operations. Before doing its calculations, the ALU accepts data from registers, from data memory, or from the
program control logic. The ALU saves results to a register or to data
memory.
- Prefetch queue and instruction decode
- Address generators for program and data
- Fixed-point MPY/ALU. The multiplier performs 32-bit × 32-bit 2s-comple-
ment multiplication with a 64-bit result. In conjunction with the multiplier,
the ’28xx uses the 32-bit multiplicand register (XT), the 32-bit product register (P), and the 32-bit accumulator (ACC). The XT register supplies one
of the values to be multiplied. The result of the multiplication can be sent
to the P register or to ACC.
- Interrupt processing
2-2
Page 33
Figure 2−1. Conceptual Block Diagram of the CPU
Program-read data bus, PRDB(0:31)
Program address bus, PAB(0:21)
Data-read address bus, DRAB(0:31)
CPU Architecture
Data-read data bus, DRDB(0:31)
Data-read buffer register
Operand bus
ARAU
XAR0
XAR1
XAR2
XAR3
XAR4
XAR5
XAR6
XAR7
DP
SP
ST1
Address
from stack
Registers
AH:AL
PH:PL
DBGIER
XAR7
T:TL
IER
IFR
ST0
PC
RPC
Program-address
generation logic
MUX
Immediate
Program control
logic
MUX
address
Immediate
data
Immediate
data
Multiplier,
barrel shifter,
and
ALU
Result bus
RESULT BUS
Data-/program-write data bus, DWDB(0:31)
Data-write address bus, DWAB(0:31)
Data-write buffer register
2-3Central Processing Unit
Page 34
CPU Registers
2.2CPU Registers
Table 2−1 lists the main CPU registers and their values after reset. Sections
2.2.1 through 2.2.10 describe the registers in more detail. Figure 2−2 shows
the registers.
Table 2−1. CPU Register Summary
RegisterSizeDescriptionValue After Reset
ACC32 bitsAccumulator0x00000000
AH16 bitsHigh half of ACC0x0000
AL16 bitsLow half of ACC0x0000
XAR016 bitsAuxiliary register 00x00000000
XAR132 bitsAuxiliary register 10x00000000
XAR232 bitsAuxiliary register 20x00000000
XAR332 bitsAuxiliary register 30x00000000
XAR432 bitsAuxiliary register 40x00000000
XAR532 bitsAuxiliary register 50x00000000
XAR632 bitsAuxiliary register 60x00000000
XAR732 bitsAuxiliary register 70x00000000
AR016 bitsLow half of XAR00x0000
AR116 bitsLow half of XAR10x0000
AR216 bitsLow half of XAR20x0000
AR316 bitsLow half of XAR30x0000
AR416 bitsLow half of XAR40x0000
AR516 bitsLow half of XAR50x0000
AR616 bitsLow half of XAR60x0000
AR7
16 bitsLow half of XAR70x0000
2-4
Page 35
Table 2−1. CPU Register Summary (Continued)
RegisterSizeDescriptionValue After Reset
DP16 bitsData-page pointer0x0000
IFR16 bitsInterrupt flag register0x0000
IER16 bitsInterrupt enable register0x0000 (INT1 to INT14, DLOGINT,
CPU Registers
RTOSINT disabled)
DBGIER16 bitsDebug interrupt enable
register
0x0000 (INT1 to INT14, DLOGINT,
RTOSINT disabled)
P32 bitsProduct register0x00000000
PH16 bitsHigh half of P0x0000
PL16 bitsLow half of P0x0000
PC22 bitsProgram counter0x3FFFC0
RPC22 bitsReturn program counter0x00000000
SP16 bitsStack pointer0x0400
ST016 bitsStatus register 00x0000
ST116 bitsStatus register 10x080B
†
XT32 bitsMultiplicand register0x00000000
T16 bitsHigh half of XT0x0000
TL
†
Reset value shown is for devices without the VMAP signal and MOM1MAP signal pinned out. On these
devices both of these signals are tied high internal to the device.
16 bitsLow half of XT0x0000
2-5Central Processing Unit
Page 36
CPU Registers
Figure 2−2. C28x Registers
T[16]
PH[16]
AR0H[16]
AR1H[16]
AR2H[16]
AR3H[16]
AR4H[16]
AR5H[16]
AR6H[16]
AR7H[16]
DP[16]
PC[22]
RPC[22]
TL[16]
PL[16]
AL[16]AH[16]
SP[16]
AR0[16]
AR1[16]
AR2[16]
AR3[16]
AR4[16]
AR5[16]
AR6[16]
AR7[16]
6/7-bit
offset
XT[32]
P[32]
ACC[32]
†
XAR0[32]
XAR1[32]
XAR2[32]
XAR3[32]
XAR4[32]
XAR5[32]
XAR6[32]
XAR7[32]
†
A 6-bit offset is used when operating in C28x mode or C27x object-compatible mode.
A 7-bit offset is used when operating in C2xLP source-compatible mode. The least significant
bit of the DP is ignored when operating in this mode.
2.2.1Accumulator (ACC, AH, AL)
The accumulator (ACC) is the main working register for the device. It is the
destination for all ALU operations except those which operate directly on
memory or registers. ACC supports single-cycle move, add, subtract, and
2-6
ST0[16]
ST1[16]
IER[16]
DBGIER[16]
IFR[16]
Page 37
compare operations from 32-bit-wide data memory. It can also accept the
32-bit result of a multiplication operation.
The halves and quarters of the ACC can also be accessed (see Figure 2−3).
ACC can be treated as two independent 16-bit registers: AH (high 16 bits) and
AL (low 16 bits). The bytes within AH and AL can also be accessed
independently. Special byte-move instructions load and store the most significant byte or least significant byte of AH or AL. This enables efficient byte packing and unpacking.
Figure 2−3. Individually Accessible Portions of the Accumulator
The accumulator has the following associated status bits. For the details on
these bits, see section 2.3, Status Register ST0.
- Overflow mode bit (OVM)
- Sign-extension mode bit (SXM)
- Test/control flag bit (TC)
- Carry bit (C)
- Zero flag bit (Z)
- Negative flag bit (N)
- Latched overflow flag bit (V)
- Overflow counter bits (OVC)
Table 2−2 shows the ways to shift the content of AH, AL, or ACC.
2-7Central Processing Unit
Page 38
CPU Registers
Table 2−2. Available Operations for Shifting Values in the Accumulator
RegisterShift DirectionShift TypeInstruction
ACCLeftLogicalLSL or LSLL
RotationROL
RightArithmeticSFR with SXM = 1
or ASRL
LogicalSFR with SXM = 0
or LSRL
RotationROR
AH or ALLeftLogicalLSL
RightArithmeticASR
LogicalLSR
2.2.2Multiplicand Register (XT)
The multiplicand register (XT register) is used primarily to store a 32-bit signed
integer value prior to a 32-bit multiply operation.
The lower 16-bit portion of the XT register is referred to as the TL register. This
register can be loaded with a signed 16-bit value that is automatically sign-extended to fill the 32-bit XT register.
The upper 16-bit portion of the XT register is referred to as the T register. The
T register is mainly used to store a 16-bit integer value prior to a 16-bit multiply
operation.
The T register is also used to specify the shift value for some shift operations.
In this case, only a portion of the T register is used, depending on the instruction.
For example:
ASR AX, Tperforms an arithmetic shift right
based on the four least significant bits
of T: T(3:0) = 0...15
ASRL ACC, Tperforms an arithmetic shift right by
the five least significant bits of T:
T(4:0) 0...31
For these operations, the most significant bits of T are ignored.
2-8
Page 39
Figure 2−4. Individually Accessible Halves of the XT Register
T = XT(16:31)TL = XT(15:0)
XT
2.2.3Product Register (P, PH, PL)
The product register (P register) is typically used to hold the 32-bit result of a
multiplication. It can also be loaded directly from a 16- or 32-bit data-memory
location, a 16-bit constant, the 32-bit ACC, or a 16-bit or a 32-bit addressable
CPU register. The P register can be treated as a 32-bit register or as two independent 16-bit registers: PH (high 16 bits) and PL (low 16 bits); see
Figure 2−5.
Figure 2−5. Individually Accessible Halves of the P Register
PH = P(31:16)PL = P(15:0)
CPU Registers
P
When some instructions access P, PH, or PL, all 32-bits are copied to the ALUshifter block, where the barrel shifter may perform a left shift, a right shift, or
no shift. The action of the shifter for these instructions is determined by the
product shift mode (PM) bits in status register ST0. Table 2−3 shows the possible PM values and the corresponding product shift modes. When the barrel
shifter performs a left shift, the low order bits are filled with zeros. When the
shifter performs a right shift, the P register value is sign extended. Instructions
that use PH or PL as operands ignore the product shift mode.
For a complete list of instructions affected by PM bits, see Table 2−5 on page
2-20.
2-9Central Processing Unit
Page 40
CPU Registers
Table 2−3. Product Shift Modes
PM ValueProduct Shift Mode
2.2.4Data Page Pointer (DP)
In the direct addressing modes, data memory is addressed in blocks of 64
words called data pages. The lower 4M words of data memory consists of
65536 data pages labeled 0 through 65535, as shown in Figure 2−6. In DP
direct addressing mode, the 16-bit data page pointer (DP) holds the current
data page number. You change the data page by loading the DP with a new
number. For information about the direct addressing modes, see section 5.4
on page 5-8.
000
001
010
011
100
101
110
111
2
2
2
2
2
2
Left shift by 1
No shift
Right shift by 1
Right shift by 2
Right shift by 3
Right shift by 4
(if AMODE = 1, left 4)
2
2
Right shift by 5
Right shift by 6
2-10
Page 41
Figure 2−6. Pages of Data Memory
CPU Registers
00 0000 0000 0000 00
00 0000 0000 0000 00
00 0000 0000 0000 01
00 0000 0000 0000 01
00 0000 0000 0000 10
00 0000 0000 0000 10
11 1111 1111 1111 11
11 1111 1111 1111 11
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
OffsetData page
00 0000
.
.
.
11 1111
00 0000
.
.
.
11 1111
00 0000
.
.
.
11 1111
.
.
.
.
.
.
00 0000
.
.
.
11 1111
Page 0:
Page 1:
Page 2:
Page 65535:
.
.
.
.
.
.
Data memory
00000000−0000003F
00000040−0000007F
00000080−000000BF
.
.
.
.
.
.
003FFFC0−003FFFFF
Data memory above 4M words is not accessible using the DP.
When operating in C2xLP source-compatible mode, a 7-bit offset is used and
the least significant bit of the DP register is ignored. See Appendix C for more
details.
2.2.5Stack Pointer (SP)
The stack pointer (SP) enables the use of a software stack in data memory.
The stack pointer has only 16 bits and can only address the low 64K of data
space (see Figure 2−7). When the SP is used, the upper six bits of the 32-bit
address are forced to 0. (For information about addressing modes that use the
SP, see section 5.5 on page 5-9.). After reset, SP points to address
00000400
16
.
2-11Central Processing Unit
Page 42
CPU Registers
Figure 2−7. Address Reach of the Stack Pointer
Data memory
Range accessible
by way of SP
Range not accessible
by way of SP
00000000−0000FFFF
00010000−FFFFFFFF
The operation of the stack is as follows:
- The stack grows from low memory to high memory.
- The SP always points to the next empty location in the stack.
- At reset, the SP is initialized, so that it points to address 0000 0400
- When 32-bit values are saved to the stack, the least significant 16 bits are
16
.
saved first, and the most significant 16 bits are saved to the next higher
address (little endian format).
- When 32-bit operations read or write a 32-bit value, the C28x CPU expects
the memory wrapper or peripheral-interface logic to align that read or write
to an even address. For example, if the SP contains the odd address
0000 0083
, a 32-bit read operation reads from addresses 0000 0082
16
16
and 0000 008316.
- The SP overflows if its value is increased beyond FFFF
below 0000
from 0000
. When the SP increases past FFFF16, it counts forward
16
. For example, if SP = FFFE16 and an instruction adds 3 to the
16
SP, the result is 000116. When the SP decreases past 000016, it counts
backward from FFFF
. For example, if SP = 000216 and an instruction
16
subtracts 4 from SP, the result is FFFE16.
- When values are being saved to the stack, the SP is not forced to align with
even or odd addresses. Alignment is forced by the memory wrapper or peripheral-interface logic.
2.2.6Auxiliary Registers (XAR0−XAR7, AR0−AR7)
The CPU provides eight 32-bit registers that can be used as pointers to
memory or as general-purpose registers (see Section 5.6, Indirect Addressing
2-12
or decreased
16
Page 43
Modes, on page 5-10 . The auxiliary registers are: XAR0, XAR1, XAR2, XAR3,
XAR4, XAR5, XAR6, and XAR7.
Many instructions allow you to access the 16 LSBs of XAR0−XAR7. As shown
in Figure 2−8, the 16 LSBs of the auxiliary registers are referred to as
AR0−AR7. AR0−AR7 can be used as general purpose registers for loop con-
trol and for efficient 16-bit comparisons.
When accessing AR0−AR7, the upper 16 bits of the register (known as AR0H−
AR7H) may or may not be modified, depending on the instruction used (see
Chapter 6 for information on the behavior of particular instructions). AR0H−
AR7H are accessed only as part of XAR0−XAR7 and are not individually accessible.
Figure 2−8. XAR0 − XAR7 Registers
CPU Registers
n = number 0 through 7
For ACC operations, all 32 bits are valid (@XARn). For 16-bit operations, the
lower 16 bits are used and upper 16 bits are ignored (@ARn).
XAR0 − XAR7 can also be used by some instructions to point to any value in
program memory; see Section 5.6, Indirect Addressing Modes.
Many instructions allow you to access the 16 least significant bits (LSBs) of
XAR0
as one auxiliary register of AR0
Figure 2−9. XAR0 − XAR7
ARnH = XARn(31:16)
XARn(31:0)
−XAR7. As shown in Figure 2−9, 16 LSBs of XAR0−XAR7 are known
−AR7.
XAR0(32:0)
ARn = XARn(15:0)
AR0 = XAR0(15:0)
XAR7(32:0)
AR7 = XAR7(15:0)
2-13Central Processing Unit
Page 44
CPU Registers
2.2.7Program Counter (PC)
When the pipeline is full, the 22-bit program counter (PC) always points to the
instruction that is currently being processed — the instruction that has just
reached the decode 2 phase of the pipeline. Once an instruction reaches this
phase of the pipeline, it cannot be flushed from the pipeline by an interrupt. It
is executed before the interrupt is taken. The pipeline is discussed in
Chapter 4.
2.2.8Return Program Counter (RPC)
When a call operation is performed using the LCR instruction, the return address is saved in the RPC register and the old value in the RPC is saved on
the stack (in two 16-bit operations). When a return operation is performed using the LRETR instruction, the return address is read from the RPC register
and the value on the stack is written into the RPC register (in two 16-bit operations). Other call instructions do not use the RPC register. For more information, see the instructions in Chapter 6.
2.2.9Status Registers (ST0, ST1)
The C28x has two status registers, ST0 and ST1, which contain various flag
bits and control bits. These registers can be stored into and loaded from data
memory, enabling the status of the machine to be saved and restored for subroutines.
The status bits have been organized according to when the bit values are modified in the pipeline. Bits in ST0 are modified in the execute phase of the pipeline; bits in ST1 are modified in the decode 2 phase. (For details about the pipeline, see Chapter 4.) The status bits are described in detail in sections 2.3
(ST0) and 2.4 (ST1). Also, ST0 and ST1 are included in Appendix A, RegisterQuick Reference.
The C28x CPU has three registers dedicated to the control of interrupts:
- Interrupt flag register (IFR)
- Interrupt enable register (IER)
- Debug interrupt enable register (DBGIER)
These registers handle interrupts at the CPU level. Devices with a peripheral
interrupt expansion (PIE) block will have additional interrupt control as part of
the PIE module.
The IFR contains flag bits for maskable interrupts (those that can be enabled
and disabled with software). When one of these flags is set, by hardware or
2-14
Page 45
CPU Registers
software, the corresponding interrupt will be serviced if it is enabled. You enable or disable a maskable interrupt with its corresponding bit in the IER. The
DBGIER indicates the time-critical interrupts that will be serviced (if enabled)
while the DSP is in real-time emulation mode and the CPU is halted.
The C28x CPU interrupts and the interrupt-control registers are described in
detail in Chapter 3, Interrupts. Also, the IFR, IER, and DBGIER are included
in Appendix A, Register Quick Reference.
2-15Central Processing Unit
Page 46
Status Register (ST0)
2.3Status Register (ST0)
The following figure shows the bit fields of status register (ST0). All of these
bit fields are modified in the execute phase of the pipeline. Detailed descriptions of these bits follow the figure.
Note:R = Read access; W = Write access; value following dash (−) is value after reset.
PMVNZCTCOVMSXM
OVC/OVCU
Bits15−10
Overflow counter. The overflow counter behaves differently for signed and unsigned operations.
For signed operations, the overflow counter is a 6-bit signed counter with a range of −32
to 31. When overflow mode is off (OVM = 0), ACC overflows normally, and OVC keeps
track of overflows. When overflow mode is on (OVM = 1) and an overflow occurs in ACC,
the OVC is not affected. Instead, the CPU automatically fills ACC with a positive or negative
saturation value (see the description for OVM on page 2-32).
When ACC overflows in the positive direction (from 7FFFFFFF
to 80000000
16
16
), the
OVC is incremented by 1. When ACC overflows in the negative direction (from 80000000
to 7FFFFFFF
) the OVC is decremented by 1. The increment or decrement is performed
16
as the overflow affects the V flag.
For unsigned operations (OVCU), the counter increments for ADD when a Carry is
generated and decrements for a SUB when a Borrow is generated (similar to a carry
counter).
If OVC increments past its most positive value, 31, the counter wraps around to −32. If OVC
decrements past its most negative value, −32, the counter wraps around to 31. At reset,
OVC is cleared.
OVC is not affected by overflows in registers other than ACC and is not affected by compare
instructions (CMP and CMPL). The table that follows explains how OVC may be affected
by the saturate accumulator (SAT ACC) instruction.
Table 2−4 lists the instructions affecting OVC/OVCU. See the instruction set
in Chapter 6 for a complete description of each instruction.
16
2-16
Page 47
Status Register (ST0)
Table 2−4. Instructions That Affect OVC/OVCU
Signed Addition InstructionsEffect on OVC/OVCU
ADD ACC,loc16 << shiftif(OVM == 0) Inc OVC on +ve signed
overflow
ADD ACC,#16bit << shift
ADD ACC,loc16 << T
ADD loc16,#16bitSigned
ADDB ACC,#8bit
ADDCL ACC,loc32
ADDCU ACC,loc16
ADDL ACC,loc32
ADDL loc32,ACC
ADDU ACC,loc16
DMAC ACC:P,loc32,*XAR7/++
INC loc16
MAC P,loc16,*XAR7/++
MAC P,loc16,0:pma
MOVA T,loc16
MOVAD T,loc16
MPYA P,loc16,#16bit
MPYA P,T,loc16
QMACL P,loc32,*XAR7/++
QMPYAL P,XT,loc32
SQRA loc16
XMAC P,loc16,*(pma)
XMACD P,loc16,*(pma)
Signed Subtraction InstructionsEffect on OVC/OVCU
DEC loc16if(OVM == 0) Dec OVC on −ve signed
overflow
MOVS T,loc16
2-17Central Processing Unit
Page 48
Status Register (ST0)
Table 2−4. Instructions That Affect OVC/OVCU (Continued)
Signed Addition InstructionsEffect on OVC/OVCU
MPYS P,T,loc16
QMPYSL P,XT,loc32
SBBU ACC,loc16
SQRS loc16
SUB ACC,#16bit << shift
SUB ACC,loc16 << shift
SUB ACC,loc16 << T
SUBB ACC,#8bit
SUBBL ACC,loc32
SUBL ACC,loc32
SUBL loc32,ACC
SUBRL loc32,ACC
SUBU ACC,loc16
SUBUL ACC,loc32
SUBUL P,loc32
Unsigned InstructionsEffect on OVC/OVCU
ADDUL ACC,loc32Inc OVC/OVCU on unsigned carry
ADDUL P,loc32
IMPYAL P,XT,loc32
IMACL P,loc32,*XAR7/++
Misc InstructionsEffect on OVC/OVCU
SAT ACCif(OVC > 0) Saturate +ve
if(OVC < 0) Saturate −ve
OVC = 0
SAT64 ACC:P
ZAPAOVC = 0
ZAP OVC
MOV OVC,loc16OVC = [loc16(15:10)]
2-18
Page 49
Table 2−4. Instructions That Affect OVC/OVCU (Continued)
Signed Addition InstructionsEffect on OVC/OVCU
MOVU OVC,loc16OVC = [loc16(5:0)]
ConditionOperation Performed by SAT ACC Instruction
Status Register (ST0)
OVC = 0
OVC > 0
OVC < 0
PM
Bits 9−7
Leave ACC and OVC unchanged.
Saturate ACC in the positive direction (fill ACC with 7FFFFFFF
Saturate ACC in the negative direction (fill ACC with 8000000016), and clear OVC.
Product shift mode bits. This 3-bit value determines the shift mode for any output operation from the product (P) register. The shift modes are shown in the following table. The output can be to the ALU or to memory. All instructions that are affected by the product shift
mode will sign extend the P register value during a right shift operation. At reset, PM is
cleared (left shift by 1 bit is the default).
PM is summarized as follows:
000Left shift by 1. During the shift, the low-order bit is zero filled. At reset, this mode
is selected.
001No shift
010Right shift by 1. During the shift, the lower bits are lost, and the shifted value is sign
extended.
011Right shift by 2. During the shift, the lower bits are lost, and the shifted value is sign
extended.
100Right shift by 3. During the shift, the lower bits are lost, and the shifted value is sign
extended.
101Right shift by 4. During the shift, the lower bits are lost, and the shifted value is sign
extended.
Note, if AMODE = 1, then 101 is a left shift by 4.
), and clear OVC.
16
110Right shift by 5. During the shift, the lower bits are lost, and the shifted value is sign
extended.
111Right shift by 6. During the shift, the lower bits are lost, and the shifted value is sign
extended.
Note:For performing unsigned arithmetic, you must use a product shift of 0 (PM = 001) to avoid sign extension and genera-
tion of incorrect results.
Table 2−5 lists instructions that are affected by the PM bits. See the instruction
set in chapter 6 for a complete description of each instruction.
Overflow flag. If the result of an operation causes an overflow in the register holding the
result, V is set and latched. If no overflow occurs, V is not modified. Once V is latched, it
remains set until it is cleared by reset or by a conditional branch instruction that tests V.
Such a conditional branch clears V regardless of whether the tested condition (V = 0 or
V = 1) is true.
An overflow occurs in ACC (and V is set) if the result of an addition or subtraction does not
fit within the signed numerical range −2
An overflow occurs in AH, AL, or another 16-bit register or data-memory location if the result
of an addition or subtraction does not fit within the signed numerical range −2
1), or 8000
The instructions CMP, CMPB and CMPL do not affect the state of the V flag. Table 2−6 lists
the instructions that are affected by V flag. See Chapter 6 for more details on instructions.
to 7FFF16.
16
31
to (+231 − 1), or 8000000016 to 7FFFFFFF16.
15
to (+215 −
V can be summarized as follows:
0
V has been cleared.
1An overflow has been detected, or V has been set.
Table 2−6. Instructions Affected by V flag
InstructionDescription
ABS ACCif(ACC == 0x8000 0000) V = 1
ABSTC ACCif(ACC == 0x8000 0000) V = 1
ADD ACC,#16bit << shiftV = 1 on signed overflow
ADD ACC,loc16 << shiftV = 1 on signed overflow
ADD ACC,loc16 << TV = 1 on signed overflow
ADD AX,loc16V = 1 on signed overflow
ADD loc16,#16bitSignedV = 1 on signed overflow
ADD loc16,AXV = 1 on signed overflow
ADDB ACC,#8bitV = 1 on signed overflow
ADDB AX,#8bitSignedV = 1 on signed overflow
ADDCL ACC,loc32V = 1 on signed overflow
ADDCU ACC,loc16V = 1 on signed overflow
ADDL ACC,loc32V = 1 on signed overflow
ADDL loc32,ACCV = 1 on signed overflow
ADDU ACC,loc16V = 1 on signed overflow
ADDUL ACC,loc32V = 1 on signed overflow
2-21Central Processing Unit
Page 52
Status Register (ST0)
Table 2−6. Instructions Affected by V flag (Continued)
InstructionDescription
ADDUL P,loc32V = 1 on signed overflow
B 16bitOff,CONDV = 0 if tested
BF 16bitOff,CONDV = 0 if tested
DEC loc16V = 1 on signed overflow
DMAC ACC:P,loc32,*XAR7/++V = 1 on signed overflow
IMACL P,loc32,*XAR7/++V = 1 on signed overflow
IMPYAL P,XT,loc32V = 1 on signed overflow
IMPYSL P,XT,loc32V = 1 on signed overflow
INC loc16V = 1 on signed overflow
MAC P,loc16,*XAR7/++V = 1 on signed overflow
MAC P,loc16,0:pmaV = 1 on signed overflow
MAX AX,loc16if((AX − [loc16]) > 0) V = 1
MAXL ACC,loc32if((ACC − [loc32]) > 0) V = 1
MIN AX,loc16if((AX − [loc16]) < 0) V = 1
MINL ACC,loc32if((ACC − [loc32]) < 0) V = 1
MOV loc16,AX,CONDV = 0 if tested
MOVA T,loc16V = 1 on signed overflow
MOVAD T,loc16V = 1 on signed overflow
MOVB loc16,#8bit,CONDV = 0 if tested
MOVL loc32,ACC,CONDV = 0 if tested
MOVS T,loc16V = 1 on signed overflow
MPYA P,loc16,#16bitV = 1 on signed overflow
MPYA P,T,loc16V = 1 on signed overflow
MPYS P,T,loc16V = 1 on signed overflow
NEG ACCif(ACC == 0x8000 0000) V = 1
NEG AXif(AX == 0x8000) V = 1
NEG64 ACC:Pif(ACC:P == 0x80....00) V = 1
2-22
Page 53
Status Register (ST0)
Table 2−6. Instructions Affected by V flag (Continued)
InstructionDescription
NEGTC ACCif(TC == 1)
if(ACC == 0x8000 0000) V = 1
QMACL P,loc32,*XAR7/++V = 1 on signed overflow
QMPYAL P,XT,loc32V = 1 on signed overflow
QMPYSL P,XT,loc32V = 1 on signed overflow
SAT ACCif(OVC == 0) V = 0 else V = 1
SAT64 ACC:Pif(OVC == 0) V = 0 else V = 1
SB 8bitOff,CONDV = 0 if tested
SBBU ACC,loc16V = 1 on signed overflow
SQRA loc16V = 1 on signed overflow
SQRS loc16V = 1 on signed overflow
SUB ACC,#16bit << shiftV = 1 on signed overflow
SUB ACC,loc16 << shiftV = 1 on signed overflow
SUB ACC,loc16 << TV = 1 on signed overflow
SUB AX,loc16V = 1 on signed overflow
SUB loc16,AXV = 1 on signed overflow
SUBB ACC,#8bitV = 1 on signed overflow
SUBBL ACC,loc32V = 1 on signed overflow
SUBL ACC,loc32V = 1 on signed overflow
SUBL loc32,ACCV = 1 on signed overflow
SUBR loc16,AXV = 1 on signed overflow
SUBRL loc32,ACCV = 1 on signed overflow
SUBU ACC,loc16V = 1 on signed overflow
SUBUL ACC,loc32V = 1 on signed overflow
SUBUL P,loc32V = 1 on signed overflow
XB pma,CONDV = 0 if tested
XCALL pma,CONDV = 0 if tested
XMAC P,loc16,*(pma)V = 1 on signed overflow
2-23Central Processing Unit
Page 54
Status Register (ST0)
Á
Á
Á
Table 2−6. Instructions Affected by V flag (Continued)
InstructionDescription
XMACD P,loc16,*(pma)
XRETC CONDV = 0 if tested
V = 1 on signed overflow
N
Bit 5
Negative flag. During certain operations, N is set if the result of the operation is a negative
number or cleared if the result is a positive number. At reset, N is cleared.
Results in ACC are tested for the negative condition. Bit 31 of ACC is the sign bit. If bit 31
is a 0, ACC is positive; if bit 31 is a 1, ACC is negative. N is set if a result in ACC is negative
or cleared if a result is positive.
Results in AH, AL, and other 16-bit registers or data-memory locations are also tested for
the negative condition. In these cases bit 15 of the value is the sign bit (1 indicates negative,
0 indicates positive). N is set if the value is negative or cleared if the value is positive.
The TEST ACC instruction sets N if the value in ACC is negative. Otherwise the instruction
clears N.
As shown in Table 2−7, under overflow conditions, the way the N flag is set for compare
operations is different from the way it is set for addition or subtraction operations. For addition or subtraction operations, the N flag is set to match the most significant bit of the truncated result. For compare operations, the N flag assumes infinite precision. This applies
to operations whose result is loaded to ACC, AH, AL, another register, or a data-memory
location.
Table 2−7. Negative Flag Under Overflow Conditions
†
A
PosNeg
†
B
(A − B)
Neg
(due to overflow in positive direction)
Subtraction
N = 1N = 0
Compare
‡
Pos
NegPos
†
For 32-bit data: Pos = Positive number from 0000000016 to 7FFFFFFF
ББББББББББББББББББББББББББББ
For 16-bit data: Pos = Positive number from 000016 to 7FFF
ББББББББББББББББББББББББББББ
ББББББББББББББББББББББББББББ
‡
The compare instructions are CMP, CMPB, CMPL, MIN, MAX, MINL, and MAXL.
(due to overflow in negative direction)
Neg = Negative number from 8000000016 to FFFFFFFF
Neg = Negative number from 800016 to FFFF
16
16
N = 0N = 1
16
16
N can be summarized as follows:
0
The tested number is positive, or N has been cleared.
1The tested number is negative, or N has been set.
2-24
Page 55
Status Register (ST0)
Z
Bit 4
C
Bit 3
Zero flag. Z is set if the result of certain operations is 0 or is cleared if the result is nonzero.
This applies to results that are loaded into ACC, AH, AL, another register, or a data-memory
location. At reset, Z is cleared.
The TEST ACC instruction sets Z if the value in ACC is 0. Otherwise, it clears Z.
Z can be summarized as follows:
0
The tested number is nonzero, or Z has been cleared.
1The tested number is 0, or Z has been set.
Carry bit. This bit indicates when an addition or increment generates a carry or when a subtraction, compare, or decrement generates a borrow. It is also affected by rotate operations
on ACC and barrel shifts on ACC, AH, and AL.
During additions/increments, C is set if the addition generates a carry; otherwise C is
cleared. There is one exception: If you are using the ADD instruction with a shift of 16, the
ADD instruction can set C but cannot clear C.
During subtractions/decrements/compares, C is cleared if the subtraction generates a
carry; otherwise C is set. There is one exception: if you are using the SUB instruction with
a shift of 16, the SUB instruction can clear C but cannot set C.
This bit can be individually set and cleared by the SETC C instruction and CLRC C instruction, respectively. At reset, C is cleared.
C can be summarized as follows:
0
A subtraction generated a borrow, an addition did not generate a carry, or C has
been cleared. Exception: An ADD instruction with a shift of 16 cannot clear C.
1An addition generated a carry, a subtraction did not generate a borrow, or C has
been set. Exception: A SUB instruction with a shift of 16 cannot set C.
Table 2−8 lists the bits that are affected by the C bit. For more information on
instructions, see Chapter 6.
Table 2−8. Bits Affected by the C Bit
InstructionAffect of or Affect on C
ABS ACCC = 0
ABSTC ACCC = 0
ADD ACC,#16bit << shiftC = 1 on carry else C = 0
ADD ACC,loc16 << shiftif(shift == 16)
C = 1 on carry
if(shift != 16)
C = 1 on carry else C = 0
2-25Central Processing Unit
Page 56
Status Register (ST0)
Table 2−8. Bits Affected by the C Bit (Continued)
InstructionAffect of or Affect on C
ADD ACC,loc16 << TC = 1 on carry else C = 0
ADD AX,loc16C = 1 on carry else C = 0
ADD loc16,#16bitSignedC = 1 on carry else C = 0
ADD loc16,AXC = 1 on carry else C = 0
ADDB ACC,#8bitC = 1 on carry else C = 0
ADDB AX,#8bitSignedC = 1 on carry else C = 0
ADDCL ACC,loc32ACC = ACC + [loc32] + C
C = 1 on carry else C = 0
ADDCU ACC,loc16ACC = ACC + [loc16] + C
C = 1 on carry else C = 0
ADDL ACC,loc32C = 1 on carry else C = 0
ADDL loc32,ACCC = 1 on carry else C = 0
ADDU ACC,loc16C = 1 on carry else C = 0
ADDUL ACC,loc32C = 1 on carry else C = 0
ADDUL P,loc32C = 1 on carry else C = 0
ASR AX,1..16C = AX(bit(shift−1))
ASR AX,Tif(T == 0) C = 0
else C = AX(bit(T−1))
ASR64 ACC:P,1..16C = P(bit(shift−1))
ASR64 ACC:P,Tif(T == 0) C = 0
else C = P(bit(T−1))
ASRL ACC,Tif(T == 0) C = 0
else C = ACC(bit(T−1))
B 16bitOff,CONDC bit used as test condition
BF 16bitOff,CONDC bit used as test condition
CLRC CC = 0
CMP AX,loc16C = 0 on borrow else C = 1
2-26
Page 57
Status Register (ST0)
Table 2−8. Bits Affected by the C Bit (Continued)
InstructionAffect of or Affect on C
CMP loc16,#16bitSignedfor([loc16] − 16bitSigned)
C = 0 on borrow else C = 1
CMPB AX,#8bit
CMPL ACC,loc32for(ACC − [loc32])
CMPL ACC,P << PMfor(ACC − P << PM)
DEC loc16+C = 0 on borrow else C = 1
DMAC ACC:P,loc32,*XAR7/++C = 1 on carry else C = 0
IMACL P,loc32,*XAR7/++C = 1 on carry else C = 0
IMPYAL P,XT,loc32C = 1 on carry else C = 0
IMPYSL P,XT,loc32C = 0 on borrow else C = 1
C = 0 on borrow else C = 1
C = 0 on borrow else C = 1
C = 0 on borrow else C = 1
INC loc16C = 1 on carry else C = 0
LSL ACC,1..16C = ACC(bit(32−shift))
LSL ACC,Tif(T == 0) C = 0
else C = ACC(bit(32−T))
LSL AX,1..16C = AX(bit(16−shift))
LSL AX,Tif(T == 0) C = 0
else C = AX(bit(16−T))
LSL64 ACC:P,1..16C = ACC(bit(32−shift))
LSL64 ACC:P,Tif(T == 0) C = 0
else C = ACC(bit(32−T))
LSLL ACC,Tif(T == 0) C = 0
else C = ACC(bit(32−T))
LSR AX,1..16C = AX(bit(shift−1))
LSR AX,Tif(T == 0) C = 0
else C = AX(bit(T−1))
LSR64 ACC:P,1..16C = P(bit(shift−1))
2-27Central Processing Unit
Page 58
Status Register (ST0)
Table 2−8. Bits Affected by the C Bit (Continued)
InstructionAffect of or Affect on C
LSR64 ACC:P,Tif(T == 0) C = 0
else C = P(bit(T−1))
LSRL ACC,Tif(T == 0) C = 0
else C = ACC(bit(T−1))
MAC P,loc16,*XAR7/++C = 1 on carry else C = 0
MAC P,loc16,0:pmaC = 1 on carry else C = 0
MAX AX,loc16for(AX − [loc16])
C = 0 on borrow else C = 1
MAXL ACC,loc32for(ACC − [loc32])
C = 0 on borrow else C = 1
MIN AX,loc16for(AX − [loc16])
C = 0 on borrow else C = 1
MINL ACC,loc32for(ACC − [loc32])
C = 0 on borrow else C = 1
MOV loc16,AX,CONDC bit used as test condition
MOVA T,loc16C = 1 on carry else C = 0
MOVAD T,loc16C = 1 on carry else C = 0
MOVB loc16,#8bit,CONDC bit used as test condition
MOVL loc32,ACC,CONDC bit used as test condition
MOVS T,loc16C = 0 on borrow else C = 1
MPYA P,loc16,#16bitC = 1 on carry else C = 0
MPYA P,T,loc16C = 1 on carry else C = 0
MPYS P,T,loc16C = 0 on borrow else C = 1
NEG ACCif( ACC == 0) C = 1
else C = 0
NEG AXif(AX == 0) C = 1
else C = 0
NEG64 ACC:Pif( ACC:P == 0) C = 1
else C = 0
2-28
Page 59
Status Register (ST0)
Table 2−8. Bits Affected by the C Bit (Continued)
InstructionAffect of or Affect on C
NEGTC ACCif(TC == 1)
if( ACC == 0) C = 1
else C = 0
QMACL P,loc32,*XAR7/++C = 1 on carry else C = 0
QMPYAL P,XT,loc32C = 1 on carry else C = 0
QMPYSL P,XT,loc32C = 0 on borrow else C = 1
ROL ACCC <− (ACC << 1) <− C(before)
ROR ACCC(before) −> (ACC >> 1) −> C
SAT ACCC = 0
SAT64 ACC:PC = 0
SB 8bitOff,CONDC bit used as test condition
SBBU ACC,loc16ACC = ACC − ([loc16] + ~C)
C = 0 on borrow else C = 1
SETC CC = 1
SFR ACC,1..16C = ACC(bit(shift−1))
SFR ACC,Tif(T == 0) C = 0
else C = ACC(bit(T−1))
SQRA loc16C = 1 on carry else C = 0
SQRS loc16C = 0 on borrow else C = 1
SUB ACC,#16bit << shiftC = 0 on borrow else C = 1
SUB ACC,loc16 << shiftif(shift == 16)
C = 0 on borrow
if(shift != 16)
C = 0 on borrow else C = 1
SUB ACC,loc16 << TC = 0 on borrow else C = 1
SUB AX,loc16C = 0 on borrow else C = 1
SUB loc16,AXC = 0 on borrow else C = 1
SUBB ACC,#8bitC = 0 on borrow else C = 1
2-29Central Processing Unit
Page 60
Status Register (ST0)
Table 2−8. Bits Affected by the C Bit (Continued)
InstructionAffect of or Affect on C
SUBBL ACC,loc32ACC = ACC − ([loc32] + ~C)
C = 0 on borrow else C = 1
SUBCU ACC,loc16for(ACC − [loc16]<<15)
C = 0 on borrow else C = 1
SUBCUL ACC,loc32for(ACC<<1 + P(31) − [loc32])
C = 0 on borrow else C = 1
SUBL ACC,loc32C = 0 on borrow else C = 1
SUBL loc32,ACCC = 0 on borrow else C = 1
SUBR loc16,AXC = 0 on borrow else C = 1
SUBRL loc32,ACCC = 0 on borrow else C = 1
SUBU ACC,loc16C = 0 on borrow else C = 1
SUBUL ACC,loc32C = 0 on borrow else C = 1
TC
Bit 2
SUBUL P,loc32C = 0 on borrow else C = 1
XB pma,CONDC bit used as test condition
XCALL pma,CONDC bit used as test condition
XMAC P,loc16,*(pma)C = 1 on carry else C = 0
XMACD P,loc16,*(pma)C = 1 on carry else C = 0
XRETC CONDC bit used as test condition
Test/control flag. This bit shows the result of a test performed by either the TBIT (test bit)
instruction or the NORM (normalize) instruction.
The TBIT instruction tests a specified bit. When TBIT is executed, the TC bit is set if the
tested bit is 1 or cleared if the tested bit is 0.
When a NORM instruction is executed, TC is modified as follows: If ACC holds 0, TC is set.
If ACC does not hold 0, the CPU calculates the exclusive-OR of ACC bits 31 and 30, and
then loads TC with the result.
This bit can be individually set and cleared by the SETC TC instruction and CLRC TC
instruction, respectively. At reset, TC is cleared.
Table 2−9 lists the instructions that affect the TC bit. See the instruction set in
Chapter 6 for a complete description of each instruction.
2-30
Page 61
Table 2−9. Instructions That Affect the TC Bit
InstructionAffect on the TC bit
ABSTC ACCif( ACC < 0 ) TC = TC ^ 1
B 16bitOff,CONDTC bit used as test condition
BF 16bitOff,CONDTC bit used as test condition
CLRC TCTC = 0
CMPR 0/1/2/3TC = 0
CSB ACCTC = N flag
MOV loc16,AX,CONDTC bit used as test condition
MOVB loc16,#8bit,CONDTC bit used as test condition
Status Register (ST0)
0: if(AR(ARP) == AR0) TC = 1
1: if(AR(ARP) < AR0) TC = 1
2: if(AR(ARP) > AR0) TC = 1
3: if(AR(ARP) != AR0) TC = 1
MOVL loc32,ACC,CONDTC bit used as test condition
NEGTC ACCTC bit used as test condition
NORM ACC,XARn++/−−
NORM ACC,*ind
SB 8bitOff,COND
if(ACC |= 0)
TC = ACC(31) ^ ACC(30)
else
TC = 1
TC bit used as test condition
SBF 8bitOff,TC/NTCTC bit used as test condition
SETC TCTC = 1
TBIT loc16,#bitTC = [loc16(bit)]
TBIT loc16,TTC = [loc16(15−T)]
TCLR loc16,#bitTC = [loc16(bit)]
TSET loc16,#bitTC = [loc16(bit)]
XB pma,CONDTC bit used as test condition
XCALL pma,CONDTC bit used as test condition
XRETC CONDTC bit used as test condition
2-31Central Processing Unit
Page 62
Status Register (ST0)
OVM
Bit 1
SXM
Bit 0
Overflow mode bit. When ACC accepts the result of an addition or subtraction and the
result causes an overflow, OVM determines how the CPU handles the overflow as follows:.
0Results overflow normally in ACC. The OVC reflects the overflow (see the de-
scription for the OVC on page 2-16)
1ACC is filled with either its most positive or most negative value as follows:
If ACC overflows in the positive direction (from 7FFFFFFF
ACC is then filled with 7FFFFFFF
16
.
If ACC overflows in the negative direction (from 80000000
ACC is then filled with 80000000
16
.
to 80000000
16
to 7FFFFFFF
16
16
16
),
This bit can be individually set and cleared by the SETC OVM instruction and
CLRC OVM instruction, respectively. At reset, OVM is cleared.
Sign-extension mode bit. SXM affects the MOV, ADD, and SUB instructions that use a
16-bit value in an operation on the 32-bit accumulator. When the 16-bit value is loaded
into (MOV), added to (ADD), or subtracted from (SUB) the accumulator, SXM determines whether the value is sign extended during the operation as follows:
0Sign extension is suppressed. (The value is treated as unsigned.)i
1Sign extension is enabled. (The value is treated as signed.)
SXM also determines whether the accumulator is sign extended when it is shifted right
by the SFR instruction. SXM does not affect instructions that shift the product register
value; all right shifts of the product register value use sign extension.
),
This bit can be individually set and cleared by the SETC SXM instruction and
CLRC SXM instruction, respectively. At reset, SXM is cleared. Table 2−10 lists the in-
structions that are affected by SXM. See Chapter 6 for more details on instructions.
2-32
Page 63
Table 2−10. Instructions Affected by SXM
InstructionDescription
ADD ACC,#16bit << shiftAffected By SXM
ADD ACC,loc16 << shiftAffected By SXM
ADD ACC,loc16 << TAffected By SXM
CLRC SXMSXM = 0
MOV ACC,#16bit << shiftAffected By SXM
MOV ACC,loc16 << shiftAffected By SXM
MOV ACC,loc16 << TAffected By SXM
SETC SXMSXM = 1
SFR ACC,1..16Affected By SXM
SFR ACC,TAffected By SXM
SUB ACC,#16bit << shiftAffected By SXM
SUB ACC,loc16 << shiftAffected By SXM
Status Register (ST0)
SUB ACC,loc16 << TAffected By SXM
2-33Central Processing Unit
Page 64
Status Register ST1
2.4Status Register ST1
The following figure shows the bit fields of status register ST1. All of these bit
fields are modified in the decode 2 phase of the pipeline. Detailed descriptions
of these bits follow the figure.
Figure 2−11.Bit Fields of Status Register 1 (ST1)
151312111098
ARPXFM0M1MAPReservedOBJMODEAMODE
R/W-000R/W−0R/W−1R/W−0R/W−0R/W−0
76543210
IDLESTAT
R−0R/W−0R−0R/W−0R/W−1R/W−0R/W−1R/W−1
EALLOWLOOPSPAVMAPPAGE0DBGMINTM
ARP
Bits 15−13
XF
Bit 12
Auxiliary register pointer. This 3-bit field points to the current auxiliary register. This is one
of the 32-bit auxiliary registers (XAR0−XAR7). The mapping of ARP values to auxiliary registers is as follows:
ARP
000XAR0 (selected at reset)
001XAR1
010XAR2
011XAR3
100XAR4
101XAR5
110XAR6
111
XF status bit. This bit reflects the current state of the XFS output signal, which is compatible to the C2XLP CPU. This bit is set by the ”SETC XF” instruction. This bit is
cleared by the ”CLRC XF” instruction. The pipeline is not flushed when setting or clearing this bit using the given instructions. This bit can be saved and restored by interrupts
and when restoring the ST1 register. This bit is set to 0 on reset.
Selected Auxiliary Register
XAR7
M0M1MAP
Bit 11
M0 and M1 mapping mode bit. The M0M1MAP bit should always remain set to 1 in
the C28x object mode. This is the default value at reset. The M0M1MAP bit may be set
low when operating in C27x-compatible mode. The effect of this bit, when low, is to
swap the location of blocks M0 and M1 only in program space and to set the stack
pointer default reset value to 0x000. C28x mode users should never set this bit to 0.
2-34
Page 65
Status Register ST1
Reserved
Bit 10
OBJMODE
Bit 9
AMODE
Bit 8
IDLESTAT
Bit 7
Reserved. This bit is reserved. Writes to this bit have no effect.
Object compatibility mode bit. This mode is used to select between C27x object
mode (OBJMODE == 0) and C28x object mode (OBJMODE == 1) compatibility. This bit
is set by the ”C28OBJ” (or ”SETC OBJMODE”) instructions. This bit is cleared by the
”C27OBJ” (or ”CLRC OBJMODE”) instructions. The pipeline is flushed when setting or
clearing this bit using the given instructions. This bit is saved and restored by interrupts
and when restoring the ST1 register. This bit is set to 0 on reset.
Address mode bit. This mode, in conjunction with the PAGE0 mode bit, is used to select the appropriate addressing mode decodes. This bit is set by the “LPADDR” (”SETC
AMODE”) instructions. This bit is cleared by the ”C28ADDR” (or ”CLRC AMODE”) instructions. The pipeline is not flushed when setting or clearing this bit using the given
instructions. This bit is saved and restored by interrupts and when restoring the ST1
register. This bit is set to 0 on reset.
Note: Setting PAGE0 = AMODE = 1 will generate an illegal instruction trap ONLY for
instructions that decode a memory or register addressing mode field (loc16 or loc32).
IDLE status bit. This ready-only bit is set when the IDLE instruction is executed. It is
cleared by any one of the following events:
- An interrupt is serviced.
- An interrupt is not serviced but takes the CPU out of the IDLE state.
- A valid instruction enters the instruction register (the register that holds the instruction
currently being decoded).
EALLOW
Bit 6
LOOP
Bit 5
- A device reset occurs.
When the CPU services an interrupt, the current value of IDLESTAT is saved on the
stack (when ST1 is saved on the stack), and then IDLESTAT is cleared. Upon return
from the interrupt, IDLESTAT is not restored from the stack.
Emulation access enable bit. This bit, when set, enables access to emulation and
other protected registers. Set this bit by using the EALLOW instruction and clear this bit
by using the EDIS instruction. See the data sheet for a particular device to determine
the registers that are protected.
When the CPU services an interrupt, the current value of EALLOW is saved on the
stack (when ST1 is saved on the stack), and then EALLOW is cleared. Therefore, at the
start of an interrupt service routine (ISR), access to protected registers is disabled. If the
ISR must access protected registers, it must include an EALLOW instruction. At the end
of the ISR, EALLOW can be restored by the IRET instruction.
Loop instruction status bit. LOOP is set when a loop instruction (LOOPNZ or
LOOPZ) reaches the decode 2 phase of the pipeline. The loop instruction does not end
until a specified condition is met. When the condition is met, LOOP is cleared. LOOP is
a read-only bit; it is not affected by any instruction except a loop instruction.
2-35Central Processing Unit
Page 66
Status Register ST1
When the CPU services an interrupt, the current value of LOOP is saved on the stack
(when ST1 is saved on the stack), and then LOOP is cleared. Upon return from the interrupt, LOOP is not restored from the stack.
SPA
Bits 4
VMAP
Bit 3
PAGE0
Bit 2
Stack pointer alignment bit. SPA indicates whether the CPU has previously aligned
the stack pointer to an even address by the ASP instruction:
0The stack pointer has not been aligned to an even address.
1The stack pointer has been aligned to an even address.
When the ASP (align stack pointer) instruction is executed, if the stack pointer (SP)
points to an odd address, SP is incremented by 1 so that it points to an even address,
and SPA is set. If SP already points to an even address, SP is not changed, but SPA is
cleared. When the NASP (unalign stack pointer) instruction is executed, if SPA is 1, SP
is decremented by 1 and SPA is cleared. If SPA is 0, SP is not changed.
At reset, SPA is cleared.
Vector map bit. VMAP determines whether the CPU interrupt vectors (including the
reset vector) are mapped to the lowest or highest addresses in program memory:
0CPU interrupt vectors are mapped to the bottom of program memory, addresses
00 0000
1CPU interrupt vectors are mapped to the top of program memory, addresses
3F FFC0
On C28x designs, the VMAP signal is tied high internally, forcing the VMAP bit to be set
high on a reset.
This bit can be individually set and cleared by the SETC VMAP instruction and
CLRC VMAP instruction, respectively.
PAGE0 addressing mode configuration bit. PAGE0 selects between two mutually-exclusive addressing modes: PAGE0 direct addressing mode and PAGE0 stack addressing mode. Selection of the modes is as follows:
0PAGE0 stack addressing mode
1PAGE0 direct addressing mode
−00 003F16.
16
−3F FFFF16.
16
Note: Illegal Instruction Trap
Setting PAGE0 = AMODE = 1 will generate an illegal instruction trap.
PAGE0 = 1 is included for compatibility with the C27x. the recommended operating
mode for C28x is PAGE0 = 0.
This bit can be individually set and cleared by the SETC PAGE0 instruction and
CLRC PAGE0 instruction, respectively. At reset, the PAGE0 bit is cleared (PAGE0 stack
addressing mode is selected).
For details about the above addressing modes, see Chapter 5, Addressing Modes.
2-36
Page 67
Status Register ST1
DBGM
Bit 1
Debug enable mask bit. When DBGM is set, the emulator cannot accesss memory or
registers in real time. The debugger cannot update its windows.
In the real-time emulation mode, if DBGM = 1, the CPU ignores halt requests or hardware breakpoints until DBGM is cleared. DBGM does not prevent the CPU from halting
at a software breakpoint. One effect of this may be seen in real-time emulation mode.
If you single-step an instruction in real time emulation mode and that instruction sets
DBGM, the CPU continues to execute instructions until DBGM is cleared.
When you give the TI debugger the REALTIME command (to enter real-time mode),
DBGM is forced to 0. Having DBGM = 0 ensures that debug and test direct memory
accesses (DT-DMAs) are allowed; memory and register values can be passed to the
host processor for updating debugger windows.
Before the CPU executes an interrupt service routine (ISR), it sets DBGM. When
DBGM = 1, halt requests from the host processor and hardware breakpoints are ignored. If you want to single-step through or set breakpoints in a non-time-critical ISR,
you must add a CLRC DBGM instruction at the beginning of the ISR.
DBGM is primarily used in emulation to block debug events in time-critical portions of
program code. DBGM enables or disables debug events as follows:
0Debug events are enabled.
1Debug events are disabled.
When the CPU services an interrupt, the current value of DBGM is saved on the stack
(when ST1 is saved on the stack), and then DBGM is set. Upon return from the interrupt, DBGM is restored from the stack.
This bit can be individually set and cleared by the SETC DBGM instruction and
CLRC DBGM instruction, respectively. DBGM is also set automatically during interrupt
operations. At reset, DBGM is set. Executing the ABORTI (abort interrupt) instruction
also sets DBGM.
INTM
Bit 0
Interrupt global mask bit. This bit globally enables or disables all maskable CPU interrupts (those that can be blocked by software):
0Maskable interrupts are globally enabled. To be acknowledged by the CPU, a
maskable interrupt must also be locally enabled by the interrupt enable register
(IER).
1Maskable interrupts are globally disabled. Even if a maskable interrupt is local-
ly enabled by the IER, it is not acknowledged by the CPU.
INTM has no effect on the nonmaskable interrupts, including a hardware reset or the
hardware interrupt NMI
mode, an interrupt enabled by the IER and the DBGIER will be serviced even if INTM is
set to disable maskable interrupts.
. In addition, when the CPU is halted in real-time emulation
2-37Central Processing Unit
Page 68
Status Register ST1
When the CPU services an interrupt, the current value of INTM is saved on the stack
(when ST1 is saved on the stack), and then INTM is set. Upon return from the interrupt,
INTM is restored from the stack.
This bit can be individually set and cleared by the SETC INTM instruction and
CLRC INTM instruction, respectively. At reset, INTM is set. The value in INTM does not
cause modification to the interrupt flag register (IFR), the interrupt enable register (IER),
or the debug interrupt enable register (DBGIER).
2-38
Page 69
2.5Program Flow
2.5.1Interrupts
Program Flow
The program control logic and program-address generation logic work together to provide proper program flow. Normally, the flow of a program is sequential: the CPU executes instructions at consecutive program-memory addresses. At times, a discontinuity is required; that is, a program must branch to a
nonsequential address and then execute instructions sequentially at that new
location. For this purpose, the ’28x supports interrupts, branches, calls, returns, and repeats.
Proper program flow also requires smooth flow at the instruction level. To meet
this need, the ’28x has a protected pipeline and an instruction-fetch mechanism that attempts to keep the pipeline full.
Interrupts are hardware- or software-driven events that cause the CPU to suspend its current program sequence and execute a subroutine called an interrupt service routine. Interrupts are described in detail in Chapter 3.
2.5.2Branches, Calls, and Returns
Branches, calls, and returns break the sequential flow of instructions by transferring control to another location in program memory. A branch only transfers
control to the new location. A call also saves the return address (the address
of the instruction following the call). Called subroutines or interrupt service routines are each concluded with a return instruction, which takes the return address from the stack or from XAR7 or RPC and places it into the program
counter (PC).
The following branch instructions are conditional: B, BANZ, BAR, BF, SB, SBF,
XBANZ, XCALL, and XRETC. They are executed only if a certain specified or
predefined condition is met. For detailed descriptions of these instructions,
see Chapter 6, Assembly Language Instructions.
2.5.3Repeating a Single Instruction
The repeat (RPT) instruction allows the execution of a single instruction
(N + 1) times, where N is specified as an operand of the RPT instruction. The
instruction is executed once and then repeated N times. When RPT is
executed, the repeat counter (RPTC) is loaded with N. RPTC is then decremented every time the repeated instruction is executed, until RPTC equals 0. For
a description of RPT and a list of repeatable instructions, see Chapter 6, As-sembly Language Instructions.
2-39Central Processing Unit
Page 70
Program Flow
2.5.4Instruction Pipeline
Each instruction passes through eight independent phases that form an
instruction pipeline. At any given time, up to eight instructions may be active,
each in a different phase of completion. Not all reads and writes happen in the
same phases, but a pipeline-protection mechanism stalls instructions as
needed to ensure that reads and writes to the same location happen in the order in which they are programmed.
To maximize pipeline efficiency, an instruction-fetch mechanism attempts to
keep the pipeline full. Its role is to fill an instruction-fetch queue, which holds
instructions in preparation for decoding and execution. The instruction-fetch
mechanism fetches 32-bits at a time from program memory; it fetches one
32-bit instruction or two 16-bit instructions.
The instruction-fetch mechanism uses three program-address counters: the
program counter (PC), the instruction counter (IC), and the fetch counter (FC).
When the pipeline is full the PC will always point to the instruction in its
decode 2 pipeline phase. The IC points to the next instruction to be processed.
When the PC points to a 1-word instruction, IC = (PC+1); when the PC points
to a 2-word instruction, IC = (PC+2). The value in the FC is the address from
which the next fetch is to be made.
The pipeline and the instruction-fetch mechanism are described in more detail
in Chapter 4, Pipeline.
2-40
Page 71
2.6Multiply Operations
The C28x features a hardware multiplier that can perform 16-bit X 16-bit or
32-bit X 32-bit fixed-point multiplication. This functionality is enhanced by
16-bit X 16-bit multiply and accumulate (MAC), 32 X 32 MAC, and
16-bit X 16-bit dual MAC (DMAC) instructions. This section describes the components involved in each type of multiplication.
2.6.116-bit X 16-bit Multiplication
The C28x multiplier can perform a 16-bit X 16-bit multiplication to produce a
signed or unsigned 32-bit product. Figure 2−12 shows the CPU components
involved in this multiplication.
The multiplier accepts two 16-bit inputs:
- One input is from the upper 16 bits of the multiplicand register (T). Most
16 X 16 multiplication instructions require that you load T from a datamemory location or a register before you execute the instruction. However, the MAC and some versions of the MPY and MPYA instructions load
T for you before the multiplication.
Multiply Operations
- The other input is from one of the following:
J A data-memory location or a register (depending on which you specify
in the multiply instruction).
J An instruction opcode. Some C28x multiply instructions allow you to
include a constant as an operation.
After the value has been multiplied by the second value, the 32-bit result is
stored in one of two places, depending on the particular multiply instruction:
the 32-bit product register (P) or the 32-bit accumulator (ACC).
One special 16-bit X 16-bit multiplication instruction takes two 32-bit input values as its operands. This instruction is the 16 X 16 DMAC instruction, which
performs dual 16 X 16 MAC operations in one instruction. In this case, the ACC
contains the result of multiplying and adding the upper word of the 32-bit operands. The P register contains the result of multiplying and adding the results
of the lower word of the 32-bit operands.
2-41Central Processing Unit
Page 72
Multiply Operations
Figure 2−12. Conceptual Diagram of Components Involved in 16 X16-Bit Multiplication
From data memory or a register
16
From data memory or a register
From an instruction opcode
16
16
T
1616
P
2.6.232-Bit X 32-Bit Multiplication
The C28x multiplier can also perform 32-bit by 32-bit multiplication.
Figure 2−13 shows the CPU components involved n this multiplication.
In this case, the multiplier accepts two 32-bit inputs:
- The first input is from one of the following:
32
MUX
Multiplier
32
MUX
32
ACC
J A program memory location. Some C28x 32 X 32 multiply MAC-type
instructions such as IMACL and QMACL take one data value directly
from memory using the program-address bus.
J The 32-bit multiplicand register (XT). Most 32 X 32-bit multiplication
instructions require that you load XT from data memory or a register
before you execute the instruction.
- A data-memory location or a register (depending on which you specify in
the multiply instruction).
After the two values have ben multiplied, 32 bits of the 64-bit result are stored
in the product register (P). You can control which half is stored (upper 32 bits
or lower 32 Bits) and whether the multiplication is signed or unsigned by the
instruction used.
2-42
Page 73
Multiply Operations
If you need support for larger data values, the 32 X 32 multiplication instructions can be combined to implement 32 X 32 = 64-bit or 64 X 64 = 128-bit math.
Figure 2−13. Conceptual Diagram of Components Involved in 32 X 32-Bit Multiplication
From data memory
or register
32
XT
From
program
memory
32
MUX
32
From data
memory or register
3232
upper 32
Multiplier
lower 32
MUX
32
P
2-43Central Processing Unit
Page 74
Shift Operations
2.7Shift Operations
The shifter holds 64 bits and accepts either a 16-bit, 32-bit, or 64-bit input
value. When the input value has 16 bits, the value is loaded into the 16 least
significant bits (LSBs) of the shifter. When the input value has 32 bits, the value
is loaded into the 32 LSBs of the shifter. Depending on the instruction that uses
the shifter, the output of the shifter may be all of its 64 bits or just its 16 LSBs.
When a value is shifted right by an amount N, the N LSBs of the value are lost
and the bits to the left of the value are filled with all 0s or all 1s. If sign extension
is specified, the bits to the left are filled with copies of the sign bit. If sign extension is not specified, the bits to the left are filled with 0s, or zero filled.
When a value is shifted left by an amount N, the bits to the right of the shifted
value are zero filled. If the value has 16 bits and sign extension is specified,
the bits to the left are filled with copies of the sign bit. If the value has 16 bits
and sign extension is not specified, the bits to the left are zero filled. If the value
has 32 bits, the N MSBs of the value are lost, and sign extension is irrelevant.
Table 2−11 lists the instructions that use the shifter and provides an illustration
of the corresponding shifter operation. The table uses the following graphical
symbols:
Shift left
0
Sign
SXM
0/Sign
C
This symbol represents the 32-bit shifter. The text
inside the box indicates the direction of the shift.
This symbol indicates zero filling.
This symbol indicates sign extending.
This symbol indicates that the MSBs of the shifter
depend on the sign-extension mode bit (SXM). If
SXM = 0, the MSBs are zero filled after the shift. If
SXM = 1, the MSBs are filled with the sign of the
shifted value.
This symbol indicates the carry bit (C).
For explanations of the instruction syntaxes listed in Table 2−11, see
Chapter 6, Assembly Language Instructions.
2-44
Page 75
Table 2−11.Shift Operations
Operation TypeIllustration
Shift Operations
Left shift of 16-bit value for ACC
operation. Syntaxes:
ADD ACC, loc16 << 0...16
ADD ACC, #16Bit <<0...15
ADD ACC, loc16 <<T
SUB ACC, loc16 << 0...16
SUB ACC, #16Bit <<0 ...15
SUB ACC, loc16<<T
MOV ACC, loc16 << 0...16
MOV ACC, #16Bit <<0...15
MOV ACC, loc16, <<T
Store 16 LSBs of left-shifted ACC.
Syntax:
MOV loc16, ACC << 1...8
Store 16 MSBs of left-shifted ACC.
Syntax:
MOVH loc16, ACC <<1...8
Note: This instruction performs a single
right shift by (16−shift1), where shift1 is a
value from 0 to 8.
SXM
0/Sign
Discard
16-bit value to 16 LSBs
Shift left
32 bits to ALU
ACC
Shift left
16 LSBs to ALU
ACC
Shift right
16 LSBs to ALU
0
0
Discard
Logical left shift of ACC. The last bit to
be shifted out fills the carry bit (C).
Syntaxes:
LSL ACC, 1...16
LSL ACC, T (shift = T(3:0))
LSL ACC, T (shift = T(4:0))
Note: If T(3:0) = 0 or T(4:0) = 0, indicating
a shift of 0, C is cleared.
Last
bit out
Discard
other bits
ACC
C
Shift left
32 bits to ACC
0
2-45Central Processing Unit
Page 76
Shift Operations
Table 2−11.Shift Operations (Continued)
Operation TypeIllustration
Logical left shift of AH or AL. The last
bit to be shifted out fills the carry bit (C).
Syntaxes:
LSL AX, 1...16
LSL AX, T (shift = T(3:0))
Note: If T(3:0) = 0, indicating a shift of 0,
C is cleared.
Right shift of ACC. If SXM = 0, a logical
shift is performed. If SXM = 1, an
arithmetic shift is performed. The last bit
to be shifted out fills the carry bit (C).
Syntaxes:
SFR ACC, 1...16
SFR ACC, T
Note: If T(3:0) = 0, indicating a shift of 0,
C is cleared.
Logical right shift of AH or AL. The last
bit to be shifted out fills the carry bit (C).
Syntaxes:
LSR AX, shift
LSR AX, T (shift = T(3:0))
ARLACC, T (shift = T(4:0)
Note: If T(4:0) = 0, indicating a shift of 0,
C is cleared.
Last
bit out
0/Sign
SXM
AH/AL to 16 LSBs
C
Shift left
16 LSBs to AH/AL
ACC
Shift right
32 bits to ACC
AH/AL to 16 LSBs
0
Shift right
16 LSBs to AH/AL
0
Last
C
bit out
Discard
other bits
Last
C
bit out
Discard
other bits
Arithmetic right shift of AH or AL. The
last bit to be shifted out fills the carry bit
(C). Syntaxes:
ASR AX, shift
ASR AX, T
Note: If T(4:0) = 0, indicating a shift of 0,
C is cleared.
Rotate ACC left by 1 bit. Bit 31 of ACC
fills the carry bit (C). C fills bit 0 of ACC.
Syntax:
ROLACC
2-46
Sign
AH/AL to 16 LSBs
Last
C
Shift right
16 LSBs to AH/AL
ACC
C
Rotate left
32 bits to ACC
bit out
Discard
other bits
Page 77
Table 2−11.Shift Operations (Continued)
Operation TypeIllustration
Shift Operations
Rotate ACC right by 1 bit. Bit 0 of ACC
fills the carry bit (C). C fills bit 31 of ACC.
Syntax:
ROR ACC
Logical right shift of ACC:P.
Syntaxes:
LSR64 ACC:P, 1...16
LSR64, ACC:P, T shift = T(5:0)
Logical left shift of ACC:P.
Syntaxes:
LSL64 ACC:P, 1...16
LSL64 ACC:P, T shift = T(5:0)
Arithmetic right shift of ACC:P.
Syntaxes:
ASR64 ACC:P, 1...16
ASR64, ACC:P, T shift = T(5:0)
Last
bit out
Discard
other bits
Sign
ACC
Rotate right
32 bits to ACC
ACC:P
0
C
Shift right
64 bits to ACC:P
ACC:P
Shift left
64 bits to ACC:P
ACC:P
Shift right
64 bits to ACC:P
C
Last
C
bit out
Discard
other bits
0
Last
C
bit out
Discard
other bits
Conditional shift of ACC by 1 bit.
Syntaxes:
NORM ACC, aux++
NORM ACC, aux−−
SUBCU ACC, loc
Discard
ACC
Shift left
32 bits to ACC
0
2-47Central Processing Unit
Page 78
Shift Operations
Table 2−11.Shift Operations (Continued)
Operation TypeIllustration
Shift of P as per PM bits. Syntaxes:
ADD ACC, P
SUB ACC, P
CMP ACC, P
MAC P, loc, 0:pmem
MOV ACC, P
MOVA T, loc
MOVP T, loc
MOVS T, loc
MPYA P, loc, #16BitSigned
MPYA P, T, loc
MPYS P, T, loc
For PM = 0:
Discard
For PM = 1: No shift
For PM from 2−7:
Sign
P
Shift left
32 bits to ALU
P
Shift right
32 bits to ALU
0
Discard
2-48
Page 79
Table 2−11.Shift Operations (Continued)
Operation TypeIllustration
Shift Operations
Store 16 LSBs of shifted P. P is shifted
as per the PM bits. The 16 LSBs of shifter
are stored. Syntax:
MOV loc16, P
Store 16 MSBs of shifted P. P is shifted
as per the PM bits. The result is shifted
right by 16 so that its 16 MSBs are in the
16 LSBs of the shifter. 16 LSBs of shifter
are stored. Syntax:
MOVH loc16, P
For PM = 0:
Discard
For PM = 1: No shift
For PM from 2−7:
Sign
For PM = 0:
1)
Discard
2)
P
Shift left
16 LSBs to ALU
P
Shift right
16 LSBs to ALU
P
Shift left
Shift right by 16
0
Discard
0
Discard
For PM = 1: No shift
For PM from 2−7:
1)
2)
Sign
16 LSBs to ALU
P
Shift right
Shift right by 16
16 LSBs to ALU
Discard
Discard
2-49Central Processing Unit
Page 80
This page intentionally left blank.
This page intentionally left blank.
2-50
Page 81
Chapter 3
CPU Interrupts and Reset
This chapter describes the available CPU interrupts and how they are handled
by the CPU. It also explains how to control those interrupts that can be controlled through software. Finally, it describes how a hardware reset affects the
CPU.
Interrupts are hardware- or software-driven signals that cause the C28x CPU
to suspend its current program sequence and execute a subroutine. Typically,
interrupts are generated by peripherals or hardware devices that need to give
data to or take data from the C28x (for example, A/D and D/A converters and
other processors). Interrupts can also signal that a particular event has taken
place (for example, a timer has finished counting).
On the C28x, interrupts can be triggered by software (the INTR, OR IFR, or
TRAP instruction) or by hardware (a pin, an external peripheral, or on-chip
peripheral/logic). If hardware interrupts are triggered at the same time, the
C28x services them according to a set priority ranking.
Some 28x devices include a peripheral interrupt expansion (PIE) module that
multiplexes interrupts from a number of peripherals into a single CPU interrupt.
The PIE module provides additional control before an interrupt reaches the
C28x CPU. See the TMS320C8x System and Interrupts Reference Guide
(literature number SPRU078) for more details.
At the CPU level, each of the C28x interrupts, whether hardware or software,
can be placed in one of the following two categories:
- Maskable interrupts.These are interrupts that can be blocked (masked)
or enabled (unmasked) through software.
- Nonmaskable interrupts. These interrupts cannot be blocked. The C28x
will immediately approve this type of interrupt and branch to the corresponding subroutine. All software-initiated interrupts are in this category.
The C28x handles interrupts in four main phases:
1) Receive the interrupt request. Suspension of the current program sequence must be requested by a software interrupt (from program code) or
a hardware interrupt (from a pin or an on-chip device).
2) Approve the interrupt. The C28x must approve the interrupt request. If
the interrupt is maskable, certain conditions must be met in order for the
C28x to approve it. For nonmaskable hardware interrupts and for software
interrupts, approval is immediate.
3) Prepare for the interrupt service routine and save register values.
The main tasks performed in this phase are:
- Complete execution of the current instruction and flush from the pipe-
line any instructions that have not reached the decode 2 phase.
- Automatically save most of the current program context by saving the
following registers to the stack: ST0, T, AL, AH, PL, PH, AR0, AR1, DP,
ST1, DBGSTAT, PC, and IER.
3-2
Page 83
CPU Interrupts Overview
Fetch the interrupt vector and load it into the program counter (PC).
-
For devices with a PIE module, the vector fetched will depend on the
setting of the PIE enable and flag registers.
4) Execute the interrupt service routine. The C28x branches to its corresponding subroutine called an interrupt service routine (ISR). The C28x
branches to the address (vector) you store at a predetermined vector location and executes the ISR you have written.
3-3CPU Interrupts and Reset
Page 84
CPU Interrupt Vectors and Priorities
Á
Hard
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
3.2CPU Interrupt Vectors and Priorities
The C28x supports 32 CPU interrupt vectors, including the reset vector. Each
vector is a 22-bit address that is the start address for the corresponding interrupt service routine (ISR). Each vector is stored in 32 bits at two consecutive
addresses. The location at the lower address holds the 16 least significant bits
(LSBs) of the vector. The location at the higher address holds the 6 most significant bits (MSBs) right-justified. When an interrupt is approved, the 22-bit vector is fetched, and the 10 MSBs at the higher address are ignored.
For devices with a PIE module, this table is re-mapped and expanded into the
PIE vector table.
Table 3−1 lists the available CPU interrupt vectors and their locations. The addresses are shown in hexadecimal form. The table also shows the priority of
each of the hardware interrupts.
Table 3−1. Interrupt Vectors and Priorities
ББББББББББББББББББББББББББББ
Vector
RESET
Absolute Address (hexadecimal)
VMAP = 0
00 0000
VMAP = 1
3F FFC0
†
ware
Priority
1 (highest)
Description
Reset
INT1
INT2
ÁÁÁ
INT3
ÁÁÁ
INT4
INT5
INT6
INT7
ÁÁÁ
INT8
INT9
INT10
INT11
INT12
ÁÁÁ
INT13
INT14
†
For C28x catalog devices, VMAP = 1 at reset.
‡
Interrupts DLOGINT and RTOSINT are generated by the emulation logic internal to the CPU.
00 0002
00 0004
ÁÁÁÁ
00 0006
ÁÁÁÁ
00 0008
00 000A
00 000C
00 000E
ÁÁÁÁ
00 0010
00 0012
00 0014
00 0016
00 0018
ÁÁÁÁ
00 001A
00 001C
3F FFC2
3F FFC4
БББББ
3F FFC6
БББББ
3F FFC8
3F FFCA
3F FFCC
3F FFCE
БББББ
3F FFD0
3F FFD2
3F FFD4
3F FFD6
3F FFD8
БББББ
3F FFDA
3F FFDC
5
6
ÁÁÁÁ
7
ÁÁÁÁ
8
9
10
11
ÁÁÁÁ
12
13
14
15
16
ÁÁÁÁ
17
18
Maskable interrupt 1
Maskable interrupt 2
ББББББББ
Maskable interrupt 3
ББББББББ
Maskable interrupt 4
Maskable interrupt 5
Maskable interrupt 6
Maskable interrupt 7
ББББББББ
Maskable interrupt 8
Maskable interrupt 9
Maskable interrupt 10
Maskable interrupt 11
Maskable interrupt 12
ББББББББ
Maskable interrupt 13
Maskable interrupt 14
3-4
Page 85
Table 3−1. Interrupt Vectors and Priorities (Continued)
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
Á
CPU Interrupt Vectors and Priorities
Vector
Vector
DLOGINT
RTOSINT
ÁÁÁ
Reserved
ÁÁÁ
NMI
ILLEGAL
USER1
USER2
USER3
ÁÁÁ
USER4
USER5
USER6
USER7
USER8
ÁÁÁ
USER9
Absolute Address (hexadecimal)
VMAP = 0
‡
‡
00 001E
00 0020
ÁÁÁÁ
00 0022
ÁÁÁÁ
00 0024
00 0026
00 0028
00 002A
00 002C
ÁÁÁÁ
00 002E
00 0030
00 0032
00 0034
00 0036
ÁÁÁÁ
00 0038
VMAP = 1
†
3F FFDE
3F FFE0
ÁÁÁÁ
3F FFE2
ÁÁÁÁ
3F FFE4
3F FFE6
3F FFE8
3F FFEA
3F FFEC
ÁÁÁÁ
3F FFEE
3F FFF0
3F FFF2
3F FFF4
3F FFF6
ÁÁÁÁ
3F FFF8
Hardware
Hardware
Priority
Priority
19 (lowest)
БББББ
БББББ
4
2
3
−
−
−
БББББ
−
−
−
−
−
БББББ
−
−
Description
Description
Maskable data log interrupt
Maskable real-time operating
ББББББББ
system interrupt
Reserved
ББББББББ
Nonmaskable interrupt
Illegal-instruction trap
User-defined software interrupt
User-defined software interrupt
User-defined software interrupt
ББББББББ
User-defined software interrupt
User-defined software interrupt
User-defined software interrupt
User-defined software interrupt
User-defined software interrupt
ББББББББ
User-defined software interrupt
USER10
USER11
USER12
†
For C28x catalog devices, VMAP = 1 at reset.
ББББББББББББББББББББББББББББ
‡
Interrupts DLOGINT and RTOSINT are generated by the emulation logic internal to the CPU.
00 003A
00 003C
00 003E
3F FFFA
3F FFFC
3F FFFE
−
−
−
User-defined software interrupt
User-defined software interrupt
User-defined software interrupt
The vector table can be mapped to the top or bottom of program space, depending on the value of the vector map bit (VMAP) in status register ST1. (ST1
is described in section 2.4 on page 2-34.) If the VMAP bit is 0, the vectors are
mapped beginning at address 00 0000
mapped beginning at address 3F FFC0
. If the VMAP bit is 1, the vectors are
16
. Table 3−1 lists the absolute ad-
16
dresses for VMAP = 0 and VMAP = 1.
The VMAP bit can be set by the SETC VMAP instruction and cleared by the
CLRC VMAP instruction. The reset value of VMAP is 1.
3-5CPU Interrupts and Reset
Page 86
Maskable Interrupts: INT1−INT14, DLOGINT, and RTOSINT
3.3Maskable Interrupts: INT1−INT14, DLOGINT, and RTOSINT
INT1−INT14 are 14 general-purpose interrupts. DLOGINT (the data log interrupt) and RTOSINT (the real-time operating system interrupt) are available for
emulation purposes. These interrupts are supported by three dedicated registers: the CPU interrupt flag register (IFR), the CPU interrupt enable register
(IER), and the CPU debug interrupt enable register (DBGIER).
The 16-bit IFR contains flag bits that indicate which of the corresponding interrupts are pending (waiting for approval from the CPU). The external input lines
−INT14 are sampled at every CPU clock cycle. If an interrupt signal is rec-
INT1
ognized, the corresponding bit in the IFR is set and latched. For DLOGINT or
RTOSINT, a signal sent by the CPU on-chip analysis logic causes the corresponding flag bit to be set and latched. You can set one or more of the IFR bits
at the same time by using the OR IFR instruction. More details about the IFR
are given in section 3.3.1. The on-chip analysis resources are introduced in
Chapter 7.
The interrupt enable register (IER) and the debug interrupt enable register
(DBGIER) each contain bits for individually enabling or disabling the maskable
interrupts. To enable one of the interrupts in the IER, you set the corresponding
bit in the IER; to enable the same interrupt in the DBGIER, you set the corresponding bit in the DBGIER. The DBGIER indicates which interrupts can be
serviced when the CPU is in the real-time emulation mode. The IER and the
DBGIER are discussed more in section 3.3.2. Real-time mode is discussed in
section 7.4.2 on page 7-9.
The maskable interrupts also share bit 0 in status register ST1. This bit, the
interrupt global mask bit (INTM), is used to globally enable or globally disable
these interrupts. When INTM = 0, these interrupts are globally enabled. When
INTM = 1, these interrupts are globally disabled. You can set and clear INTM
with the SETC INTM and CLRC INTM instructions, respectively. ST1 is described in section 2.4 on page 2-34.
After a flag has been latched in the IFR, the corresponding interrupt is not serviced until it is appropriately enabled by two of the following: the IER, the
DBGIER, and the INTM bit. As shown in Table 3−2, the requirements for enabling the maskable interrupts depend on the interrupt-handling process used.
In the standard process, which occurs in most circumstances, the DBGIER is
ignored. When the C28x is in real-time emulation mode and the CPU is halted,
a different process is used. In this special case, the DBGIER is used and the
INTM bit is ignored. (If the DSP is in real-time mode and the CPU is running,
the standard interrupt-handling process applies.)
3-6
Page 87
Maskable Interrupts: INT1−INT14, DLOGINT, and RTOSINT
Once an interrupt has been requested and properly enabled, the CPU prepares for and then executes the corresponding interrupt service routine. For
a detailed description of this process, see section 3.4.
Table 3−2. Requirements for Enabling a Maskable Interrupt
Interrupt-Handling ProcessInterrupt Enabled If ...
StandardINTM = 0 and bit in IER is 1
DSP in real-time mode and CPU haltedBit in IER is 1 and bit in DBGIER is 1
As an example of varying interrupt-enable requirements, suppose you want
interrupt INT5
enabled. This corresponds to bit 4 in the IER and bit 4 in the
DBGIER. Usually, INT5 is enabled if INTM = 0 and IER(4) = 1. In real-time
emulation mode with the CPU halted, INT5
DBGIER(4) = 1.
3.3.1CPU Interrupt Flag Register (IFR)
Figure 3−1 shows the IFR. If a maskable interrupt is pending (waiting for approval from the CPU), the corresponding IFR bit is 1; otherwise, the IFR bit is
0. To identify pending interrupts, use the PUSH IFR instruction and then test
the value on the stack. Use the OR IFR instruction to set IFR bits, and use the
AND IFR instruction to clear pending interrupts. When a hardware interrupt is
serviced, or when an INTR instruction is executed, the corresponding IFR bit
is cleared. All pending interrupts are cleared by the AND IFR, #0 instruction
or by a hardware reset.
is enabled if IER(4) = 1 and
Notes:
When an interrupt is requested by the TRAP instruction, if the corresponding
IFR bit is set, the CPU does not clear it automatically. If an application requires that the IFR bit be cleared, the bit must be cleared in the interrupt service routine.
Figure 3−1. Interrupt Flag Register (IFR)
15
RTOSINT
R/W−0
7
INT8
R/W−0
Note:R = Read access; W = Write access; value following dash (−) is value after reset.
14
DLOGINT
R/W−0
6
INT7
R/W−0
13
INT14
R/W−0
5
INT6
R/W−0
12
INT13
R/W−0
4
INT5
R/W−0
11
INT12
R/W−0
3
INT4
R/W−0
INT11
R/W−0
R/W−0
10
2
INT3
9
INT10
R/W−0
1
INT2
R/W−0
8
INT9
R/W−0
0
INT1
R/W−0
3-7CPU Interrupts and Reset
Page 88
Maskable Interrupts: INT1−INT14, DLOGINT, and RTOSINT
Bits 15 and 14 of the IFR correspond to the interrupts RTOSINT and DLOGINT:
RTOSINTReal-time operating system interrupt flag
Bit 15RTOSINT = 0RTOSINT is not pending.
RTOSINT = 1RTOSINT is pending.
DLOGINTData log interrupt flag
Bit 14DLOGINT = 0DLOGINT is not pending.
DLOGINT = 1DLOGINT is pending.
For bits INT1−INT14, the following general description applies:
INTxInterrupt x flag (x = 1, 2, 3, ..., or 14)
Bit (x−1)INTx = 0INTx
INTx = 1INTx
3.3.2CPU Interrupt Enable Register (IER) and
CPU Debug Interrupt Enable Register (DBGIER)
Figure 3−2 shows the IER. To enable an interrupt, set its corresponding bit to
1. To disable an interrupt, clear its corresponding bit to 0. Two syntaxes of the
MOV instruction allow you to read from the IER and write to the IER. In addition, the OR IER instruction enables you to set IER bits, and the AND IER
instruction enables you to clear IER bits. When a hardware interrupt is serviced, or when an INTR instruction is executed, the corresponding IER bit is
cleared. At reset, all the IER bits are cleared to 0, disabling all the corresponding interrupts.
Note:
When an interrupt is requested by the TRAP instruction, if the corresponding
IER bit is set, the CPU does not clear it automatically. If an application requires that the IER bit be cleared, the bit must be cleared in the interrupt service routine.
is not pending.
is pending.
3-8
Page 89
Maskable Interrupts: INT1−INT14, DLOGINT, and RTOSINT
Figure 3−2. Interrupt Enable Register (IER)
15
RTOSINT
R/W−0
7
INT8
R/W−0
Note:R = Read access; W = Write access; value following dash (−) is value after reset.
14
DLOGINT
R/W−0
6
INT7
R/W−0
13
INT14
R/W−0
5
INT6
R/W−0
12
INT13
R/W−0
4
INT5
R/W−0
11
INT12
R/W−0
3
INT4
R/W−0
10
INT11
R/W−0
2
INT3
R/W−0
Note:
When using the AND IER and OR IER instructions, make sure that they do
not modify the state of bit 15 (RTOSINT) unless a real-time operating system
is present.
Bits 15 and 14 of the IER enable or disable the interrupts RTOSINT and
DLOGINT:
RTOSINTReal-time operating system interrupt enable bit
Bit 15RTOSINT = 0RTOSINT is disabled.
RTOSINT = 1RTOSINT is enabled.
9
INT10
R/W−0
1
INT2
R/W−0
8
INT9
R/W−0
0
INT1
R/W−0
DLOGINTData log interrupt enable bit
Bit 14DLOGINT = 0DLOGINT is disabled.
DLOGINT = 1DLOGINT is enabled.
For bits INT1−INT14, the following general description applies:
INTxInterrupt x enable bit (x = 1, 2, 3, ..., or 14)
Bit (x−1)INTx = 0INTx
INTx = 1INTx
is disabled.
is enabled.
Figure 3−3 shows the DBGIER, which is used only when the CPU is halted in
real-time emulation mode. An interrupt enabled in the DBGIER is defined as
a time-critical interrupt. When the CPU is halted in real-time mode, the only in-
terrupts that are serviced are time-critical interrupts that are also enabled in
the IER. If the CPU is running in real-time emulation mode, the standard interrupt-handling process is used and the DBGIER is ignored.
3-9CPU Interrupts and Reset
Page 90
Maskable Interrupts: INT1−INT14, DLOGINT, and RTOSINT
Á
Á
Á
Á
Á
Á
Á
As with the IER, you can read the DBGIER to identify enabled or disabled interrupts and write to the DBGIER to enable or disable interrupts. To enable an
interrupt, set its corresponding bit to 1. To disable an interrupt, set its corresponding bit to 0. Use the PUSH DBGIER instruction to read from the DBGIER
and the POP DBGIER instruction to write to the DBGIER. At reset, all the
DBGIER bits are set to 0.
Note:R = Read access; W = Write access; value following dash (−) is value after reset.
Bits 15 and 14 of the DBGIER enable or disable the interrupts RTOSINT and
DLOGINT:
RTOSINTReal-time operating system interrupt debug enable bit
Bit 15RTOSINT = 0RTOSINT is disabled.
RTOSINT = 1RTOSINT is enabled.
DLOGINTData log interrupt debug enable bit
Bit 14DLOGINT = 0DLOGINT is disabled.
DLOGINT = 1DLOGINT is enabled.
For bits INT1−INT14, the following general description applies:
9
INT10
ÁÁ
R/W−0
1
INT2
R/W−0
8
INT9
ÁÁÁ
R/W−0
0
INT1
R/W−0
3-10
INTxInterrupt x debug enable bit (x = 1, 2, 3, ..., or 14)
Bit (x−1)INTx = 0INTx
INTx = 1INTx
is disabled.
is enabled.
Page 91
Standard Operation for Maskable Interrupts
3.4Standard Operation for Maskable Interrupts
The flow chart in Figure 3−4 shows the standard process for handling interrupts. Section 7.4.2 on page 7-9 contains information on handling interrupts
when the DSP is in real-time mode and the CPU is halted. When more than
one interrupt is requested at the same time, the C28x services them one after
another according to their set priority ranking. See the priorities in Table 3−1
on page 3-4.
Figure 3−4 is not meant to be an exact representation of how an interrupt is
handled. It is a conceptual model of the important events.
3-11CPU Interrupts and Reset
Page 92
Standard Operation for Maskable Interrupts
Figure 3−4. Standard Operation for CPU Maskable Interrupts
Interrupt request sent to CPU
Set corresponding IFR flag bit.
No
No
Interrupt enabled in
IER?
Yes
Interrupt enabled by
INTM bit?
Yes
Clear corresponding IFR bit.
Empty pipeline.
Increment and temporarily store PC.
Fetch interrupt vector.
Increment SP by 1.
Perform automatic context save.
Clear corresponding IER bit.
This sequence
protected from interrupts
Set INTM and DBGM. Clear LOOP,
EALLOW, and IDLESTAT.
Load PC with fetched vector.
Execute interrupt service routine.
Program continues
3-12
Page 93
Standard Operation for Maskable Interrupts
What following list explains the steps shown in Figure 3−4:
1) Interrupt request sent to CPU. One of the following events occurs:
- One of the pins INT1−INT14 is driven low by an external event, periph-
eral or PIE interrupt request..
- The CPU emulation logic sends to the CPU a signal for DLOGINT or
RTOSINT.
- One of the interrupts INT1−INT14, DLOGINT, and RTOSINT is initi-
ated by way of the OR IFR instruction.
2) Set corresponding IFR flag bit. When the CPU detects a valid interrupt
in step 1, it sets and latches the corresponding flag in the interrupt flag register (IFR). This flag stays latched even if the interrupt is not approved by
the CPU in step 3. The IFR is explained in detail in section 3.3.1.
3) Is the interrupt enabled in IER? Is the interrupt enabled by INTM bit?
The CPU approves the interrupt only if the following conditions are true:
- The corresponding bit in the IER is 1.
- The INTM bit in ST1 is 0.
Once an interrupt has been enabled and then approved by the CPU, no
other interrupts can be serviced until the CPU has begun executing the interrupt service routine for the approved interrupt (step 13). The IER is described in section 3.3.2. ST1 is described in section 2.4 on page 2-34.
4) Clear corresponding IFR bit. Immediately after the interrupt is approved,
its IFR bit is cleared. If the interrupt signal is kept low, the IFR register bit
will be set again. However, the interrupt is not immediately serviced again.
The CPU blocks new hardware interrupts until the interrupt service routine
(ISR) begins. In addition, the IER bit is cleared (in step 10) before the ISR
begins; therefore, an interrupt from the same source cannot disturb the
ISR until the IER bit is set again by the ISR.
5) Empty the pipeline. The CPU completes any instructions that have
reached or passed their decode 2 phase in the instruction pipeline. Any
instructions that have not reached this phase are flushed from the pipeline.
6) Increment and temporarily store PC. The PC is incremented by 1 or 2,
depending on the size of the current instruction. The result is the returnaddress, which is temporarily saved in an internal hold register. During the
automatic context save (step 9), the return address is pushed onto the
stack.
3-13CPU Interrupts and Reset
Page 94
Standard Operation for Maskable Interrupts
Á
S
Regist
7) Fetch interrupt vector. The PC is filled with the address of the appropri-
ate interrupt vector, and the vector is fetched from that location. To
determine which vector address has been assigned to each of the interrupts, see section 3.2, Interrupt Vectors, on page 3-4 or, if your device
uses a PIE module, see the System and Interrupts Reference Guide for
your specific device.
8) Increment SP by 1. The stack pointer (SP) is incremented by 1 in prepara-
tion for the automatic context save (step 9). During the automatic context
save, the CPU performs 32-bit accesses, and the CPU expects 32-bit accesses to be aligned to even addresses by the memory wrapper. Incrementing SP by 1 ensures that the first 32-bit access does not overwrite the
previous stack value.
9) Perform automatic context save. A number of register values are saved
automatically to the stack. These registers are saved in pairs; each pair
is saved in a single 32-bit operation. At the end of each 32-bit save operation, the SP is incremented by 2. Table 3−3 shows the register pairs and
the order in which they are saved. The CPU expects all 32-bit saves to be
even-word aligned by the memory wrapper. As shown in the table, the SP
is not affected by this alignment.
Table 3−3. Register Pairs Saved and SP Positions for Context Saves
ББББББББББББББББББББББББББББ
ave
Operation
†
Pairs
SP Starts at Odd Address
1 ← SP position before step 8
er
Bit 0 of Storage Address
SP Starts at Even Address
1
1stST000 ← SP position before step 8
T11
2nd
3rdPL
AL
AH
0
1
‡
00
0
1
PH11
4thAR000
AR111
5thST100
DP11
3-14
Page 95
Standard Operation for Maskable Interrupts
ББББББББББББББББББББ
ББББББББББ
ББББББББББ
Á
ББББББББББ
Á
Á
Á
Table 3−3. Register Pairs Saved and SP Positions for Context Saves (Continued)
Bit 0 of Storage Address
SP Starts at Even Address
0
1
БББББББББ
Save
Save
Operation
Operation
6th
ÁÁÁÁБББББ
†
†
Register
Register
Pairs
Pairs
IER
DBGSTAT
§
7thReturn address
SP Starts at Odd Address
0
1
ББББББББ
00
(low half)
Return address
11
(high half)
0 ← SP position after save0
11 ← SP position after save
†
All registers are saved as pairs, as shown.
‡
The P register is saved with 0 shift (CPU ignores current state of the product shift mode bits, PM, in status register 0).
§
The DBGSTAT register contains special emulation information.
10) Clear corresponding IER bit. After the IER register is saved on the stack
in step 9, the CPU clears the IER bit that corresponds to the interrupt being
handled. This prevents reentry into the same interrupt. If you want to nest
occurrences of the interrupt, have the ISR set that IER bit again.
11) Set INTM and DBGM. Clear LOOP, EALLOW, and IDLESTAT. All these
bits are in status register ST1. By setting INTM to 1, the CPU prevents
maskable interrupts from disturbing the ISR. If you wish to nest interrupts,
have the ISR clear the INTM bit. By setting DBGM to 1, the CPU prevents
debug events from disturbing time-critical code in the ISR. If you do not
want debug events blocked, have the ISR clear DBGM.
The CPU clears LOOP, EALLOW, and IDLESTAT so that the ISR operates
within a new context.
12) Load PC with fetched vector. The PC is loaded with the interrupt vector
that was fetched in step 7. The vector forces program control to the ISR.
13) Execute interrupt service routine. Here is where the CPU executes the
program code you have prepared to handle the interrupt. A typical ISR is
shown in Example 3−1.
Although a number of register values are saved automatically in step 10, if
the ISR uses other registers, you may need to save the contents of these
registers at the beginning of the ISR. These values must then be restored
before the return from the ISR. The ISR in Example 3−1 saves and re-
stores auxiliary registers AR1H:AR0H, XAR2−XAR7, and the temporary
register XT.
3-15CPU Interrupts and Reset
Page 96
Standard Operation for Maskable Interrupts
If you want the ISR to inform a peripheral that the interrupt is being serviced, you can use the IACK instruction to send an interrupt acknowledge
signal. The IACK instruction accepts a 16-bit constant as an operand. For
a detailed description of the IACK instruction, see Chapter 6, C28x As-sembly Language Instructions.
14) Program continues. If the interrupt is not approved by the CPU, the inter-
rupt is ignored, and the program continues uninterrupted. If the interrupt
is approved, its interrupt service routine is executed and the program continues where it left off (at the return address).
Nonmaskable interrupts cannot be blocked by any of the enable bits (the INTM
bit, the DBGM bit, and enable bits in the IFR, IER, or DBGIER). The C28x immediately approves this type of interrupt and branches to the corresponding
interrupt service routine. There is one exception to this rule: When the CPU
is halted in stop mode (an emulation mode), no interrupts are serviced. Stop
mode is described in section 7.4.1 on page 7-7.
The C28x nonmaskable interrupts include:
- Software interrupts (the INTR and TRAP instructions).
- Hardware interrupt NMI
- Illegal-instruction trap
- Hardware reset interrupt (RS)
Nonmaskable Interrupts
The software interrupt instructions and NMI
illegal-instruction trap and reset are described in sections 3.6 and 3.7, respectively.
3.5.1INTR Instruction
You can use the INTR instruction to initiate one of the following interrupts by
name: INT1−INT14, DLOGINT, RTOSINT and NMI. For example, you can
execute the interrupt service routine for INT1
INTRINT1
Once an interrupt is initiated by the INTR instruction, how it is handled depends
on which interrupt is specified:
- INT1−INT14, DLOGINT, and RTOSINT. These maskable interrupts have
- NMI. Because this interrupt is nonmaskable, a hardware request at a pin
are described in this section. The
by using the following instruction:
corresponding flag bits in the IFR. When a request for one of these interrupts is received at an external pin, the corresponding IFR bit is set and
the interrupt must be enabled to be serviced. In contrast, when one of
these interrupts is initiated by the INTR instruction, the IFR flag is not set,
and the interrupt is serviced regardless of the value of any enable bits.
However, in other respects, the INTR instruction and the hardware request
are the same. For example, both clear the IFR bit that corresponds to the
requested interrupt. For more details, see section 3.4 on page 3-11.
and a software request with the INTR instruction lead to the same events.
These events are identical to those that take place during a TRAP instruction (see section 3.5.2).
Chapter 6, C28x Assembly Language Instructions, contains a detailed de-
scription of the INTR instruction.
3-17CPU Interrupts and Reset
Page 98
Nonmaskable Interrupts
3.5.2TRAP Instruction
You can use the TRAP instruction to initiate any interrupt, including one of the
user-defined software interrupts (see USER1−USER12 in Table 3−1 on page
3-4). The TRAP instruction refers to one of the 32 interrupts by a number from
0 to 31. For example, you can execute the interrupt service routine for INT1
by using the following instruction:
TRAP#1
Regardless of whether the interrupt has bits set in the IFR and IER, neither the
IFR nor the IER is affected by this instruction. Figure 3−5 shows a functional
flow chart for an interrupt initiated by the TRAP instruction. For more details
about the TRAP instruction, see Chapter 6, C28x Assembly Language Instruc-tions.
Note:
The TRAP #0 instruction does not initiate a full reset. It only forces execution
of the interrupt service routine that corresponds to the RESET interrupt vector.
Figure 3−5. Functional Flow Chart for an Interrupt Initiated by the TRAP Instruction
INTM bit, IFR,
IER, and DBGIER
ignored and not affected
TRAP instruction fetched
Empty the pipeline.
Increment and temporarily store PC.
Fetch interrupt vector.
Increment SP by 1.
Perform automatic context save.
Set INTM and DBGM. Clear LOOP,
EALLOW, and IDLESTAT.
Load PC with fetched vector.
Execute interrupt service routine.
Program continues
This sequence
protected from
interrupts
3-18
Page 99
Nonmaskable Interrupts
The following lists explains the steps shown in Figure 3−5:
1) TRAP instruction fetched. The CPU fetches the TRAP instruction from
program memory. The desired interrupt vector has been specified as an
operand and is now encoded in the instruction word. At this stage, no other
interrupts can be serviced until the CPU begins executing the interrupt service routine (step 9).
2) Empty the pipeline. The CPU completes any instructions that have
reached or passed the decode 2 phase of the pipeline. Any instructions
that have not reached this phase are flushed from the pipeline.
3) Increment and temporarily store PC. The PC is incremented by 1. This
value is the return address, which is temporarily saved in an internal hold
register. During the automatic context save (step 6), the return address is
pushed onto the stack.
4) Fetch interrupt vector. The PC is set to point to the appropriate vector
location (based on the VMAP bit and the interrupt), and the vector located
at the PC address is loaded into the PC. (To determine which vector address has been assigned to each of the interrupts, see section 3.2, Inter-rupt Vectors, on page 3-4.)
5) Increment SP by 1. The stack pointer (SP) is incremented by 1 in prepara-
tion for the automatic context save (step 6). During the automatic context
save, the CPU performs 32-bit accesses, which are aligned to even addresses. Incrementing SP by 1 ensures that the first 32-bit access will not
overwrite the previous stack value.
6) Perform automatic context save. A number of register values are saved
automatically to the stack. These registers are saved in pairs; each pair
is saved in a single 32-bit operation. At the end of each 32-bit operation,
the SP is incremented by 2. Table 3−3 shows the register pairs and the order in which they are saved. All 32-bit saves are even-word aligned. As
shown in the table, the SP is not affected by this alignment.
3-19CPU Interrupts and Reset
Page 100
Nonmaskable Interrupts
S
Regist
Á
Á
Á
Á
Á
Á
Table 3−4. Register Pairs Saved and SP Positions for Context Saves
ave
Operation
†
Pairs
SP Starts at Odd Address
1 ← SP position before step 5
er
Bit 0 of Storage Address
SP Starts at Even Address
1
1stST000 ← SP position before step 5
T11
2nd
ÁÁÁÁÁÁÁÁÁ
3rdPL
AL
AH
0
1
БББББББББ
‡
00
0
1
ББББББББ
PH11
4thAR000
AR111
5thST100
DP11
6th
ÁÁÁÁÁÁÁÁÁ
7thReturn address
IER
DBGSTAT
0
§
1
БББББББББ
0
1
ББББББББ
00
(low half)
Return address
11
(high half)
0 ← SP position after save0
11 ← SP position after save
†
All registers are saved as pairs, as shown.
‡
The P register is saved with 0 shift (CPU ignores current state of the product shift mode bits, PM, in status register 0).
§
The DBGSTAT register contains special emulation information.
7) Set INTM and DBGM. Clear LOOP, EALLOW, and IDLESTAT. All these
bits are in status register ST1 (described in section 2.4 on page 2-34). By
setting INTM to 1, the CPU prevents maskable interrupts from disturbing
the ISR. If you wish to nest interrupts, have the ISR clear the INTM bit. By
setting DBGM to 1, the CPU prevents debug events from disturbing timecritical code in the ISR. If you do not want debug events blocked, have the
ISR clear DBGM.
3-20
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.