
M0A21/M0A23 Series
May 06, 2022
Page
542
of 746
Rev 1.02
M0
A21
/M
0
A
2
3
SE
RIES
TEC
H
NICAL
RE
FEREN
C
E
M
ANUAL
SPI_CLK
SPI_MOSI
SPI_MISO
TX0[1]
TX0[7]
TX1[0]
TX1[1]
MSB
TX1[7]
RX0[1]
RX0[7]
RX1[1]
MSB
RX1[7]
LSB
RX0[0]
RX1[0]
LSB
TX0[0]
SPI_SS
SCLKMODE=0x1
SCLKMODE=0x3
Slave Mode: FUNMODE=0x1, SLAVE=1, SLV3WIRE=0,
LSB=1, DWIDTH=0x8
CTLIN0[ININV]=0
CTLIN0[ININV]=1
Figure 6.14-19 SPI Timing in Slave Mode (Alternate Phase of Serial Bus Clock)
Programming Flow
This section describes the programming flow for USCI SPI data transfer.
For Master mode:
1. Enable USCI peripheral clock by setting CLK_APBCLK1 register.
2. Configure user-specified pins as USCI function pins by setting corresponding multiple
function control registers.
3. Set FUNMODE (USPI_CTL[2:0]) to 1 to select SPI mode.
4. Set USPI_BRGEN register to determine the SPI bus clock frequency.
5. According to the requirements o
f user’s application, configure the settings as follows.
CTLOINV (USPI_LINECTL[7]): If the slave selection signal is active low, set this bit to 1;
otherwise, set it to 0.
DWIDTH (USPI_LINECTL[11:8]): Data width setting.
LSB (USPI_LINECTL[0]): LSB first or MSB first.
TSMSEL (USPI_PROTCTL[14:12]): Full-duplex SPI transfer or one channel half-duplex
SPI transfer.
SCLKMODE (USPI_PROTCTL[7:6]): Determine the clock timing.
AUTOSS (USPI_PROTCTL[3]): Enable automatic slave select function or not.
SLAVE (USPI_PROTCTL[0]): Set to 0 for Master mode.
Set PROTEN (USPI_PROTCTL[31]) to 1 to enable SPI protocol.
6. If automatic slave select function is disabled (AUTOSS=0), set SS (USPI_PROTCTL[2]) to 1
before data transfer; set SS to 0 to
inactivate the slave selection signal by user’s application.
7. Write USPI_TXDAT register to trigger SPI transfer. In half-duplex SPI transfer, the data pin
direction is determined by PORTDIR (USPI_TXDAT[16]) setting.
8. User can get the received data by reading USPI_RXDAT register as long as RXEMPTY
(USPI_BUFSTS[0]) is 0. The SPI data transfer can be triggered by writing USPI_TXDAT