Serial Peripheral Interface (SPI)
7-330
MC68360 USER’S MANUAL
MOTOROLA
12.Write $00000020 to the CIMR to allow the SPI to generate a system interrupt.
(The CICR should also be initialized.)
13.Write $0370 to SPMODE to enable normal operation (not loopback), master
mode, SPI enabled, 8-bit characters, and the fastest speed possible.
14.Write PBDAT bit 0 with zero to assert the SPI select pin.
15.Set the STR bit in the SPCOM to start the transfer.
NOTE
After 5 bytes have been transmitted, the Tx BD is closed. Addi-
tionally, the receive buffer is closed after 5 bytes have been re-
ceived because the L-bit of the Tx BD was set.
7.12.7 SPI Slave Example
The following list is an initialization sequence for use of the SPI as a slave. It is very similar
to the SPI master example except that the SPISEL pin is used, rather than a general-pur-
pose I/O pin.
1. The SDCR (SDMA Configuration Register) should be initialized to $0740, rather than
being left at its default value of $0000.
2. Configure the port B pins to enable the SPIMOSI, SPIMISO, SPISEL, and SPICLK
pins. Write PBPAR bits 0, 1, 2, and 3 with ones. Write PBDIR bits 0, 1, 2, and 3
with ones. Write PBODR bits 0, 1, 2, and 3 with zeros.
3. Write RBASE and TBASE in the SPI parameter RAM to point to the Rx BD and Tx
BD in the dual-port RAM. Assuming one Rx BD at the beginning of dual-port RAM
and one Tx BD following that Rx BD, write RBASE with $0000 and TBASE with
$0008.
4. Program the CR to execute the INIT RX & TX PARAMS command for this channel.
For instance, to execute this command for SCC1, write $0001 to the CR. This com-
mand causes the RBPTR and TBPTR parameters of the serial channel to be updated
with the new values just programmed into RBASE and TBASE.
5. Write RFCR with $18 and TFCR with $18 for normal operation.
6. Write MRBLR with the maximum number of bytes per receive buffer. For this case,
assume 16 bytes, so MRBLR = $0010.
7. Initialize the Rx BD. Assume the Rx data buffer is at $00001000 in main memory.
Write $B000 to Rx_BD_Status. Write $0000 to Rx_BD_Length (not required—
done for instructional purposes only). Write $00001000 to Rx_BD_Pointer.
8. Initialize the Tx BD. Assume the Tx data buffer is at $00002000 in main memory
and contains five 8-bit characters. Write $B800 to Tx_BD_Status. Write $0005 to
Tx_BD_Length. Write $00002000 to Tx_BD_Pointer.
9. Write $FF to the SPIE to clear any previous events.
10.Write $37 to the SPIM to enable all possible SPI interrupts.
11.Write $00000020 to the CIMR to allow the SPI to generate a system interrupt. (The