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
application s 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 form 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 decep tive 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.com
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
Audiowww.ti.com/audio
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 2005, Texas Instruments Incorporated
REVISION HISTORY
REVISIONDATENOTES
E8/05Page 16, Baud Rate Limitations section added
Page 24, information on slave prescale baud rate added
Page 27, note on clearing SPIBUF added
This reference guide provides the specifications for a 16-bit configurable
synchronous serial peripheral interface (SPI). The SPI is in effect a
programmable-length shift register used for high speed communication
between external peripherals or other microcontroller s.
The SPI is a high-speed sync hronous serial input/output port that allows a
serial bit stream of programmed length (3 to 16 bits) to be shif ted into and out
of the device at a programmed bit-transfer rate . The SPI i s nor mally use d for
communication between the microcontroller and external peripherals or
another microcontroller. Typical applications include interface to external I/O
or peripheral expansion via devices such as shift registers, display drivers,
and analog-to-digital converters.
The SPI is available with three, four or five pins. The pins SPICLK, SPISIMO
and SPISOMI are used in all SPI pin modes. The pins SPIENA
and SPISCS
are optional and may be used if the pin are pres en t on a give n de vice .
The SPI has the following attributes:
The SPI allows software to program the following options:
❏ SPISOMI/SPISIMO pin direction configuration
❏ SPICLK pin source (external/internal)
❏ SPICLK frequency (interface clock [ICLK] /2 through /256)
❏ SPI pins as functional or digital I/O pins
❏ Character length (3 to 16 bits)
❏ Phase (delay/no delay)
❏ Polarity (high or low).
Note: Maximum Input Frequency
The maximum input frequency on the SPICLK pin when in sla ve mode is th e
ICLK frequency /2.
2
2SPI Operation Modes
The SPI operates in a master or slave mode. The MASTER bit (SPICTRL2.3)
selects the configuration of the SPISIMO and SPISOMI pins and the
CLKMOD bit (SPICTRL2.5) determines whether an internal or external clock
source will be used.
SPI Operation Modes
The slave chip select (SPISCS
) pin is used when communicating with
multiple slave devices. When the mas ter (SP I sending ou t the cloc k stream)
writes to SPIDAT1, the SPISCS
pin is automatically driven low to select the
slave connected to that signal. Writing to SPIDAT0 will not drive SPISCS
thus allowing the master to communicate with all slave devices connected to
the same SPI bus.
In addition, a handshaking mechanism, provided by the SPIENA
the slave to delay the generation of the clock signal supplied by the master
as long as it is not prepared for the next exchange of data.
Serial Peripheral Interface (SPI) Module (SPNU195E)3
SPICTRL2.5
SPI Operation Modes
2.1SPI Internal Registers
A general representation of th e SPI internal registers is shown in Table 1. The
page column provides a cross reference to additional information on the
individual registers. For more information regarding individual bytes, see
Table , on page 20.
Table 1.SPI Internal Registers
Offset
Address
†
MnemonicNameDescriptionPage
0x00SPICTRL1SPI Control Register 1Sets transfer rate and character length
0x04SPICTRL2SPI Control Register 2Controls SPI clock
0x08SPICTRL3SPI Control Register 3Controls system interface
0x20SPIPC2SPI Pin Control Register 2Reflects the values on the I/O pins
0x24SPIPC3SPI Pin Control Register 3Controls the values sent to the I/O pins
Shift register used in automatic slave chip
select mode only
Mirror of SPIBUF. Read does not clear
flags
Controls the direction of data on the I/O
pins
24
26
28
30
31
32
34
35
37
39
0x28SPIPC4SPI Pin Control Register 4Sets data values in the SPIPC3 register
0x2CSPIPC5SPI Pin Control Register 5Clears values in the SPIPC3 register
0x30SPIPC6SPI Pin Control Register 6
† The actual address of these registers is device specific and CPU specific. See the specific device data sheet to verify the
SPI register addresses.
4
Determines if pins will operate as general
I/O or SPI functional pin.
41
43
45
2.2SPI Operation; Three-Pin Option
In master mode configuration (M ASTER = 1 (SPICTRL2.3) and CLKMOD =
1 (SPICTRL2.5)), the SPI provides the serial clock on the SPICLK pin for the
entire serial communications network. Data is output on the SPISIMO pi n and
latched in from the SPISOMI pin (see Figure 2).
Figure 2.SPI Three Pin Option
SPI Operation Modes
Master
(Master = 1 ; CLKMOD = 1)
SPISIMO
SPISOMI
MSB
SPIDAT0SPIDAT0
Write to
SPIDAT0
LSB
SPICLK
Write to SPIDAT
SPICLK
SIMO
SOMI
SPI three pin option
Slave
(Master = 0 ; CLKMOD = 0)
SPISIMO
SPISOMI
MSBLSB
SPICLK
Data written to the shift register (SPIDAT0) initiates data transmission on the
SPISIMO pin, most significant bit (MSB) first. Simultaneously, received data
is shifted through the SPISOMI pin into the least significant bit (LSB) of the
SPIDAT0 register. When the selected number of bits has been transmitted,
the data is transferred to the SPI BUF register for the CPU to read. Data is
stored right-justified in SPIBUF.
When the specified number of bits has been shifted through the SPIDAT0
register, the following events occur:
❏ The RXINTFLAG bit (SPICTRL3.0) is set to 1
❏ The SPIDAT0 register contents transfer to the SPIBUF register
❏ An interrupt is asserted if the RXINTEN bit (SPICTRL3.1) is set to 1
In slave mode configuration (MASTER = 0 and CLKMOD = 0), da ta shif ts out
on the SPISOMI pin and in on the SPISIMO pin. The SPICLK pin is used as
Serial Peripheral Interface (SPI) Module (SPNU195E)5
SPI Operation Modes
the input for the serial shift clock, which is supplied fr om the external network
master. The transfer rate is defined by this clock.
Data written to the SPIDAT0 register is transmitted to the network when the
SPICLK signal is received from the network master. To receive data, the SPI
waits for the network master to send the SPICLK signal and then shifts data
on the SPISIMO pin into the SPIDAT0 register. If data is to be transmitted by
the slave simultaneously, it must be written to the SPIDAT0 register before
the beginning of the SPICLK signal.
6
2.3SPI Operation; Four-Pin Option
The three-pin option and the fo ur-pin options of the SPI are identic al in the
master mode (CLKMOD = 1), except that the four-pin option uses either
SPIENA
or SPISCS pin. The I/O direction of these p ins is de te rm in ed by the
CLKMOD control bit as SPI not general purpose I/O.
4-pin option with SPISCS
To use the SPISCS as an automatic chip select pin, the SPISCS pin must be
configured to be functional (SPIPC6.4 = 1). In this mode, the master will drive
this signal low when data has been written to SPIDAT1 and then drive the pin
high again after a character transmission has completed. If data is written to
SPIDAT0, SPISCS
remains high (see Figure 3).
Figure 3.SPI Four Pin Option with SPISCS
SPI Operation Modes
Master
(Master = 1 ; CLKMOD = 1)
SPISIMO
SPISOMI
MSB
SPIDAT1SPIDAT0
Write to
SPIDAT1
SPICSCS
LSBMSB
SPICLK
SPISCS
Write to SPIDAT1
SPICLK
SPISIMO
SPISOMI
SPI four pin option (1)
Slave
(Master = 0 ; CLKMOD = 0)
SPISIMO
SPISOMI
LSB
SPICLK
SPISCS
To use the SPISCS as a chip select, the slave SPISCS pin must be
configured as SPI functional (SPIPC6.4 = 1). In this mode, an active low
signal on the SPISCS
data line. An inactive high signal will put the slave SPI’s serial output pin in a
high-impedance state. Therefore many slave devices can be tied together on
the network, but only one slave at a time is allowed to talk. While the slave is
not selected, no shifting or interrupts will occur.
pin will allow the slave SPI to transfer data to the serial
Serial Peripheral Interface (SPI) Module (SPNU195E)7
SPI Operation Modes
4-pin option with SPIENA
To use the SPIENA as a W AIT signal pin, the SPIENA pin m ust be configured
to be functional (SPIPC6.0 = 1). In this mode, an active low signal on the
SPIENA
pin will allow the master SPI to drive the clock pulse stream;
otherwise, the master will hold the clock signal.
To use the SPIENA
as a WAIT signal pin, the slave SPIENA pin must be
configured as functional (SPIPC6.0 = 1). If the SPIENA
(ENABLE_HIGHZ = 1), the slave will put SPIENA
once it receives a new character. If the SPIENA
(ENABLE_HIGHZ = 0), the slave will drive SPIENA
new character. The slave will drive SPIENA
to the slave shift register (SPIDAT0).
To use the hardware handshaking mechanism, both the SPIENA pin and
SPISCS
pin must be configured as functional pins.
SPI Operation Modes
In the master SPI (CLKMOD = 1), if the SPIENA
functional input. If configured as a slave SPI, the SPIENA
a functional output. If the SPIENA
pin is in high-z mode (ENABLE_HIGHZ =
pin is configured as a
pin is configured as
1), the slave SPI will put this signal into the high-impedance state if it receives
a new character from the master or if the slave becomes de-selected by the
master (SPISCS
goes high). The slave will drive the signal low when new
data is written to the slave shift register (SPIDAT0) and the slave has been
selected by the master (SPISCS
If the SPIENA
drive SPIENA
pin is in push-pull mode (ENABLE_HIGHZ = 0), the slave will
high only if there is new data in the buffer register and the slave
is selected by the master (SPISCS
SPIENA
signal low when new data is written to the slave shift register
(SPIDAT0) and the slave is selec ted by the master (SPISCS
slave is de-selected by the master (SPISCS
is low).
is low). The slave SPI will drive the
is low). If the
goes high), the slave SPIENA
signal is driven low , allowing the ma ster SPI to communicate with other slave
SPIs.
In the master SPI (CLKMOD = 1), the SPISCS
pin is configured as a
functional output. If configured as a slave SPI (CLKMOD = 0), the SPISCS
pin is configured as a functional input. A write to the master’s SPIDAT1 shift
register will automatically drive the SPISCS
the SPISCS
signal high again after transmitting the new characte r. If the new
data is written to the master’s SPIDAT0 shift register, the SPISCS
signal low. The master will drive
signal will
NOT be driven low.
Serial Peripheral Interface (SPI) Module (SPNU195E)9
SPI Operation Modes
Figure 5.SPI Five-Pin Option with SPIENA and SPISCS
Master
(Master = 1 ; CLKMOD = 1)
SPISIMO
SPISOMI
MSB
SPIDAT1SPIDAT0
Write to
SPIDAT1
LSB
SPICLK
SPISCS
SPIENA
Write to SPIDAT1 (MASTER)
SPISCS
Write to SPIDAT0 (SLAVE)
SPI five pin option
Slave
(Master = 0 ; CLKMOD = 0)
SPISIMO
SPISOMI
MSBLSB
SPICLK
SPISCS
SPIENA
Write to
SPIDAT0
SPIENA
SPICLK
SPISIMO
SPISOMI
10
SPI Operation Modes
2.5Data Format
The data formats for th e three, four and five pin options are identical.
CHARLEN[4:0] (SPICTRL1.4-0) specifies the number of bits (3 to 16) in the
data word. The CHARLEN[4:0] value directs the state control logic to count
the number of bits received or transmitted to determine when a complete
word is processed.
The following conditions apply for words with fewer than 16 bits:
❏ Data must be left-justified when it is written to the SPI for transmission
❏ Data is right-justified when read back from the receive register
The buffer contains the most recently received word, right-justified, plus any
bits that are left over from previous transmissions that have been shifted to
the left. The diagram below shows how a 14-bit word is stored in the buffer
once it is received.
Bits D15D14D13D12D11D10D9D8D7D6D5D4D3D2D1D0
XX10101010101010
In transmit mode, the SPIBUF register contains the most recently transmitted word, left-justified. The diagram b elow shows ho w a 14-bit word n eeds to
be written to the buffer in order to be transmitted correctly.
Bits D15D14D13D12D11D10D9D8D7D6D5D4D3D2D1D0
10101010101010XX
To allow for the efficient transmission of byte-sized words, if a character
length is programmed for 8 bits or less, the SDPDAT[7] bit instead of SDPDA T[15 ] is the source of the serial out dat a. This prevent s the need to further
add 8 justification bits.
Serial Peripheral Interface (SPI) Module (SPNU195E)11
SPI Operation Modes
2.6Clocking Modes
There are four clock modes in which SPICL K may operate, dependi ng on the
choice of the phase (delay/no delay) and the polarity (rising edge / falling
edge) of the clock. When operating with PHASE active, the SPI makes the
first bit of data available after the SPIDAT0 register is written and before the
first edge of SPICLK. The data input a nd ou tput edges d epend on the valu es
of both POLARITY and PHASE as shown in Table 2.
Table 2. Clocking Modes
POLARITY PHASE ACTION
00
01
10
11
Data is output on the rising edge of SPICLK. Input
data is latched on the falling edge.
Data is output one half-cycle before the first rising
edge of SPICLK and on subsequent falling edges.
Input data is latched on the rising edge of SPICLK.
Data is output on the falling edge of SPICLK. Input
data is latched on the rising edge.
Data is output one half-cycle before the first falling
edge of SPICLK and on subsequent rising edges.
Input data is latched on the falling edge of SPICLK.
Figure 6 to Figure 9 illustrate the four possible signals of SPICLK
corresponding to each mode . Having four signal options allows the SPI to
interface with different types of serial devices. Also shown are the SPICLK
control bit polarity and phase values corresponding to each signal.
12
Figure 6.Clock Mode with POLARITY = 0 and PHASE = 0
Clock polarity = 0, Clock phase = 0
Write SPIDAT
SPICLK
2
D6D5D4D3D2D1
345678
SPISIMO
1
MSB
SPI Operation Modes
LSB
SPISOMI
Sample in
reception
Clock phase = 0 (SPICLK without delay)
- Data is output on the rising edge of SPICLK
- Input data is latched on the falling edge of SPICLK
- A write to the SPIDAT register starts SPICLK
D6D5D4D3D2D1D7
Figure 7.Clock Mode with POLARITY = 0 and PHASE = 1
Clock polarity = 0, Clock phase = 1
Write SPIDAT
SPICLK
2
D6D5D4D3D2D1
345678
SPISIMO
1
MSB
D0
LSB
SPISOMI
Sample in
reception
Clock phase = 1 (SPICLK with delay)
- Data is output one-half cycle before the first rising of SPICLK and on subsequent falling
edges of SPICLK
- Input data is latched on the rising edge of SPICLK
D7
D6D5D4D3D2D1
D0
Serial Peripheral Interface (SPI) Module (SPNU195E)13
SPI Operation Modes
Figure 8.Clock Mode with POLARITY = 1 and PHASE = 0
Clock polarity = 1, Clock phase = 0
Write SPIDAT
SPICLK
2
D6D5D4D3D2D1
345678
SPISIMO
1
MSB
LSB
SPISOMI
Sample in
reception
Clock phase = 0 (SPICLK without delay)
- Data is output on the falling edge of SPICLK
- Input data is latched on the rising edge of SPICLK
- A write to the SPIDAT register starts SPICLK
D6D5D4D3D2D1D7
Figure 9.Clock Mode with POLARITY = 1 and PHASE = 1
Clock polarity = 1, Clock phase = 1
Write SPIDAT
SPICLK
2
D6D5D4D3D2D1
345678
SPISIMO
1
MSB
D0
LSB
SPISOMI
Sample in
reception
Clock phase 1 (SPICLK with delay)
- Data is output one-half cycle before the first falling edge of SPICLK and on the subsequent rising
edges of SPICLK
- Input data is latched on the falling edge of SPICLK
14
D6D5D4D3D2D1D7
D0
2.7Data Transfer Example
The following timing diagram illustrates an SPI data transfer between two
devices using a character length of five bits.
Figure 10.Five Bits per Character (5-Pin Option)
Master SPI
Int. flag
Slave SPI
Int. flag
SPISOMI
from slave
7654376345
SPISIMO
from master
SPI Operation Modes
SPICLK signal options:
Clock polarity = 0
Clock phase = 0
Clock polarity = 0
Clock phase = 1
Clock polarity = 1
Clock phase = 0
Clock polarity = 1
Clock phase = 1
SPISCS
SPIENA
76543
B
7
6345
K
Serial Peripheral Interface (SPI) Module (SPNU195E)15
SPI Operation Modes
2.8Baud Rate Limitations
It is recommended to operate the master and slave SPIs at the same baud
rate. However, when this is not possible the SPICLK ranges specified in
Table 3 must be followed to ensure proper data transfer. Th e SPICLK ra te is
set by adjusting the PRESCALE value in the SPICTRL1 register.
Table 3.SPICLK Ranges
POLARITYPHASESPICLK RATIO
X0
X1
In all clocking mode configurations, the slave SPICLK must never be less
than half the speed of the master SPICLK. Doing so may allow the master to
start a new SPI transmission before the slave is ready. When operating with
PHASE = 0, the slave SPICLK must not be more than 1% faster than the
master SPICLK. When operating with PHASE = 1 the slave SPICLK must not
be more than two times faster than the master SPICLK. If th e slave SPICLK
exceeds the master SPICLK by more than 1% when PHASE = 0 or by 2x
when PHASE = 1 there is a possibility that the slave will move data from the
input shift register to SPIBUF before the master is finished transferring data.
Each of the SPI pins may be program med via th e SPI Pin Co ntrol Regist ers
(SPIPC1, SPIPC2, SPIPC3, SPIPC4, SPIPC5, SPIPC6) to be a generalpurpose I/O pin.
When the SPI module is not used, t he SPI pins may be programme d to be
either general input or general output pins. The direction is controlled in the
SPIPC1 register. Note that each pin can be programmed to be either a SPI
pin or a GPIO pin through register SPIPC6.
If the SPI function is to be used, application software must ensure that each
pin is configured as a SPI pin and not a GPIO pin, or else unexpected
behavior may result.
Note: Unused SPI Pins
If there are four or five SPI pins available and only the three- or four-pin
configuration is desired, the remaining pin(s) can be configured and used as
general-purpose input/output (GIO) pins.
General Purpose I/O
Serial Peripheral Interface (SPI) Module (SPNU195E)17
Low Power Mode
4Low Power Mode
The SPI module has two means to be placed in a low-power mode: a global
low-power mode from the system and a local low-power mode via the
POWERDOWN bit (SPICTRL2.2). The net effect on the SPI is the same,
independent of the source.
A low-power mode in effect shuts down all the clocks to the module. During
a global low-power mode, no register s are visible to the software; noth ing can
be written to or read from any register. A local low-power mode has the same
effect when both the local POWERDOWN bit and the system level
PPWNOVR bit are set. If only the local POWERDOWN bit is set, then the SPI
logic is not clocked, but the registers continue to be clocked.
Since entering a low-power mode has the effect of suspending all statemachine activities, care must be taken when entering such modes to insure
that a valid state is entered when low-power mode is active. As a result,
application software must insure that a low power mo de is not entered during
a transmission or reception of a message.
18
5DMA Interface
DMA Interface
If handling the SPI message traffic on a character-by-ch aracter basis requires
too much CPU overhead and if the particular de vice is equipped with the DMA
controller, the SPI may use the DMA controller to receive or transmit data
directly to memory. The SPI module contains one DMA request enable bit
(DMA REQ EN).
When a character is being transmitted or received, the SPI will signal the
DMA via a DMA request signal. The DMA controller will then perform the
needed data manipulation.
For DMA-based transmissions, all characters are assembled in RAM, and
DMA transfers move the message, word-by-word, from RAM into the
SPIDAT0 register. (See the DMA controller specification). Data is then read
from SPIBUF, clearing RXINTFLAG (SPICTRL3.0).
For efficient behavior, during DMA operations, the receive interrupt enable
flag RXINTEN (SPICTRL3.1) should be cleared to 0. For specific DMA
features, refer to the DMA controller specification.
Serial Peripheral Interface (SPI) Module (SPNU195E)19
Control Registers
6Control Registers
This section describes the SPI control, data and pin registers The registers
support 16-bit and 32-bit writes .
20
Control Registers
Serial Peripheral Interface (SPI)Module (SPNU195E)21
Serial Peripheral Interface (SPI)Module (SPNU195E)23
† The actual addresses of these registers are device specific. See the specific device data sheet to verify the SPI register addresses.
‡ The SPIBUF is a 32 bit register. Two bits in the upper 16 bits are used for control, all 16 lower bits are data buffers.
If the SPI is a network slave, the module receives a clock signal on the
SPICLK pin from the network master . However , the slave’s PRESCALE bau d
rate (Slave SPICLK) must also conform to the following specifications:
Bits 4:0CHARLEN Controls how many times the SPI shifts per character transmitted
or the number of bits per character. The binary value of the bit length must be
programmed into this register. Legal values are 0x03 to 0x10. Illegal values,
such as 0x00 or 0x1F are not detected and their effect is indeterminate.
Note: CHARLEN Bits Must Be Initialized
CHARLEN.4:0 must be initialized to the desired character length before the
SPIEN bit is set. Otherwise, the first character may be shifted with an
incorrect length.
Serial Peripheral Interface (SPI) Module (SPNU195E)25
Control Registers
6.2SPI Control Register 2 (SPICTRL2)
Bits 3116
0x04Reserved
U
Bits 156543210
CLK
Reserved
URW-0 RW-0 RW-0 RW-0 RW-0 RW-0
R = read; W = Write; U = Undefined; -n = Value after reset
Bits 31:6Reserved.
Reads are undefined and writes have no effe ct.
Bit 5CLKMOD. Clock mode
MOD
SPIENMAS-
PWRDNPOLA
TER
RITY
PHAS
E
Selects either an internal or exter nal clock source. This bit also determines
the I/O direction of the SPIENA
0=Clock is external
1=Clock is internal
Bit 4SPIEN. SPI enable
Holds the SPI in a reset state after a chip reset. The SPI is enab led only after
a 1 is written to this bit. This bit must be set to 1 after all other SPI
configuration bits have been written. This prevent s an invalid operation of the
SPI while the clock polarity is being changed. When this bit is 0, the SPI shift
registers (SPIDAT0 and SPIDAT1) are held in reset mode and forced to
0x0000.
The RXINTFLAG (SPICTRL3.0) and RCVROVRN (SPITRL3.2) bits are also
held in reset mode and forced to 0 when this bit is 0. SPICLK is disabled whe n
this bit is 0.
0=SPI is in reset
1=Activates SPI
and SPISCS pins in functional mode.
26
Control Registers
Note: Clearing SPIBUF
Clearing and then setting the SPIEN bit does not clear an internal flag that
indicates that there is valid data in the SPI data register. This could lead to an
inadvertent overrun error. The software should do a dummy read of SPIBUF
after setting the SPIEN bit to clear the internal flag.
Bit 3MASTER: SPISIMO/SPISOMI pin direction determination.
Determines the direction of the SPISIMO and SPISOMI pins.
0=SPISIMO pin an input, SPISOMI pin an output
1=SPISOMI pin an input, SPISIMO pin an output
Bit 2POWERDOWN.
When active, the SPI state machines enter a powerdown state.
0=SPI in active mode
1=SPI in powerdown mode
Bit 1POLARITY.
Controls the polarity of the SPICLK. Clock polarity and clock phase
(SPICTRL2.0) controls four clocking schemes on the SPICLK pin. See Figure
6 to Figure 9, page 13 for wave form diagrams of the SPI clocking schemes.
Bit 0PHASE.
Data is sent or latched in-phase with the clock signal. When PHASE = 1,
SPICLK is delayed by one-half cycle from when data is output. Polarity is
determined by the POLARITY bit (SPICTRL2.1). POLARITY and PHASE
make four different clocking schemes po ssible. For infor mation on th e use of
the Polarity and Phase bits, see section 2.5, Data Format, on page 11
Note: Register Configuration Bits
Since there are configuration bits in this register, two write operations must
occur when setting these bits. One write to set the configuration bit s and one
to set the SPIEN bit.
Serial Peripheral Interface (SPI) Module (SPNU195E)27
Control Registers
6.3SPI Control Register 3 (SPICTRL3)
Bits 3116
0x08Reserved
U
Bits 156543210
EN
DMA
Reserved
URW-0 RW-0 RW-0 RC-0 RW-0 RC-0
R = Read, W = Write, C = Clear, U = Undefined; -n = Value after reset
Bits 31:6Reserved.
Reads are undefined and writes have no effe ct.
ABLE
HIGH
Z
REQ
EN
OVRN
INT
EN
RCVR
OVRN
RX
INT
EN
RX
INT
FLAG
Bit 5ENABLE HIGHZ. SPIENA
When active, the SPIENA
pin high-z enable.
pin (when it is configured as a WAIT functional
output signal in a slave SPI) is forced to place it’s output in high-z when not
driving a low signal. If inactive, then the pin will output both a high and a low
signal.
0=SPIENA
1=SPIENA
pin is a value
pin is in high-z
Bit 4DMA REQ EN. DMA request enable.
Enables the DMA request signal to be generated for both receive and
transmit channels.
0=DMA is not used
1=DMA is used
Bit 3OVRNINTEN. Overrun interrupt enable.
An interrupt is to be generated when the RCVR OVRN flag bit (SPICTRL3.2)
is set by hardware. Otherwise, no interrupt will be generated.
0=Overrun interrupt will not be generated
1=Overrun interrupt will be generated
28
Bit 2RCVR OVRN. Receiver overrun flag.
This bit is a read/clear only flag. The SPI hardware sets this bit when an
operation completes before the previous character has been read from the
buffer. The bit indicates that the last received character has been overwritte n
and therefore lost. The SPI will generate an interrupt request if this bit is set
and the OVRN INTEN bit (SPICTRL3.3) is set high.
This bit is cleared in one of four ways:
❏ Reading the SPIBUF register
❏ Writing a 1 to this bit
❏ Writing a 0 to SPIEN (SPICTRL2.4)
❏ System reset
0=Overrun condition did not occur
1=Overrun condition has occurred
Bit 1RXINTEN.
Control Registers
An interrupt is to be generated when the RXINTFLAG bit (SPICTRL3.0) is set
by hardware. Otherwise, no interrupt will be generated.
0=Interrupt will not be generated
1=Interrupt will be generated
Bit 0RXINTFLAG. Serves as the SPI interrupt flag.
This flag is set when a word is rece ived and copied into the buffer register
(SPIBUF). If RXINTEN is enabled, an interrupt is also generated. During
emulation mode, however, a read to the emulation register (SPIEMU) does
not clear this flag bit. This bit is cleared in one of four ways:
❏ Reading the SPIBUF register
❏ Writing a 1 to this bit
❏ Writing a 0 to SPIEN (SPICTRL2.4)
❏ System reset
0=Interrupt condition did not occur
1=Interrupt condition did occur
Serial Peripheral Interface (SPI) Module (SPNU195E)29
Control Registers
6.4SPI Shift Register 0 (SPIDAT0)
Bits 3116
0x0CReserved
U
Bits 150
SPIDAT0
RW-0
R = Read, W = Write, U = Undefined; -n = Value after reset
Bits 31:16Reserved
Reads are undefined and writes have no effe ct.
Bits 15:0SPIDAT0 SPI shift data 0.
These bits make up the SPI shift register 0. Data is shifted out of the MSB (bit
15) and into the LSB (bit 0).
SPIEN (SPICTRL2.4) must be set to 1 before this register can be written to.
Writing a 0 to the SPIEN register forces the lower 16 bits of the SPIDAT0
register to 0x00.
When data is read from this register, the value is indeterminate because of
the shift operation. The value in the buffer register (SPIBUF) should be read
after the shift operation is complete to determine what data was shifted into
the SPIDAT0 register.
When transmitting data, input data is automatically clocked in at the receive
side. As the data is shifted from the MSB, the LSB of the r eceived data is
shifted in. Similarly, when the shift register is used as a receiver, the shift
register continues to send data out as it receives new data on each input
clock cycle. This allows the concurrent transmission and reception of data.
The application software must determine whether the data transferred is
valid.
For word sizes of 8 bits or less (as determined by CHARLEN)
(SPICTRL1.4:0), the shift register is tapped at SPIDAT.7. As a result, data of
8 bits does not need to be justified at all. For dat a of less than 8 bit s, the dat a
should be justified as if it is an 8-bit register.
30
Control Registers
6.5SPI Shift Register 1 (SPIDAT1)
Bits 3116
0x10Reserved
U
Bits 150
SPIDAT1
RW-0
R = Read, W = Write, U = Undefined; -n = Value after reset
Bits 31:16Reserved
Reads are undefined and writes have no effe ct.
Bits 15:0SPIDAT1 SPI shift data 1.
These bits make up the SPI shift register 1. Data is shifted out of the MSB (bit
15) and into the LSB (bit 0).
SPIEN must be set to 1 before this register can be written to. Writing a 0 to
the SPIEN register forces the lower 16 bits of the SPIDAT 1 regi ste r to 0x 00 .
Write to this register ONLY when using the automatic Slave Chip Select
feature. See section 2, SPI Operation Modes, on page 3. A write to this
register will drive the SPISCS
signal low.
When data is read from this register, the value is indeterminate because of
the shift operation. The value in the buffer register (SPIBUF) should be read
after the shift operation is complete to determine what data was shifted into
the SPIDAT1 register.
Serial Peripheral Interface (SPI) Module (SPNU195E)31
Control Registers
6.6SPI Buffer Register (SPIBUF)
Bits 31181716
0x14Reserved
URC-0 RC-0
Bits 150
SPIBUF
R-U
R = Read, C = Clear, U = Undefined; -n = Value after reset
RCVR
OVRN
IMG
FLAG
Bits 31:18Reserved.
Reads are undefined and writes have no effect
Bit 17RCVR OVRN IMG. SPI receiver overrun flag image.
This is a mirror bit of the RCVROVRN flag bit (SPICTRL3.2) and is used to
reduce the interrupt latency and execution time.
This bit is cleared in one of four ways.
INT
IMG
❏ Reading the SPIBUF register
❏ Writing a 1 to this bit
❏ Writing a 0 to SPIEN (SPICTRL2.4)
❏ System reset
0=Overrun condition did not occur
1=Overrun condition has occurred
Note: The SPIBUF Register
The SPIBUF is a 32 bit register. Two bits in the upper 16 bits are used for
control, all 16 lower bits are data buffers
32
Bit 16RXINTFLAG IMG. SPI interrupt flag image.
This is a mirror bit of the RXINTFLAG bit (SPICTRL3.0).
This bit is cleared in one of four ways.
❏ Reading the SPIBUF register
❏ Writing a 1 to this bit
❏ Writing a 0 to SPIEN (SPICTRL2.4)
❏ System reset
0=Interrupt condition did not occur
1=Interrupt condition did occur
Bits 15:0SPIBUF: SPI buffer.
The data in this register is the data transferred from the shift-register
(SPIDAT). Since the data is shifted into the SPI most significant bit first, for
word lengths less than 16, the data is stored right-justified in the register.
Control Registers
Note: SPI Buffer
Reading the SPIBUF register clears the RCVROVRN (SPICTRL3.2),
RXINTFLAG (SPICTRL3.0), RCVR OVRN IMG (SPIBUF.17), and the
RXINTFLAG IMG (SPIBUF.16) bits.
Serial Peripheral Interface (SPI) Module (SPNU195E)33
Control Registers
6.7SPI Emulation Register (SPIEMU)
Bits 3116
0x18Reserved
U
Bits 150
SPIEMU
R-U
R = Read, U = Undefined; -n = Value after reset
Bits 31:16Reserved.
Reads are undefined and writes have no effect
Bits 15:0SPIEMU: SPI emulation.
SPI emulation is a mirror of the SPIBUF register . The only dif ference between
SPIEMU and SPIBUF is that a read from SPIEMU does not clear the RCVR
OVRN (SPICTRL3.2) or RXINTFLAG (SPICTRL3.0) bits.
34
Control Registers
6.8SPI Pin Control Register 1 (SPIPC1)
Bits 3116
0x1CReserved
U
Bits 15543210
SCS
SOMI
Reserved
URW-0 RW-0 RW-0 RW-0 RW-0
R = Read, C = Clear, U = Undefined; -n = Value after reset
Bits 31:5Reserved.
Reads are undefined and writes have no effect
DIR
DIR
SIMOI
DIR
CLK
DIR
ENA
DIR
Bit 4SCS DIR: SPISCS
direction.
Controls the direction of the SPISCS
I/O pin. If the SPISCS
is used as a SPI functional pin, the I/O direction is
determined by the CLKMOD bit (SPICTRL2.5).
0=SPISCS
1=SPISCS
pin is an input
pin is an output
Bit 3SOMI DIR: SPISOMI direction.
Controls the direction of the SPISOMI pin when it is used as a generalpurpose I/O pin. If the SPISOMI pin is used as a SPI functional pin, the I/O
direction is determined by the MASTER bit (SPICTRL2.3).
0=SPISOMI pin is an input
1=SPISOMI pin is an output
Bit 2SIMODIR: SPISIMO direction.
Controls the direction of the SPISIMO pin when it is used as a generalpurpose I/O pin. If the SPISIMO pin is used as a SPI functional pin, the I/O
direction is determined by the MASTER bit (SPICTRL2.3).
pin when it is used as a general-purpose
0=SPISIMO pin is an input
1=SPISIMO pin is an output
Serial Peripheral Interface (SPI) Module (SPNU195E)35
Control Registers
Bit 1CLKDIR: SPICLK direction.
Controls the direction of the SPICLK pin when it is used as a general-purpose
I/O pin. In functional mode, the I/O direction is determined by the CLKMOD
bit (SPICTRL2.5).
0=SPICLK pin is an input
1=SPICLK pin is an output
Bit 0ENA DIR: SPIENA
Controls the direction of the SPIENA
I/O. If the SPIENA
determined by the CLKMOD bit (SPICTRL2. 5) .
0=SPIENA pin is an input
1=SPIENA pin is an output
direction.
pin when it is used as a general-purpose
pin is used as a functional pin, then the I/O direction is
36
Control Registers
6.9SPI Pin Control Register 2 (SPIPC2)
Bits 3116
0x20Reserved
U
Bits 15543210
SCS
SOMI
Reserved
UR-UR-UR-UR-UR-U
R = Read, C = Clear, U = Undefined; -n = Value after reset
Bits 31:5Reserved.
Write:Has no effect
Read:Value is indeterminate
Reset: Undefined
DIN
DIN
SIMO
DIN
CLK
DIN
ENA
DIN
Bit 4SCS DIN: SPISCS
data in.
Reflects the value of the SPISCS
0=Current value on SPISCS
1=Current value on SPISCS
Bit 3SOMI DIN: SPISOMI data in.
Reflects the value of the SPISOMI pin.
0=Current value on SPISOMI pin is logic 0.
1=Current value on SPISOMI pin is logic 1
Bit 2SIMO DIN: SPISIMO data in.
Reflects the value of the SPISIMO pin.
0=Current value on SPISIMO pin is logic 0.
1=Current value on SPISIMO pin is logic 1
Bit 1CLK DIN: Clock data in.
Reflects the value of the SPICLK pin.
pin.
pin is logic 0.
pin is logic 1
0=Current value on SPICLK pin is logic 0.
1=Current value on SPICLK pin is logic 1
Serial Peripheral Interface (SPI) Module (SPNU195E)37
Control Registers
Bit 0ENA DIN: SPIENA data in.
Reflects the value of the SPIENA
pin.
0=Current value on SPIENA
1=Current value on SPIENA
pin is logic 0.
pin is logic 1
38
Control Registers
6.10SPI Pin Control Register 3 (SPIPC3)
Bits 3116
0x24Reserved
U
Bits 15543210
SCS
SOMI
Reserved
URW-0 RW-0 RW-0 RW-0 RW-0
R = Read, W = Write, U = Undefined; -n = Value after reset
Bits 31:5Reserved.
Reads are undefined and writes have no effect.
DOUT
DOUT
SIMO
DOUT
CLK
DOUT
ENA
DOUT
Bit 4SCS DOUT: SPISCS
Only active when the SPISCS
dataout write.
pin is configured as a general-purpose I/O pin
and configured as an output pin. The value of this bit indicates the value sent
to the pin.
0=Current value on SPISCS
1=Current value on SPISCS
Bit 3SOMI DOUT: SPISOMI dataout write.
Only active when the SPISOMI pin is configured as a general-purpose I/O pin
and configured as an output pin. The value of this bit indicates the value sent
to the pin.
0=Current value on SPISOMI pin is logic 0.
1=Current value on SPISOMI pin is logic 1
Bit 2SIMO DOUT: SPISIMO dataout write.
Only active when the SPISIMO pin is configured as a general-purpose I/O pin
and configured as an output pin. The value of this bit indicates the value sent
to the pin.
pin is logic 0.
pin is logic 1
0=Current value on SPISIMO pin is logic 0.
1=Current value on SPISIMO pin is logic 1
Serial Peripheral Interface (SPI) Module (SPNU195E)39
Control Registers
Bit 1CLK DOUT: SPICLK dataout write.
Only active when the SPICLK pin is configured as a general-purpose I/O pin
and configured as an output pin. The value of this bit indicates the value sent
to the pin.
0=Current value on SPICLK pin is logic 0.
1=Current value on SPICLK pin is logic 1
Bit 0ENA DOUT: SPIENA
Only active when the SPIENA
and configured as an output pin. The value of this bit indicates the value sent
to the pin.
0=Current value on SPIENA
1=Current value on SPIENA
dataout write.
pin is configured as a general-purpose I/O pin
pin is logic 0.
pin is logic 1
40
Control Registers
6.11SPI Pin Control Register 4 (SPIPC4)
Bits 3116
0x28Reserved
U
Bits 15543210
SCS
SOMI
Reserved
URW-0 RW-0 RW-0 RW-0 RW-0
R = Read, W = Write, U = Undefined; -n = Value after reset
Bits 31:5Reserved.
Reads are undefined and writes have no effect
DSET
DSET
SIMO
DSET
CLK
DSET
ENA
DSET
Bit 4SCS DOUT SET: SPISCS
Only active when the SPISCS
dataout set.
pin is configured as a general-purpose output
pin. A value of one written to this bit sets the corresponding SCS
(SPIPC3.4) to one.
Write:
0=Has no effect
1=Logic 1 placed on SPISCS
Read:
0=Current value on SPISCS
1=Current value on SPISCS
Bit 3SOMI DSET: SPISOMI dataout set.
Only active when the SPISOMI pin is configured as a general-purpose output
pin. A value of one written to this bit sets the corresponding SPISOMIDOUT
bit (SPIPC3.3) to one.
Write:
0=Has no effect
1=Logic 1 placed on SPISOMI pin
DOUT bit
pin
pin is logic 0.
pin is logic 1
Read:
0=Current value on SPISOMI pin is logic 0.
1=Current value on SPISOMI pin is logic 1
Serial Peripheral Interface (SPI) Module (SPNU195E)41
Control Registers
Bit 2SIMO DSET: SPISIMO dataout set.
Bit 1CLK DSET: SPICLK dataout set.
Only active when the SPISIMO pin is configured as a general-purpose output
pin. A value of one written to this bit sets the corresponding SPISIMODOUT
bit (SPIPC3.2) to one.
Write:
0=Has no effect
1=Logic 1 placed on SPISIMO pin
Read:
0=Current value on SPISIMO pin is logic 0.
1=Current value on SPISIMO pin is logic 1
Only active when the SPICLK pin is configured as a general-purpose output
pin. A value of one written to this bit sets the corresponding CLKDOUT bit
(SPIPC3.1) to one.
Write:
0=Has no effect
1=Logic 1 placed on SPICLK pin
Read:
0=Current value on SPICLK pin is logic 0.
1=Current value on SPICLK pin is logic 1
Bit 0ENA DSET: SPIENA
Only active when the SPIENA
pin. A value of one written to this bit sets the corresponding ENABLEDOUT
bit (SPIPC3.0) to one.
Write:
0=Has no effect
1=Logic 1 placed on SPIENA
Read:
0=Current value on SPIENA
1=Current value on SPIENA pin is logic 1
Note: Register Read
A read to this register gives the corresponding value of the SPIPC3 register.
dataout set.
pin is configured as a general-purpose output
pin
pin is logic 0.
42
Control Registers
6.12SPI Pin Control Register 5 (SPIPC5)
Bits 3116
0x2CReserved
U
Bits 15543210
SCS
SOMI
Reserved
URW-0 RW-0 RW-0 RW-0 RW-0
R = Read, W = Write, U = Undefined; -n = Value after reset
Bits 31:5Reserved.
Reads are undefined and writes have no effect
DCLR
DCLR
SIMO
DCLR
CLK
DCLR
ENA
DCLR
Bit 4SCS DCLR: SPISCS
Only active when the SPISCS
dataout clear.
pin is configured as a general-purpose output
pin. A value of one written to this bit clears the correspondin g SCSDOU T bit
(SPIPC3.4) to zero.
Write:
0=Has no effect
1=Logic 0 placed on SPISCS
Read:
0=Current value on SPISCS
1=Current value on SPISCS
Bit 3SOMI DCLR: SPISOMI dataout clear.
Only active when the SPISOMI pin is configured as a general-purpose output
pin. A value of one written to this bit clears the corresponding SPISOMIDOUT
bit (SPIPC3.3) to zero.
Write:
0=Has no effect
1=Logic 0 placed on SPISOMI pin
pin
pin is logic 0.
pin is logic 1
Read:
0=Current value on SPISOMI pin is logic 0.
1=Current value on SPISOMI pin is logic 1
Serial Peripheral Interface (SPI) Module (SPNU195E)43
Control Registers
Bit 2SIMO DCLR: SPISIMO dataout clear.
Bit 1CLK DCLR: SPICLK dataout clear.
Only active when the SPISIMO pin is configured as a general-purpose output
pin. A value of one written to this bit clea rs the corresponding SPISIMODOUT
bit (SPIPC3.2) to zero.
Write:
0=Has no effect
1=Logic 0 placed on SPISIMO pin
Read:
0=Current value on SPISIMO pin is logic 0.
1=Current value on SPISIMO pin is logic 1
Only active when the SPICLK pin is configured as a general-purpose output
pin. A value of one written to this bit clears the corresponding CLKDOUT bit
(SPIPC3.1) to zero.
Write:
0=Has no effect
1=Logic 0 placed on SPICLK pin
Read:
0=Current value on SPICLK pin is logic 0.
1=Current value on SPICLK pin is logic 1
Bit 0ENA DCLR: SPIENA
Only active when the SPIENA
pin. A value of one written to this bit clears the corresponding ENABLEDOUT
bit (SPIPC3.0) to zero.
Write:
0=Has no effect
1=Logic 0 placed on SPIENA
Read:
0=Current value on SPIENA
1=Current value on SPIENA pin is logic 1
Note: Register Read
A read to this register gives the corresponding value of the SPIPC3 register.
dataout clear.
pin is configured as a general-purpose output
pin
pin is logic 0.
44
Control Registers
6.13SPI Pin Control Register 6 (SPIPC6)
Bits 3116
0x30Reserved
U
Bits 15543210
SCS
SOMI
Reserved
URW-0 RW-0 RW-0 RW-0 RW-0
R = Read, W = Write, U = Undefined; -n = Value after reset
Bits 31:5Reserved.
Reads are undefined and writes have no effect
FUN
FUN
SIMO
FUN
CLK
FUN
ENA
FUN
Bit 4SCS FUN: SPISCS
Determines whether the SPISCS
function.
pin is to be used as a general-purpos e I/O
pin or as a SPI functional pin. If the slave SPISCS
and receives an inactive high signal, the slave SPI will place it’s output in
high-z and disable shifting.
0=SPISCS
1=SPISCS
pin is a GPIO
pin is a SPI functional pin
Bit 3SOMI FUN: Slave out, master in function.
Determines whether the SPISOMI pin is to be used as a general-purpose
I/O pin or as a SPI functional pin.
0=SPISOMI pin is a GPIO
1=SPISOMI pin is a SPI functional pin
Bit 2SIMO FUN: Slave in, master out function.
Determines whether the SPISIMO pin is to be used as a general-purpose
I/O pin, or as a SPI functional pin.
0=SPISIMO pin is a GPIO
1=SPISIMO pin is a SPI functional pin
pin is in functional mode
Bit 1CLK FUN: SPI clock function.
Determines whether the SPICLK pin is to be used as a general-purpose I/O
pin, or as a SPI functional pin.
0=SPICLK pin is a GPIO
1=SPICLK pin is a SPI functional pin
Serial Peripheral Interface (SPI) Module (SPNU195E)45
Control Registers
Bit 0ENA FUN: SPIENA function.
Determines whether the SPIENA
pin, or as a SPI functional pin.
0=SPIENA
1=SPIENA
pin is a GPIO
pin is a SPI functional pin
pin is to be used as a general-purpose I/O
46
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.