GD32F20x User Manual
551
SPI 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 transmit buffer. 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 transmit buffer before
the transmission starts in slave mode.
When SPI begins to send a data frame, it loads this data frame from the data buffer to the
shift register first and then begins to transmit the loaded data frame, TBE (transmit buffer
empty) flag is set after the first bit of this frame is transmitted. After TBE flag is set, which
means the transmit buffer 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
The incoming data will be moved from shift register to the receive buffer after the last valid
sample clock and RBNE (receive buffer not empty) will be set also. The application should
read SPI_DATA register to get the received data and this will clear the RBNE flag
automatically. 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 transmit buffer is not empty.
SPI operation sequence in different modes (Not Quad-SPI)
In full-duplex mode, either MFD or SFD, application should monitor the RBNE and TBE flags
and follow the sequences described above.
The transmission mode (MTU, MTB, STU or STB) is similar to full-duplex mode, except that
application should ignore the RBNE and OVRE bits and only perform transmission sequence
described above.
In master reception mode (MRU or MRB), the behavior is different from full-duplex mode or
transmission mode. In MRU or MRB mode, the SPI continuously generates SCK just after
SPI is enabled, until the SPI is disabled. So the application should ignore the TBE flag and
read out reception buffer 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 full-duplex mode, except that application
should ignore the TBE flag and only perform reception sequence described above.
Summary of Contents for GD32F20 Series
Page 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Page 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Page 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Page 385: ...GD32F20x User Manual 385 ...
Page 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...