MS51
Nov. 28, 2019
Page
434
of 491
Rev 1.00
MS51
32K
SE
RIES
TE
CHNICAL RE
F
EREN
CE MA
N
UAL
6.12.4 Slave Select Pin Configuration
The MS51 SPI gives a flexible
SS
̅̅̅̅̅
pin feature for different system requirements. When the SPI
operates as a Slave,
SS
̅̅̅̅̅
pin always rules as Slave select input. When the Master mode is enabled,
SS
̅̅̅̅̅
has three different functions according to DISMODF (SPInSR.3) and SSOE (SPInCR.7). By default,
DISMODF is 0. It means that the Mode Fault detection activates.
SS
̅̅̅̅̅
is configured as a input pin to
check if the Mode Fault appears. On the contrary, if DISMODF is 1, Mode Fault is inactivated and the
SSOE bit takes over to control the function of the
SS
̅̅̅̅̅
pin. While SSOE is 1, it means the Slave select
signal will generate automatically to select a Slave device. The
SS
̅̅̅̅̅
as output pin of the Master usually
connects with the
SS
̅̅̅̅̅
input pin of the Slave device. The
SS
̅̅̅̅̅
output automatically goes low for each
transmission when selecting external Slave device and goes high during each idle state to de-select
the Slave device. While SSOE is 0 and DISMODF is 1,
SS
̅̅̅̅̅
is no more used by the SPI and reverts to
be a general purpose I/O pin.
6.12.5 Mode Fault Detection
The Mode Fault detection is useful in a system where more than one SPI devices might become
Masters at the same time. It may induce data contention. When the SPI device is configured as a
Master and the
SS
̅̅̅̅̅
input line is configured for Mode Fault input depending on Table 6.12-1 Slave
Select Pin Configurations, a Mode Fault error occurs once the
SS
̅̅̅̅̅
is pulled low by others. It indicates
that some other SPI device is trying to address this Master as if it is a Slave. Instantly the MSTR and
SPIEN control bits in the SPInCR are cleared via hardware to disable SPI, Mode Fault flag MODF
(SPInSR.4) is set and an interrupt is generated if ESPI and EA are enabled.
6.12.6 Write Collision Error
The SPI is signal buffered in the transfer direction and double buffered in the receiving and transmit
direction. New data for transmission cannot be written to the shift register until the previous transaction
is complete. Write collision occurs while SPInDR be written more than once while a transfer was in
progress. SPInDR is double buffered in the transmit direction. Any writing to SPInDR cause data to be
written directly into the SPI shift register. Once a write collision error is generated, WCOL (SPInSR.6)
will be set as 1 via hardware to indicate a write collision. In this case, the current transferring data
continues its transmission. However the new data that caused the collision will be lost. Although the
SPI logic can detect write collisions in both Master and Slave modes, a write collision is normally a
Slave error because a Slave has no indicator when a Master initiates a transfer. During the receiving
of Slave, a write to SPInDR causes a write collision in Slave mode. WCOL flag needs to be cleared via
software.
6.12.7 Overrun Error
For receiving data, the SPI is double buffered in the receiving direction. The received data is
transferred into a parallel read data buffer so the shifter is free to accept a second serial byte.
However, the received data should be read from SPInDR before the next data has been completely
shifted in. As long as the first byte is read out of the read data buffer and SPIF is cleared before the
next byte is ready to be transferred, no overrun error condition occurs. Otherwise the overrun error
occurs. In this condition, the second byte data will not be successfully received into the read data
register and the previous data will remains. If overrun occur, SPIOVF (SPInSR.5) will be set via
hardware. An SPIOVF setting will also require an interrupt if enabled. Figure 6.12-7 SPI Overrun
Waveform shows the relationship between the data receiving and the overrun error.