![](http://datasheet.mmic.net.cn/270000/MC68HC11A8_datasheet_16036735/MC68HC11A8_217.png)
M68HC11
REFERENCE MANUAL
SYNCHRONOUS SERIAL PERIPHERAL INTERFACE
MOTOROLA
8-9
Bit 5 — Not implemented; always reads zero.
MODF — Mode-Fault Error Flag
This flag is set if the SS signal goes to active low while the SPI is configured as a mas-
ter (MSTR = 1). MODF is automatically cleared by reading the SPSR with MODF set,
followed by a write to the SPCR. Because the mode-fault mechanism is intended to
prevent damage due to conflicts between output drivers, it takes effect immediately,
regardless of the SPI system configuration at the time of the fault. The MSTR control
bit in the SPCR and all four DDRD control bits associated with the SPI are cleared,
and an interrupt is generated subject to masking by the SPIE control bit and the I bit
in the CCR. Mode-fault errors are discussed in greater detail in the following para-
graphs.
8.5 SPI System Errors
Two system errors can be detected by the SPI system in the MC68HC11A8. The first
type error arises in a multiple-master system when more than one SPI device simulta-
neously tries to be a master. This error is called a mode fault. The second type error,
a write collision, indicates that an attempt has been made to write data to the SPDR
while a transfer was in progress.
8.5.1 SPI Mode-Fault Error
When the SPI system is configured as a master and the SS input line goes to active
low, a mode-fault error has occurred. Only an SPI master can experience a mode-fault
error, caused when a second SPI device becomes a master and selects this device as
if it were a slave. In cases where more than one device is concurrently configured as
a master, there is a chance of contention between two pin drivers. For push-pull CMOS
drivers, this contention can cause catastrophic latchup. When this type error is detect-
ed, the following actions are taken immediately:
1. The DDRD bits corresponding to the four SPI-related I/O pins are forced to zero
to disable all SPI output drivers.
2. The MSTR control bit is forced to zero to reconfigure the SPI as a slave.
3. The SPE control bit is forced to zero to disable the SPI system.
4. The MODF status flag is set, and an SPI interrupt is generated subject to mask-
ing by the SPIE bit and the I bit in the CCR.
After software has corrected the problems that led to the mode fault, MODF is cleared
and the system is returned to normal operation. The MODF flag is automatically
cleared by reading SPSR while MODF is set, followed by a write to the SPDR. The
DDRD must also be restored before SPI transfers can resume.
In some cases, the mode-fault mechanism does not fully protect multiple-master sys-
tems from driver contention. For example, suppose a second device becomes a mas-
ter but does not immediately drive the SS pin of this master low. Perhaps a system
fault selects two slave devices, and these slave devices try to simultaneously drive the