NXP Semiconductors
QN902x
User Manual of QN902x
UM10996
All information provided in this document is subject to legal disclaimers.
© NXP Semiconductors N.V. 2018. All rights reserved.
User Manual
Rev 1.3
— 05 November 2018
76 of 128
10.
Serial Peripheral Interface (SPI0/SPI1)
The serial peripheral interface (SPI) can be used to communicate with external devices
using the SPI protocol supporting half-duplex, full-duplex and simplex synchronous serial
communication. The interface can be configured as master or slave device, in 4-wire (full-
duplex) or 3-wire (half-duplex) modes, and supports multiple slaves on a single SPI bus.
10.1
Features
Supports master or slave mode
Supports 4-wire (full-duplex) or 3-wire (half-duplex) modes
Clock speed up to 16MHz in master mode for 32MHz system clock
Clock speed up to 32/6MHz in slave mode for 32MHz system clock
Programmable clock polarity and phase
Slave select controlled by hardware or software in master mode
Programmable bit order with MSB-first or LSB-first shifting
Dedicated transmission and reception flags with interrupt capability
SPI bus busy status flag
10.2
Functional Description
The SPI allows synchronous, serial communication between the MCU and external
devices. The application software can manage the communication by polling the status
flag or using dedicated SPI interrupt.
Four I/O pins may be used for communication.
DAT
: data-out in 4-wire mode and data in/out in 3-wire mode
DIN
: data-in in 4-wire mode; Not used in 3-wire mode
SCK
: serial clock output for SPI master and input for SPI slave.
nCS0/1
: Slave select pin; Output for master and input for slave; Only nCS0 is
available for slave mode.
The SPI interface is shared with the GPIO pins. The SPIx_PIN_SEL(PIN_MUX_CTRL[0:1]) is
used to select the GPIO pins for SPI. The nCS0 and nCS1 are selected by
MSTR_SSx(CR0[14:15]).
10.2.1
Master Mode Operation
The SPI interface is programmed as a master device by setting SPI_MODE to 0. Once it is
enabled, it monitors the TX buffer (TXD) continuously. If it is not empty, the data in TX
buffer is moved to the transmit shift register, which shifts the data out serially on the DAT
line while providing the serial clock. If the TX buffer is not full, the TX_FIFO_NFUL_IF flag
is set to 1, to indicate that more data can be written into the buffer.
While the SPI master transfers data to a slave on the DAT line, the selected SPI slave
device simultaneously transfers the data in its shift register to the master on the DIN line
in a 4-wire operation. The data byte received from the slave is moved into the master's
RX buffer, where it can be read from the RXD.