![Texas Instruments AM1808 Technical Reference Manual Download Page 1434](http://html.mh-extra.com/html/texas-instruments/am1808/am1808_technical-reference-manual_10945581434.webp)
Architecture
1434
SPRUH82C – April 2013 – Revised September 2016
Copyright © 2013–2016, Texas Instruments Incorporated
Serial Peripheral Interface (SPI)
29.2.17 General-Purpose I/O Pin
Each of the SPI pins may be programmed via the SPI pin control registers (SPIPC0 to SPIPC5) to be a
general-purpose I/O (GPIO) pin.
When the SPI pins are not used as functional pins, they may be programmed to be either general input or
general output pins by configuring SPIPC0. For example, in 3-pin mode, SPIx_SOMI, SPIx_SIMO, and
SPIx_CLK must be configured as SPI pins, while the SPIx_SCS[n] and SPIx_ENA pins should be
configured as GPIO pins. The direction is controlled by configuring SPIPC1.
If configured as a general-purpose output, then SPIPC3 controls the output value. There is also a write 1
to set (SPIPC4) and a write 1 to clear (SPIPC5) for the data out value. These registers allow different
tasks running on the CPU to manipulate the SPI I/O pins without read-modify-write hazards.
SPIPC2 reflects the current value on the pin when the particular pin is configured as a functional or
general-purpose input pin. When the pin is configured as a functional or general-purpose output pin,
SPIPC2 indicates the value that is attempted to be driven on the pin.
29.2.18 Emulation Considerations
CAUTION
Viewing or otherwise reading the following SPI registers: SPIBUF, SPIFLG, and
INTVEC1 through the JTAG debugger causes their contents to change,
possibly invalidating the results of the debug session. Be sure to set up the
debugger to avoid reading these registers.
The SPI module does not support soft or hard stop during emulation breakpoints. The SPI module will
continue to run if an emulation breakpoint is encountered.
In addition, any status registers that are cleared after reading will be affected if viewed in a memory or
watch window of the debugger; since the emulator will read these registers to update the value displayed
in the window.
29.2.19 Initialization
Perform the following procedure for initializing the SPI:
1. Reset the SPI by clearing the RESET bit in the SPI global control register 0 (SPIGCR0) to 0.
2. Take the SPI out of reset by setting SPIGCR0.RESET to 1.
3. Configure the SPI for master or slave mode by configuring the CLKMOD and MASTER bits in the SPI
global control register 1 (SPIGCR1).
4. Configure the SPI for 3-pin, 4-pin with chip select, 4-pin with enable, or 5-pin mode by configuring the
SPI pin control register 0 (SPIPC0).
5. Chose the SPI data format register
n
(SPIFMT
n
) to be used by configuring the DFSEL bit in the SPI
transmit data register (SPIDAT1). In slave mode, only SPIFMT0 is supported.
6. Configure the SPI data rate, character length, shift direction, phase, polarity and other format options
using SPIFMT
n
selected in step 5.
7. If SPI master, then configure the master delay options using the SPI delay register (SPIDELAY). In
slave mode, SPIDELAY is not relevant.
8. Select the error interrupt notifications by configuring the SPI interrupt register (SPIINT0) and the SPI
interrupt level register (SPILVL).
9. Enable the SPI communication by setting the SPIGCR1.ENABLE to 1.
10. Setup and enable the DMA for SPI data handling and then enable the DMA servicing for the SPI data
requests by setting the SPIINT0.DMAREQEN to 1.
11. Handle SPI data transfer requests using DMA and service any SPI error conditions using the interrupt
service routine.