MOTOROLA
6-10
QUEUED SERIAL MODULE
MC68331
USER’S MANUAL
6
6.3.5 QSPI Operating Modes
The QSPI operates in either master or slave mode. Master mode is used when the
MCU originates data transfers. Slave mode is used when an external device initiates
serial transfers to the MCU through the QSPI. Switching between the modes is con-
trolled by MSTR in SPCR0. Before either mode is entered, appropriate QSM and QSPI
registers must be initialized properly.
In master mode, the QSPI executes a queue of commands defined by control bits in
each command RAM queue entry. Chip-select pins are activated, data is transmitted
from transmit RAM and received by the receive RAM.
In slave mode, operation proceeds in response to SS pin activation by an external bus
master. Operation is similar to master mode, but no peripheral chip selects are gener-
ated, and the number of bits transferred is controlled in a different manner. When the
QSPI is selected, it automatically executes the next queue transfer to exchange data
with the external device correctly.
Although the QSPI inherently supports multimaster operation no special arbitration
mechanism is provided. A mode fault flag (MODF) indicates a request for SPI master
arbitration. System software must provide arbitration. Note that unlike previous SPI
systems, MSTR is not cleared by a mode fault being set nor are the QSPI pin output
drivers disabled. The QSPI and associated output drivers must be disabled by clearing
SPE in SPCR1.
Figure 6-4
shows QSPI initialization;
Figure 6-5
and
Figure 6-6
show QSPI master
and slave operation. The CPU must initialize the QSM global and pin registers and the
QSPI control registers before enabling the QSPI for either mode of operation (refer to
6.5 QSM Initialization
). The command queue must be written before the QSPI is en-
abled for master mode operation. Any data to be transmitted should be written into
transmit RAM before the QSPI is enabled. During wraparound operation, data for sub-
sequent transmissions can be written at any time.