GD32VF103 User Manual
401
18.9.3.
Operation
Operation modes
The operation mode is selected by the I2SOPMOD bits in the SPI_I2SCTL register. There
are four available operation modes, including master transmission mode, master reception
mode, slave transmission mode, and slave reception mode. The direction of I2S interface
signals for each operation mode is shown in the
Table 18-6. Direction of I2S interface
signals for each operation mode .
Table 18-6. Direction of I2S interface signals for each operation mode
Operation mode
I2S_MCK
I2S_CK
I2S_WS
I2S_SD
Master transmission
Output or NU(1)
Output
Output
Output
Master reception
Output or NU(1)
Output
Output
Input
Slave transmission
Input or NU(1)
Input
Input
Output
Slave reception
Input or NU(1)
Input
Input
Input
1. NU means the pin is not used by I2S and can be used by other functions.
I2S initialization sequence
I2S initialization sequence contains five steps shown below. In order to initialize I2S to master
mode, all the five steps should be done. In order to initialize I2S to slave mode, only step 2,
step 3, step 4 and step 5 should be done.
Step 1: Configure the DIV[7:0] bits, the OF bit, and the MCKOEN bit in the SPI_I2SPSC
register to define the I2S bitrate and determine whether I2S_MCK needs to be provided
or not.
Step 2: Configure the CKPL in the SPI_I2SCTL register to define the idle state clock
polarity.
Step 3: Configure the I2SSEL bit, the I2SSTD[1:0] bits, the PCMSMOD bit, the
I2SOPMOD[1:0] bits, the DTLEN[1:0] bits, and the CHLEN bit in the SPI_I2SCTL register
to define the I2S feature.
Step 4: Configure the TBEIE bit, the RBNEIE bit, the ERRIE bit, the DMATEN bit, and
the DMAREN bit in the SPI_CTL1 register to select the potential interrupt sources and
the DMA capabilities. This step is optional.
Step 5: Set the I2SEN bit in the SPI_I2SCTL register to enable I2S.
I2S master transmission sequence
The TBE flag is used to control the transmission sequence. As is mentioned before, the TBE
flag indicates that the transmit buffer is empty, and an interrupt will be generated if the TBEIE
bit in the SPI_CTL1 register is set. At the beginning, the transmit buffer is empty (TBE is high)
and no transmission sequence is processing in the shift register. When a half word is written