9- 30
MC68341 USER’S MANUAL
MOTOROLA
the transmit data segment with information to be sent, and c) enabled the QSPI, the QSPI
operates independently of the CPU. The QSPI executes all of the commands in its queue,
sets a flag indicating completion, and then either interrupts the CPU or waits for CPU
intervention.
The QSPI operates on a queue data structure contained in the QSPI RAM. Control of the
queue is handled by three pointers: the new queue pointer (NEWQP), the completed
queue pointer (CPTQP), and the end queue pointer (ENDQP). NEWQP, contained in
SPCR2, points to the first command in the queue to be executed by the QSPI. CPTQP,
contained in SPSR, points to the command last executed by the QSPI. ENDQP, also
contained in SPCR2, points to the last command in the queue to be executed by the
QSPI, unless wraparound mode is enabled (WREN = 1).
At reset, NEWQP is initialized to $0, causing QSPI execution to begin at queue address
$0 when the QSPI is enabled (SPE = 1). CPTQP is set by the QSPI to the queue address
($0-$F) last executed, but is initialized to $0 at reset. ENDQP is also initialized to $0 at
reset, but should be changed by the user to reflect the last queue entry to be transferred
before enabling the QSPI. Leaving NEWQP and ENDQP set to $0 causes a single
transfer to occur when the QSPI is enabled.
The organization of the QSPI RAM defines that one byte of command control data, one
word of transmit data, and one word of receive data all correspond to one queue entry, $0-
$F.
After executing the current command, ENDQP is checked against CPTQP for an end-of-
queue condition. If a match occurs, the SPIF flag is set and the QSPI stops unless
wraparound mode is enabled.
The QSPI operates in one of two modes: master or slave. Master mode is used when the
MC68341 originates all data transfers. Slave mode is used when another device or a
peripheral to the MC68341 initiates all serial transfers to the MC68341 via the QSPI.
Switching between the two operating modes is achieved under software control by writing
to the master (MSTR) bit in SPCR0.
In master mode, the QSPI executes the queue of commands as defined by the control bits
in each entry. Chip-select pins are activated; data is transmitted, received, and placed in
the QSPI RAM.
In slave mode, a similar operation occurs in response to the slave select (SS) pin
activated by an external SPI bus master. The primary differences are a) no peripheral chip
selects are generated, and b) the number of bits transferred is controlled in a different
manner. When the QSPI is selected, it executes the next queue transfer to correctly
exchange data with the external device.
The following flowcharts, Figures 9-6–9-8, outline the operation of the QSPI for both
master and slave modes. Note that the CPU must initialize the QSPM global and pin
registers and the QSPI control registers before enabling the QSPI for either master or
slave operation. If using master mode, the necessary command control RAM should also
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
..
.