
M68HC11
REFERENCE MANUAL
SYNCHRONOUS SERIAL PERIPHERAL INTERFACE
MOTOROLA
8-5
pin is a special case.
NOTE
SPI transfers will not occur unless the outputs are enabled by setting
the corresponding DDRD bits. SPI outputs are disabled (high imped-
ance) unless their corresponding DDRD bits are set to one. SPI
inputs are configured as high-impedance inputs even if their corre-
sponding DDRD bits are set to one.
The SCK pin is an output when the SPI is configured as a master and an input when
the SPI is configured as a slave. When the SPI is configured as a master, the SCK
signal is derived from the internal MCU bus clock. When the master initiates a transfer,
eight clock cycles are automatically generated on the SCK pin. When the SPI is con-
figured as a slave, the SCK pin is an input, and the clock signal from the master syn-
chronizes the data transfer between the master and slave devices. Slave devices
ignore the SCK signal unless the slave select pin is active low. In both the master and
slave SPI devices, data is shifted on one edge of the SCK signal and is sampled on
the opposite edge where data is stable. Edge polarity is determined by the SPI transfer
protocol.
The MISO and MOSI data pins are used for transmitting and receiving serial data.
When the SPI is configured as a master, MISO is the master data input line, and MOSI
is the master data output line. When the SPI is configured as a slave, these pins re-
verse roles. In a multiple-master system, all SCK pins are tied together, all MOSI pins
are tied together, and all MISO pins are tied together. A single SPI device is configured
as a master; all other SPI devices on the SPI bus are configured as slaves. The single
master drives data out its SCK and MOSI pins to the SCK and MOSI pins of the slaves.
One selected slave device optionally drives data out its MISO pin to the MISO master
pin. The automatic control of the direction of these pins makes reconfiguration through
external logic unnecessary when a new device becomes the master.
The SS pin behaves differently on master and slave devices. On a slave device, this
pin is used to enable the SPI slave for a transfer. If the SS pin of a slave is inactive
(high), the device ignores SCK clocks and keeps the MISO output pin in the high-im-
pedance state. On a master device, the SS pin can optionally serve as an error-detec-
tion input for the SPI or as a general-purpose output not affecting the SPI. The choice
is based on the corresponding data direction control bit (DDRD5). When DDRD5 is
logic one and the SPI is configured as a master, the PD5/SS pin acts as a general-
purpose output that is independent of SPI activities. When the DDRD5 bit is logic zero
and the SPI system is configured as a master, the SS pin acts as an error-detection
input, which should remain high. If the SS pin goes low while the SPI is a master and
is using the SS pin as an error-detection input, it indicates that some other device on
the SPI bus is attempting to be a master. This attempt causes the master device sens-
ing the error to immediately exit the SPI bus to avoid potentially damaging driver con-
tentions. This detection is called a mode fault and is discussed in
8.5.1 SPI Mode-
Fault Error
.
The port D I/O pins, including the four SPI pins, can be configured to behave as open-