GD32W51x User Manual
680
checks TBE status at the end of a frame and stops when condition is not met.
The operation flow for transmitting in quad mode is shown below:
1. Configure clock prescaler, clock polarity, phase, etc. in SPI_CTL0 and SPI_CTL1 based
on application requirements.
2. Set QMOD bit in SPI_QCTL register and then enable SPI by setting SPIEN in SPI_CTL0.
3. Write a byte of data to SPI_DATA register and the TBE will be cleared.
4. Wait until TBE is set by hardware again before writing the next byte.
Figure 20-11. Timing diagram of quad write operation in Quad-SPI mode
D1[5]
D1[4]
D1[6]
D1[7]
D1[0]
D1[1]
D1[2]
D1[3]
SCK
MOSI
MISO
IO2
IO3
TBE
D2[4]
D2[6]
D2[7]
D2[0]
D2[1]
D2[2]
D2[3]
D2[5]
Software writes
SPI_DATA
Hadware sets TBE
again
Quad read operation
SPI works in quad read mode when QMOD and QRD bits are both set in SPI_QCTL register.
In this mode, MOSI, MISO, IO2 and IO3 are all used as input pins. SPI begins to generate
clock on SCK line as soon as a data is written into SPI_DATA (TBE is cleared) and SPIEN is
set. Writing data into SPI_DATA is only to generate SCK clocks, so the written data can be
any value. Once SPI starts transmission, it always checks SPIEN and TBE status at the end
of a frame and stops when condition is not met. So, dummy data should always be written
into SPI_DATA to generate SCK.
The operation flow for receiving in quad mode is shown below:
1. Configure clock prescaler, clock polarity, phase, etc. in SPI_CTL0 and SPI_CTL1
register based on application requirements.
2. Set QMOD and QRD bits in SPI_QCTL register and then enable SPI by setting SPIEN
in SPI_CTL0 register.
3. Write an arbitrary byte (for example, 0xFF) to SPI_DATA register.
4. Wait until the RBNE flag is set and read SPI_DATA to get the received byte.