595
/
838
Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
signal, and set the SPI_I2SPREDIV.MCLKOEN bit to select whether to output the master clock (MCLK).
The sending process begins when data is written to the send buffer. When the data of the current channel is moved
from the send buffer to the shift register in parallel, the flag bit TE (SPI_STS.TE) is set to '1'. At this time, the data
of the other channel should be written into SPI_DAT. The channel corresponding to the current data to be transmitted
is confirmed by the flag bit CHSIDE (SPI_STS. CHSIDE). The value of CHSIDE (SPI_STS. CHSIDE) is updated
when TE (SPI_STS.TE) is set to '1'. A complete data frame includes left and right channels, and only part of the data
frame cannot be transmitted. When the flag bit TE (SPI_STS.TE) is set to '1', if the SPI_CTRL2.TEINTEN = 1, an
interrupt will be generated.
The operation of writing data depends on the selected I2S standard. See chapter 21.4.1 for details.
When the user wants to turn off the I2S function, wait for the TE flag (SPI_STS.TE) bit to be 1 and the BUSY flag
(SPI_STS.BUSY) bit to be 0, and then clear the SPI_I2SCFG.I2SEN bit to 0.
Slave mode
The sending process of the slave mode is similar to that of the master mode, the difference is as follows:
When I2S works in slave mode, there is no need to configure the clock, and the CLK pin and WS pin are connected
to the corresponding pins of the master device. The sending process begins when an external master sends a clock
signal, and when a WS signal requires data transfer. Only when the slave device is enabled and the data has been
written to the I2S data register, the external master device can start communication.
When the first clock edge representing the next data transfer arrives, the new data has not been written into the
SPI_DAT register, an underflow occurs, and the SPI_STS.UNDER flag bit is set to 1. If the SPI_CTRL2.ERRINTEN
bit is set to 1, an interrupt is generated to indicate that an error has occurred.
The SPI_STS.CHSIDE flag indicates which channel the currently transmitted data corresponds to. Compared with
the master mode sending process, in the slave mode, CHSIDE depends on the WS signal of the external master I2S
device (WS signal is 1 means the left channel)
Receiving sequence
Master mode
Audio is always received in 16-bit packets. According to the configured data and channel length, the received audio
data will need to be transferred to the receive buffer once or twice.
When the data is transferred from the shift register to the receive buffer, the SPI_STS.RNE flag bit is set to 1, at this
time, the data is ready and can be read from the SPI_DAT register. If the SPI_CTRL2.RNEINTEN bit is set to 1, an
interrupt will be generated. Reading the SPI_DAT register to clear the SPI_STS.RNE flag. If the previously received
data is not read, new data is received again, an overflow occurs, and the SPI_STS.OVER flag is set to 1. If the
SPI_CTRL2.ERRINTEN bit is set to 1, an interrupt is generated to indicate that an error has occurred.
The channel corresponding to the currently transmitted data can be confirmed by the SPI_STS.CHSIDE bit. When
the SPI_STS.RNE flag bit is set to 1, the SPI_STS.CHSIDE value is updated.
The operation of reading data depends on the selected I2S standard. See Section 21.4.1 for details.
When I2S function is turned off, different audio standards, data length and channel length adopt different operation
steps: