Operating Modes
MOTOROLA
Serial Peripheral Interface (SPI)
11-7
Preliminary
11
11.6 Operating Modes
The SPI has two operating modes:
Master
Slave
An operating mode is selected by the SPMSTR bit in the SPSCR as follows:
SPMSTR = 0 Slave mode
SPMSTR = 1 Master mode
Note:
The SPMSTR bit should be configured before enabling the SPI, setting the SPE
bit in the SPSCR. The master SPI should be enabled before enabling any slave
SPI. All slave SPIs should be disabled before disabling the master SPI.
11.6.1 Master Mode
The SPI operates in master mode when the SPI master bit, SPMSTR, is set.
Note:
Configure the SPI module as master or slave before enabling the SPI. Enable
the master SPI before enabling the slave SPI. Disable the slave SPI before
disabling the master SPI.
Only a Master SPI module can initiate transmissions. With the SPI enabled, software
begins the transmission from the master SPI module by writing to the SPI Data Transmit
Register (SPDTR). If the Shift Register is empty, the data immediately transfers to the
Shift Register, setting the SPI Transmitter Empty (SPTE) bit. The data begins shifting out
on the MOSI pin under the control of the SPI Serial Clock (SCLK).
The SPR2, SPR1 and SPR0 bits in the SPSCR register, control the baud rate generator and
determine the speed of the shift register. Through the SCLK pin, the baud rate generator of
the master also controls the shift register of the slave peripheral.
As the data shifts out on the MOSI pin of the master, external data shifts in from the slave
on the master’s MISO pin. The transmission ends when the receiver full bit, SPRF,
becomes set. At the same time the SPRF becomes set, the data from the slave transfer to the
receive data register. In normal operation, SPRF signals the end of a transmission. Software
clears SPRF by reading the SPI data receive register, SPDRR. Writing to the SPI data
transmit register, SPDTR, clears the SPTE bit.
Figure 11-3 is an example configuration for a Full-Duplex Master-Slave Configuration.
Having the SS bit of the Master DSP held high is only necessary if MODFEN = 1. Tying
the Slave DSP SS bit to ground should only be executed if CPHA = 1.