![GigaDevice Semiconductor GD32A50 Series Скачать руководство пользователя страница 558](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32a50-series/gd32a50-series_user-manual_2225782558.webp)
GD32A50x User Manual
558
place, several additional conditions must be met, users must also set the device into master
mode, and frame format should follow the normal SPI protocol, and set the data capture edge
to first clock transition.
In summary: NSSP = 1; MSTMOD = 1; CKPH = 0;
When active, a pluse duration of least 1 SCK clock priod is inserted between successive data
frames depending on internal data transmit buffer status, multiple SCK clock cycle interval is
possible if the transfer buffer stays empty. This function is designed for single master-slave
configuration for the slave to latch data. The following diagram depicts its timing diagram.
Figure 21-11. Timing diagram of NSS pulse with continuous transmit
NSS
SCK
MISO
MOSI
MSB
LSB
LSB
MSB
MSB
LSB
MSB
LSB
Don
t Care
Don
t Care
Don
t Care
1 SCK
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
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.