Write Collision; Data Mode - Philips P89LPC938 User Manual

Single-chip microcontroller
Table of Contents

Advertisement

Philips Semiconductors
slave and start sending data to it. To avoid bus contention, the SPI becomes a slave. As a
result of the SPI becoming a slave, the MOSI and SPICLK pins are forced to be an input
and MISO becomes an output.
The SPIF flag in SPSTAT is set, and if the SPI interrupt is enabled, an SPI interrupt will
occur.
User software should always check the MSTR bit. If this bit is cleared by a slave select
and the user wants to continue to use the SPI as a master, the user must set the MSTR bit
again, otherwise it will stay in slave mode.

13.5 Write collision

The SPI is single buffered in the transmit direction and double buffered in the receive
direction. New data for transmission can not be written to the shift register until the
previous transaction is complete. The WCOL (SPSTAT.6) bit is set to indicate data
collision when the data register is written during transmission. In this case, the data
currently being transmitted will continue to be transmitted, but the new data, i.e., the one
causing the collision, will be lost.
While write collision is detected for both a master or a slave, it is uncommon for a master
because the master has full control of the transfer in progress. The slave, however, has no
control over when the master will initiate a transfer and therefore collision can occur.
For receiving data, received data is transferred into a parallel read data buffer so that the
shift register is free to accept a second character. However, the received character must
be read from the Data Register before the next character has been completely shifted in.
Otherwise. the previous data is lost.
WCOL can be cleared in software by writing a logic 1 to the bit.

13.6 Data mode

Clock Phase Bit (CPHA) allows the user to set the edges for sampling and changing data.
The Clock Polarity bit, CPOL, allows the user to set the clock polarity.
Figure 45
User manual
show the different settings of Clock Phase bit CPHA.
Rev. 03 — 7 June 2005
UM10119
P89LPC938 User manual
Figure 42
to
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
96 of 139

Advertisement

Table of Contents
loading

Table of Contents