GD32W51x User Manual
696
(RBNE is low). When a reception sequence finishes, the received data in the shift register is
loaded into the receive buffer (RBNE goes high). The data should be read from the SPI_DATA
register, when the RBNE flag is high. After a read operation to the SPI_DATA register, the
RBNE flag goes low. It is mandatory to read the SPI_DATA register before the end of the next
reception. Otherwise, reception overrun error occurs. The RXORERR flag is set and an
interrupt may be generated if the ERRIE bit in the SPI_CTL1 register is set. In this case, it is
necessary to disable and then enable I2S before resuming the communication.
For all standards except PCM, the I2SCH flag is used to distinguish which channel side the
received data belongs to. The I2SCH flag is refreshed at the moment when the RBNE flag
goes high.
Different sequences are used to disable the I2S in different standards, data length and
channel length. The sequences for each case are described below.
16-bit data packed in 32-bit frame in the LSB justified standard (DTLEN = 00, CHLEN =
1, and I2SSTD = 10)
1. Wait for the second last RBNE.
2. Then wait 17 I2S CK clock (clock on I2S_CK pin) cycles.
3. Clear the I2SEN bit.
16-bit data packed in 32-bit frame in the audio standards except the LSB justified
standard (DTLEN = 00, CHLEN = 1, and I2SSTD is not equal to 0b10)
1. Wait for the last RBNE.
2. Then wait one I2S clock cycle.
3. Clear the I2SEN bit.
For all other cases
1. Wait for the second last RBNE.
2. Then wait one I2S clock cycle.
3. Clear the I2SEN bit.
I2S slave transmission sequence
The transmission sequence in slave mode is similar to that in master mode. The differences
between them are described below.
In slave mode, the slave has to be enabled before the external master starts the
communication. The transmission sequence begins when the external master sends the clock
and when the I2S_WS signal requests the transfer of data. The data has to be written to the
SPI_DATA register before the master initiates the communication. Software should write the
next audio data into SPI_DATA register before the current data finishes. Otherwise,
transmission underrun error occurs. The TXURERR flag is set and an interrupt may be
generated if the ERRIE bit in the SPI_CTL1 register is set. In this case, it is mandatory to
disable and enable I2S to resume the communication. In slave mode, I2SCH is sensitive to
the I2S_WS signal coming from the external master.