GD32W51x User Manual
679
Figure 20-10. Timing diagram of TI slave mode
D7
D6
D5
D4
D3
D2
D1
D0
D7
D6
D5
D4
D3
D2
D1
D0
SCK
NSS
MOSI
MISO
sample
Td
In slave TI mode, after the last rising edge of SCK in transfer, the slave begins to transmit the
LSB bit of the last data byte, and after a half-bit time, the master begins to sample the line.
To make sure that the master samples the right value, the slave should continue to drive this
bit after the falling sample edge of SCK for a period of time before releas ing the pin. This time
is called
T
d
.
T
d
is decided by PSC[2:0] bits in SPI_CTL0 register.
T
d
=
T
bit
2
+5*T
pclk
(20-1)
For example, if PSC[2:0] = 010,
T
d
is
9*T
pclk
.
In slave mode, the slave also monitors the NSS signal and sets an error flag FERR if it detects
an incorrect NSS behavior, for example, toggles at the middle bit of a byte.
Quad-SPI mode operation sequence
The Quad-SPI mode is designed to control Quad-SPI flash.
In order to enter Quad-SPI mode, the software should first verify that the TBE bit is set and
TRANS bit is cleared, then set QMOD bit in SPI_QCTL register. In Quad-SPI mode, BDEN,
BDOEN, CRCEN, CRCNT, FF16, RO and LF bits in SPI_CTL0 register should be kept
cleared and MSTMOD should be set to ensure that SPI is in master mode. SPIEN, PSC,
CKPL and CKPH bits should be configured as desired.
There are two operation modes in Quad-SPI mode: quad write and quad read, decided by
QRD bit in SPI_QCTL register.
Quad write operation
SPI works in quad write mode when QMOD is set and QRD is cleared in SPI_QCTL register.
In this mode, MOSI, MISO, IO2 and IO3 are all used as output pins. SPI begins to generate
clock on SCK line and transmit data on MOSI, MISO, IO2 and IO3 as soon as data is written
into SPI_DATA (TBE is cleared) and SPIEN is set. Once SPI starts transmission, it always