Download MC56F8006 / MC56F8002 - Reference Manual

Transcript
Serial Peripheral Interface (SPI)
11.4.2.1
Data Transaction Length
The SPI can support data lengths of two to sixteen bits. This can be configured in the data size register,
SPI_DSCTRL. When the data length is less than sixteen bits, the receive data register pads the upper bits
with zeros.
NOTE
Data can be lost if the data length is not the same for both master and slave
devices.
11.4.2.2
Data Shift Ordering
The SPI can be configured to transmit or receive the MSB of the desired data first or last. This is controlled
by the data shift order, DSO, bit in the SPI_SCTRL. Regardless of which bit is transmitted or received first,
the data shall always be written to the data transmit register, SPI_DXMIT, and read from the receive data
register, SPI_DRCV, with the LSB in bit 0 and the MSB in correct position depending on the data
transaction size.
11.4.2.3
Clock Phase and Polarity Controls
Software can select any of four combinations of serial clock (SCLK) phase and polarity using two bits in
the SPI control register (SPI_SCTRL). The clock polarity is specified by the CPOL control bit, which
selects an active high or low clock and has no significant effect on the transaction format.
The clock phase (CPHA) control bit selects one of two fundamentally different transaction formats. The
clock phase and polarity should be identical for the master SPI device and the communicating slave device.
In some cases, the phase and polarity are changed between transactions to allow a master device to
communicate with peripheral slaves having different requirements.
NOTE
Before writing to the CPOL bit or the CPHA bit, disable the SPI by clearing
the SPI enable bit (SPE).
11.4.2.4
Transaction Format When CPHA = 0
Figure 11-8 shows an SPI transaction in which CPHA is logic zero. The figure should not be used as a
replacement for data sheet parametric information. Two waveforms are shown for SCLK: one for
CPOL = 0 and another for CPOL = 1. The diagram may be interpreted as a master or slave timing diagram
since the serial clock (SCLK), master in/slave out (MISO), and master out/slave in (MOSI) pins are
directly connected between the master and the slave. The MISO signal is the output from the slave, and
the MOSI signal is the output from the master. When CPHA = 0, the first SCLK edge is the MSB capture
strobe. Therefore the slave must begin driving its data before the first SCLK edge, and a falling edge on
the SS pin is used to start the slave data transaction. The slave’s SS pin must be toggled back to high and
then low again between each data word transmitted, as shown in Figure 11-9.
When CPHA = 0 for a slave, the falling edge of SS indicates the beginning of the transaction. This causes
the SPI to leave its idle state and begin driving the MISO pin with the first bit of its data. After the
transaction begins, no new data is allowed into the shift register from the transmit data register. Therefore,
11-14
Freescale Semiconductor