
Architecture
1427
SPRUH82C – April 2013 – Revised September 2016
Copyright © 2013–2016, Texas Instruments Incorporated
Serial Peripheral Interface (SPI)
29.2.11 Data Formats
The SPI provides the capability to configure four independent data formats. These formats are configured
by programming the corresponding SPI data format registers (SPIFMT
n
). In each data format, the
following characteristics of the SPI operation are selected:
•
Character length from 2 to 16 bits: The character length is configured by the SPIFMT
n
.CHARLEN field.
•
Shift direction (MSB first or LSB first): The shift out direction is configured by the SPIFMT
n
.SHIFTDIR
bit.
•
Clock polarity: The clock polarity is configured by the SPIFMT
n
.POLARITY bit.
•
Clock phase: The clock phase is configured by the SPIFMT
n
.PHASE bit.
The data format is chosen on each transaction. Transmit data is written to the SPI transmit data register 1
(SPIDAT1) and in the same write the data word format select (DFSEL) bit in SPIDAT1 indicates which
data format is to be used for the next transaction. Alternatively, the data format can be configured once
and applies to all transactions that follow until the data format is changed.
29.2.11.1 Character Length
The character length is configured by the SPIFMT
n
.CHARLEN bit. Legal values are 2 bits (2h) to 16 bits
(10h). The character length is independently configured for each of the four data formats; and it must be
programmed in both master mode and slave mode.
Transmit data is written to SPIDAT1. The transmit data must be written right-justified irrespective of the
character length. The SPI automatically sends out the data correctly based on the chosen data format.
shows how a 12-bit word (EC9h) needs to be written to the transmit buffer in order to be
transmitted correctly.
Figure 29-6. Format for Transmitting 12-Bit Word
D15
D14
D13
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0
x
x
x
x
1
1
1
0
1
1
0
0
1
0
0
1
The data received in SPIBUF is right-justified irrespective of the character length and is padded with 0s
when character length is less than 16.
shows how a 10-bit word (3A2h) is stored in the buffer once it is received.
Figure 29-7. Format for 10-Bit Received Word
D15
D14
D13
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0
0
0
0
0
0
0
1
1
1
0
1
0
0
0
1
0
29.2.11.2 Shift Direction
The shift out direction is configured as most-significant bit (MSB) first or least significant bit (LSB) first. The
shift out direction is selected by the SPIFMT
n
.SHIFTDIR bit. The shift out direction is independently
configured for each of the four data formats.
•
When SPIFMT
n
.SHIFTDIR is 0, the transmit data is shifted out MSB first.
•
When SPIFMT
n
.SHIFTDIR is 1, the transmit data is shifted out LSB first.