
GD32L23x User Manual
519
A write access to the SPI_DATA register stores the written data in the end of TXFIFO, while
a read access to the SPI_DATA returns the oldest value in RXFIFO which has not been read.
Write access of a data frame to be transmitted is managed by the TBE event. This event is
triggered when the TXFIFO level is less than or equal to half of its capacity, and at the time
the TXFIFO is considered as empty
(1)
. When TBE is cleared, the TXFIFO is considered as
full. A read access to SPI_DATA is managed by the RBNE event. This is triggered when
RXFIFO is not considered to be empty
(2)
. When RBNE is cleared, the RXFIFO is considered
to be empty. In this way, when the data frame format is not greater than 8 bits, RXFIFO can
store up to 4 data frames while TXFIFO can only store up to three.
Note:
(1) For SPI0, the TXFIFO empty means that the TXFIFO level is less than or equal to
half of its capacity. The meaning of TXFIFO full is the opposite. If the TXFIFO empty or full
appears below and
there is no special explanation, the meaning is the same as this.
(2) For SPI0, the meaning of RXFIFO empty is divided into the following two conditions: If
BYTEN bit in SPI_CTL1 is set, the RXFIFO empty means the RXFIFO level is less than
quarter of its capacity. If BYTEN is cleared, the RXFIFO empty means the RXFIFO level is
less than half of its capacity The meaning of RXFIFO full is the opposite. If the RXFIFO empty
or full appears below and
there is no special explanation, the meaning is the same as this.
Data packing
When the data frame size is less than or equal to 8 bits, data packing mode is automatically
enabled when BYTEN is set as 0. The double data frame pattern is handled in parallel in this
case. At first, the SPI operates using the pattern stored in the LSB of the accessed word, then
with the other half stored in the MSB. Two data frames are sent after the single 16-bit access
the SPI_DATA register of the transmitter. At the receiving end, two data frames are received
simultaneously can generate just one RBNE event in the receiver if BYTEN is set as 0. The
receiver then has to access both data frames by a single 16-bit read of SPI_DATA.
Note:
when an odd number of data bytes will be transferred, on the transmitter side, writing
the last data frame of any odd sequence with an 8-bit access to SPI_DATA is enough. The
receiver has to change BYTEN for the last data frame received in the odd sequence of frames
in order to generate the RBNE event.
22.5.3.
NSS function
Slave mode
When slave mode is configured (MSTMOD=0), SPI gets NSS level from NSS pin in hardware
NSS mode (SWNSSEN = 0) or from SWNSS bit in software NSS mode (SWNSSEN = 1) and
transmits/receives data only when NSS level is low. In software NSS mode, NSS pin is not
used.