2 additional considerations for a slave, 3 additional considerations for a master, 4 mode change on ss – NXP Semiconductors P89LPC9321 UM10310 User Manual

Page 89: Section 12.4 “mode change on ss, Section 12.4, Mode change on ss, To sl, P2.2, P2.5, Nxp semiconductors

Advertising
background image

UM10310

All information provided in this document is subject to legal disclaimers.

© NXP B.V. 2010. All rights reserved.

User manual

Rev. 2 — 1 November 2010

89 of 139

NXP Semiconductors

UM10310

P89LPC9321 User manual

[1]

Selected as a port function

[2]

The MSTR bit changes to logic 0 automatically when SS becomes low in input mode and SSIG is logic 0.

12.2 Additional

considerations for a slave

When CPHA equals zero, SSIG must be logic 0 and the SS pin must be negated and
reasserted between each successive serial byte. If the SPDAT register is written while SS
is active (low), a write collision error results. The operation is undefined if CPHA is logic 0
and SSIG is logic 1.

When CPHA equals one, SSIG may be set to logic 1. If SSIG = 0, the SS pin may remain
active low between successive transfers (can be tied low at all times). This format is
sometimes preferred in systems having a single fixed master and a single slave driving
the MISO data line.

12.3 Additional

considerations for a master

In SPI, transfers are always initiated by the master. If the SPI is enabled (SPEN = 1) and
selected as master, writing to the SPI data register by the master starts the SPI clock
generator and data transfer. The data will start to appear on MOSI about one half SPI
bit-time to one SPI bit-time after data is written to SPDAT.

Note that the master can select a slave by driving the SS pin of the corresponding device
low. Data written to the SPDAT register of the master is shifted out of the MOSI pin of the
master to the MOSI pin of the slave, at the same time the data in SPDAT register in slave
side is shifted out on MISO pin to the MISO pin of the master.

After shifting one byte, the SPI clock generator stops, setting the transfer completion flag
(SPIF) and an interrupt will be created if the SPI interrupt is enabled (ESPI, or IEN1.3 = 1).
The two shift registers in the master CPU and slave CPU can be considered as one
distributed 16-bit circular shift register. When data is shifted from the master to the slave,
data is also shifted in the opposite direction simultaneously. This means that during one
shift cycle, data in the master and the slave are interchanged.

12.4 Mode change on SS

If SPEN = 1, SSIG = 0 and MSTR = 1, the SPI is enabled in master mode. The SS pin can
be configured as an input (P2M2.4, P2M1.4 = 00) or quasi-bidirectional (P2M2.4, P2M1.4
= 01). In this case, another master can drive this pin low to select this device as an SPI

1

0

1

1

Master

(idle)

input

Hi-Z

Hi-Z

MOSI and SPICLK are at high-impedance to
avoid bus contention when the MAster is idle.
The application must pull-up or pull-down
SPICLK (depending on CPOL - SPCTL.3) to
avoid a floating SPICLK.

Master

(active)

output

output

MOSI and SPICLK are push-pull when the
Master is active.

1

1

P2.4

[1]

0

Slave

output

input

input

1

1

P2.4

[1]

1

Master

input

output

output

Table 82.

SPI master and slave selection

…continued

SPEN

SSIG

SS Pin MSTR

Master
or Slave
Mode

MISO

MOSI

SPICLK Remarks

Advertising