Serial Peripheral Interface (SPI) : Synchronous Serial Data Transfers
Serial Peripheral Interface (SPI) : Synchronous Serial Data Transfers
Slave SS
Master CS Slave
Select
Clock SCK
Shift register Gen Shift register
MOSI
MISO
Slave-selects
Single master, multiple slave SPI
implementation – daisy chained
CPOL
is the
“idle”
state
SPI serial data timing
CPHA=1
data output on 1st clock edge after PCSn active
data sampled on trailing edge
Data output Sample data
PCSn active
Maxim MAX5154
12-Bit Serial DAC
Data Output
Chip-Select
Serial Clock
Data Input
MAX5154 serial data format
I2C signals
Trigger
Data Ready
Analog Devices
ADIS16003 Dual-axis accelerometer
SPI
Interface
Slave
select
SPI data register (SPI_DR)
TXDMAEN: Tx buffer DMA enable (DMA request when TXE flag set)
RXDMAEN: Rx buffer DMA enable (DMA request when RXNE flag set)
DMA automatically xfers data between memory and SPI_DR
SPI status register (SPI_SR)
FRE: frame format error (for SPI TI slave mode or I2S slave mode)
BSY: SPI/I2S busy communicating (set/cleared by hardware)
OVR: overrun error – master sends before RXNE cleared by slave
MODF: master mode fault – master NSS pin lulled low(SPI only)
CRCERR: CRC error in received value (SPI only)
UDR: underrun error (I2S only) 1st clock before data in DR
CHSIDE: channel side to xmit/has been received (0 = left/1 = right) (I2S only)
TXE: 1 = Tx buffer empty: can load next data to buffer;
clears on DR write
RXNE: 1 = Rx buffer not empty: valid received data in buffer;
clears on DR read
2. Select CPOL and CPHA bits to define one of the four relationships between
the data transfer and the serial clock.
3. Select DFF bit to define 8- or 16-bit data frame format
4. Select LSBFIRST bit to define the frame format (MSB or LSB first).
6. If the NSS pin is required in input mode, in hardware mode, connect the
NSS pin to a high-level signal during the complete byte transmit sequence.
In NSS software mode, set the SSM and SSI bits in the SPI_CR1 register. If
the NSS pin is required in output mode, the SSOE bit only should be set.
7. Select FRF bit in SPI_CR2 to select the Motorola or TI SPI protocol.