DocID025202 Rev 7
944/1080
RM0365
Serial peripheral interface / inter-IC sound (SPI/I2S)
959
Reception sequence
The operating mode is the same as for the transmission mode except for the point 1 (refer to
the procedure described in
Section 30.7.7: I2S slave mode
), where the configuration should
set the master reception mode using the I2SCFG[1:0] bits in the SPIx_I2SCFGR register.
Whatever the data length or the channel length, the audio data are received by 16-bit
packets. This means that each time the RX buffer is full, the RXNE flag in the SPIx_SR
register is set and an interrupt is generated if the RXNEIE bit is set in the SPIx_CR2
register. Depending on the data length and channel length configuration, the audio value
received for a right or left channel may result from one or two receptions into the RX buffer.
The CHSIDE flag is updated each time data are received to be read from the SPIx_DR
register. It is sensitive to the external WS line managed by the external master component.
Clearing the RXNE bit is performed by reading the SPIx_DR register.
For more details about the read operations depending the I
2
S standard mode selected, refer
to
Section 30.7.3: Supported audio protocols
If data are received while the preceding received data have not yet been read, an overrun is
generated and the OVR flag is set. If the bit ERRIE is set in the SPIx_CR2 register, an
interrupt is generated to indicate the error.
To switch off the I
2
S in reception mode, I2SE has to be cleared immediately after receiving
the last RXNE = 1.
Note:
The external master components should have the capability of sending/receiving data in 16-
bit or 32-bit packets via an audio channel.
30.7.8 I
2
S status flags
Three status flags are provided for the application to fully monitor the state of the I
2
S bus.
Busy flag (BSY)
The BSY flag is set and cleared by hardware (writing to this flag has no effect). It indicates
the state of the communication layer of the I
2
S.
When BSY is set, it indicates that the I
2
S is busy communicating. There is one exception in
master receive mode (I2SCFG = 11) where the BSY flag is kept low during reception.
The BSY flag is useful to detect the end of a transfer if the software needs to disable the I
2
S.
This avoids corrupting the last transfer. For this, the procedure described below must be
strictly respected.
The BSY flag is set when a transfer starts, except when the I
2
S is in master receiver mode.
The BSY flag is cleared:
•
When a transfer completes (except in master transmit mode, in which the
communication is supposed to be continuous)
•
When the I
2
S is disabled
When communication is continuous:
•
In master transmit mode, the BSY flag is kept high during all the transfers
•
In slave mode, the BSY flag goes low for one I
2
S clock cycle between each transfer