Specifications

101
3706C–MICRO–2/11
AT89LP3240/6440
and if the ENH bit in SPSR is set. For multi-byte transfers, TXE may be used to remove any
dead time between byte transmissions.
The SPI master can operate in two modes : multi-master mode a nd single-master mode. By
default, multi-master mode is active when SSIG = 0. In this mode, the SS
input is used to dis-
able a master device when another master is accessing the bus. When SS
is driven low, the
master device becomes a slave by clearing its MSTR b it and a Mode Fault is generated by set-
ting the MODF bit in SPSR. MODF will generate an interrupt if enabled. The MSTR bit must be
set in software b efore the device may become a master again. Single-master mode is enabled
by setting SSIG = 1. In this mode SS
is ignored and the mas ter is always active. SS may be
used as a general purpose I/O in this mode.
17.2 Slave Operation
When the AT89LP3240/6440 is not configured for master operation, MSTR = 0, it will operate as
an SPI slave. In slave mode, bytes are shifted in through MOSI and out through MISO by a mas-
ter device controlling the serial clock on SCK. When a byte has been transferred, the SPIF flag
is set to “1” and an interrupt request is generated, if enabled. The data
received from the
addressed master device is also transferred from the shift register to the receive buffer. The
received data is accessed by reading SPDR. A slave device cannot initiate tra nsfers. Data to be
transferred to the master device must be preloaded by writing to SPDR. Writes to SPDR are
double-buffered. The transmit buffer is loaded first a
nd if the shift register is empty, the contents
of the buffer will be transferred to the shift register.
While the TXE flag is set, the transmit buffer is empty. TXE can be cleared by software or by
writing to SPDR. Writing to SPDR will clear TXE and load the transmit buffer. The user may load
the buffer while the shift register is busy, i.e. before the current transfer completes. When the
current transfer complete
s, the queued byte in the transmit buffer is moved to the shift register
and waits for the master to initiate another transfer. TXE will generate an interrupt if the SPI
interrupt is enabled and if the ENH bit in SPSR is set.
The SPI slave can operate in two modes: 4-wire mode and 3-wire mode. By default, 4-wire
mode is active when SSIG = 0. In this mode, the SS
input is used to enable/disable the slave
device when addressed by a master. When SS
is driven low, the slave device is enabled and will
shift out data on MISO in response to the serial clock on SCK. While SS
is high, the SPI slave
will remain sleeping with MISO inactive. Three-wire mode is enabled by setting SSIG = 1. In this
mode SS
is ignored and the slave is always active. SS may be used as a general purpose I/O in
this mode.
The Disable Slave Output bit, DISSO in SPSR, may be used to disable the MISO line of a slave
device. DISSO can allow several slave devices to share MISO while operating in 3-wire mode. In
this case some protocol other than SS
may be used to determine which slave is enabled.
17.3 Pin Configuration
When the SPI is enabled (SPE = 1), the data direction of the MOSI, MISO, SCK, and SS pins is
automatically overridden according to the MSTR b it as shown in Table 17-1. The user need not
reconfigure the pins when switching from master to slave or vice-versa. For more details on port
configuration, refer to “Port Configuration” on page 45.