MAX32660 User Guide
Maxim Integrated
Page 183 of 195
14.3.2.2
SPI Slave Mode
When using SPI slave mode,
.mode = 0
, configure the slave select pin, SPI1_SS0, as an input by clearing
.ss_io
ssv
bit is not used in SPI slave mode.
14.3.3
SPI Character Size
SPI transmits and receives characters simultaneously. The transmit and receive character size is the same. Set the number
of bits per character using the
.numbits
field.
14.3.4
SPI Data Movement
Data movement in SPI mode is controlled using one of the following methods:
•
Synchronous operation
−
Application polling of the
txst
bit to transfer single words.
−
Application polling of the
tx_fifo_level
rx_fifo_level
fields enables transfers of up
to eight characters at a time.
•
Asynchronous Operation
−
irqe
bit can be set to enable data and error interrupts. The
.str bit may be used if
sir t f rc a “startup” ata int rrupt. ata int rrupt will b g n rat n c mpl ti n f ach charact r
transfer.
•
DMA Operation
−
Control of data transferred is enabled via the
rx_dma_en
tx_dma_en
bits.
tx_fifo_level
and
rx_fifo_level
control when DMA requests are asserted. When
DMA is enabled, the SPIMSS data interrupt is disabled by hardware, error interrupts remain available. DMA
operation is beneficial for block transfers as the CPU only needs to service one DMA interrupt per block of data
versus one interrupt for each character transferred if data interrupt-based transfer is used.
The SPIMSS Data Register,
, is used for transferring data for both transmit and receive operations.
For incoming data, the receive data is shifted into an internal shift register. Once a full character is received, the character is
automatically moved into the receive FIFO. Read received data using the
For outgoing data, data written to the
register is automatically moved to the transmit FIFO. The data is then
transmitted via the shift register. When the shift register is empty, any data in the transmit FIFO is moved to the shift
register.
Note: When the SPIMSS is not actively transmitting or receiving data (
.enable = 0), data written to the SPIMSS
Data Register is stored in the transmit FIFO, if the transmit FIFO is not full. Any data in the transmit FIFO when the SPIMSS
enable bit is set to 1 is transmitted immediately by the hardware. Flush the transmit FIFO at any time by setting the
.tx_fifo_clr bit to 1.
With the SPIMSS configured as a SPI master, writing data to the
register initiates the data transmission. With
the SPIMSS configured as a SPI slave, writing data
register loads the shift register in preparation for the next
data transfer with the external master. In either SPI master or slave mode, when the transmit FIFO is full, writes to the
register are ignored and result in a transmit overrun error interrupt (
tovr
= 1).
Data is shifted out starting with the most significant bit first (bit 15). The last bit received will reside in the least significant
bit, (bit 0). In SPI mode, when the character length is less than 16 bits, set by the
numbits
field, the transmit
character must be left justified in the
register. A received character of less than 16 bits is always right
justified, with the last bit received loaded into the least significant bit (bit 0). For example, if SPI1 is configured for 4-bit
characters, write transmit data to
[15:12]
and received characters are read from
[3:0]
.