www
.mcu.com.cn
166
/
239
Rev.
1.00
CMS80F731x Reference Manual
20.2 SPI Port Configuration
Using the SPI function requires configuring the relevant port as an SPI channel and selecting the corresponding port input
through the communication input port registers. For example, configure P00, P01, P02, and P03 as SPI communication ports.
The configuration code is as follows:
PS_SCLK = 0x00; Select P00 as the SCLK channel for the SPI
PS_MOSI = 0x01; Select P01 for the MOSI channel for the SPI
PS_MISO = 0x02; Select P02 as the MISO channel for the SPI
PS_NSS = 0x03; Select P03 as the NSS channel for the SPI
P00CFG = 0x03; P00 multiplexing for SCLK function
P01CFG = 0x03; P01 multiplexing for MOSI function
P02CFG = 0x03; P02 multiplexing for MISO function
P03CFG = 0x03; P03 multiplexing for NSS function
Configured as SCLK, MOSI, MISO, and NSS ports, its pull-up resistor and the open-drain output are forced off. The
schematic diagram of the multi-slave SPI communication structure is shown in the following figure:
MOSI
MISO
SCLK
SPI Slave
device
SPI Slave
device
SPI Slave
device
SPI Slave
device