
NUC126
Aug. 08, 2018
Page
790
of 943
Rev 1.03
NUC12
6 S
E
RI
E
S
T
E
CH
NI
CA
L R
E
F
E
RE
NCE
MA
NUA
L
4. Set USPI_BRGEN register to determine the SPI bus clock frequency.
5.
According to the requirements of user’s application, configured 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.
6. Set PROTEN (USPI_PROTCTL[31]) to 1 to enable SPI protocol.
7. 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.
8. 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.
9. 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
register as long as TXFULL (USPI_BUFSTS[9]) is 0.
For Slave 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. According to the requirements o
f user’s application, configure the settings as follows.
ININV (USPI_CTLIN0[2]): 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.
SLAVE (USPI_PROTCTL[0]): Set to 1 for Slave mode.
5. Set PROTEN (USPI_PROTCTL[31]) to 1 to enable SPI protocol.
6. Write USPI_TXDAT register for transmission. In half-duplex SPI transfer, the data pin direction
is determined by PORTDIR (USPI_TXDAT[16]) setting.
7. User can get the received data by reading USPI_RXDAT register as long as RXEMPTY
(USPI_BUFSTS[0]) is 0. The next datum for transmission can be written to USPI_TXDAT
register as long as TXFULL (USPI_BUFSTS[9]) is 0.
6.21.5.13 Wake-up Function
The USCI Controller in SPI mode supports wake-up system function. The wake-up source in SPI