GD32W51x User Manual
676
Figure 20-6. A typical simplex connection (Master: Transmit only, Slave: Receive)
Master
MTU
MISO
MOSI
SCK
NSS
Slave
SRU
MISO
MOSI
SCK
NSS
Figure 20-7. A typical bidirectional connection
Master
MTB/MRB
MISO
MOSI
SCK
NSS
Slave
SRB/STB
MISO
MOSI
SCK
NSS
SPI initialization sequence
Before
transmiting or receiving
data, application should follow the SPI initialization sequence
described below:
1.
If master mode or slave TI mode is used, program the PSC [2:0] bits in SPI_CTL0 register
to generate SCK with desired baud rate or configure the Td time in TI mode, otherwise,
ignore this step.
2.
Program data format (FF16 bit in the SPI_CTL0 register).
3.
Program the clock timing register (CKPL and CKPH bits in the SPI_CTL0 register).
4.
Program the frame format (LF bit in the SPI_CTL0 register).
5.
Program the NSS mode (SWNSSEN and NSSDRV bits in the SPI_CTL0 register)
according to the application
’s demand as described above in
section.
6.
If TI mode is used, set TMOD bit in SPI_CTL1 register, otherwise, ignore this step.
7.
Configure MSTMOD, RO, BDEN and BDOEN depending on the operating modes
described in
section.
8.
If Quad-SPI mode is used, set the QMOD bit in SPI_QCTL register. Ignore this step if
Quad-SPI mode is not used.
9.
Enable the SPI (set the SPIEN bit).