![GigaDevice Semiconductor GD32E23 Series Скачать руководство пользователя страница 506](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32e23-series/gd32e23-series_user-manual_2225794506.webp)
GD32E23x User Manual
506
Note:
During communication, CKPH, CKPL, MSTMOD, PSC[2:0], LF and DZ[3:0] bits
should not be changed.
Basic transmission and reception sequence
Transmission sequence
After the initialization sequence, the SPI is enabled and stays at idle state. In master mode,
the transmission starts when the application writes a data into the transmission
buffer/TXFIFO. In slave mode the transmission starts when SCK clock signal begins to
toggle at SCK pin and NSS level is low, so application should ensure that data is already
written into transmission buffer/TXFIFO before the transmission starts in slave mode.
When SPI begins to send a data frame, it first loads this data frame from the transmission
buffer/TXFIFO to the shift register and then begins to transmit the loaded data frame. After
TBE flag is set, which means the transmission buffer/TXFIFO is empty, the application
should write SPI_DATA register again if it has more data to transmit.
In master mode, software should write the next data into SPI_DATA register before the
transmission of current data frame is completed if it desires to generate continuous
transmission.
Reception sequence
After the last valid sample clock, the incoming data will be moved from shift register to the
reception buffer/RXFIFO and RBNE will be set. The application should read SPI_DATA
register to get the received data and this will clear the RBNE flag automatically when
reception buffer/RXFIFO is empty. In MRU and MRB modes, hardware continuously sends
clock signal to receive the next data frame, while in full-duplex master mode (MFD),
hardware only receives the next data frame when the transmission buffer/TXFIFO is not
empty.
SPI operation sequence in different modes (not Quad-SPI, TI mode or NSSP
mode)
In full-duplex mode, either MFD or SFD, the RBNE and TBE flags should be monitored and
then follow the sequences described above.
The transmission mode (MTU, MTB, STU or STB) is similar to the transmission sequence of
full-duplex mode except that the RBNE bit and RXORERR bit need to be ignored.
The master reception mode (MRU or MRB) is different from the reception sequence of
full-duplex mode. In MRU or MRB mode, after SPI is enabled, the SPI continuously
generates SCK until the SPI is disabled. So the application should ignore the TBE flag and
read out reception buffer/RXFIFO in time after the RBNE flag is set, otherwise a data overrun
fault will occur.
The slave reception mode (SRU or SRB) is similar to the reception sequence of full-duplex