cancel
Showing results for 
Search instead for 
Did you mean: 

I2S2 Full Duplex

Keith Payea
Associate II
Posted on October 30, 2017 at 00:25

I have an STM3242I-SK board from IAR.  It has a Wolfson WM8731 Codec on it.  I'm trying to use I2S2 in Full duplex mode to get data in/out of the codec.  I used STM32Cube MX to do the basic setup and I am using the HAL libraries for everything.  The board has the Codec ADC output connected to I2S2ext_SD on PI2. The clocks look good, WS is toggling as it should, and I can see data on the ADC out of the codec, but the data in the I2S2 (SPI2) data register is always 0xFFFF, implying (to me) that the input is floating. 

The problem I'm having is that the description of the Full Duplex mode and the interaction of I2S2ext has me thoroughly confused.  The reference manual refers to I2S2ext somewhat obliquely but says nothing about how to set it up.   Figure 262 in the data sheet shows a Mux on the serial data lines in the upper left.  How is this controlled?  How do I make I2S2ext_SD an input?  Does the data input to I2S2ext magically get routed to the SPI2_DR?  What makes I2S2ext a transmitter or a receiver?

Thanks for any light you can shed on this problem.

Keith

3 REPLIES 3
Posted on October 30, 2017 at 06:30

Read 28.4.2  I2S full duplex in RM0090.

There's no fullduplex I2S in STM32. The SPI/I2S unit is simplex in I2S mode, i.e. there's only one I2Sx_SD data pin (see the pin AF matrix in DS). You chose whether it's an input or output by setting the I2S to Rx or Tx in SPI_I2SCFGR.I2SCFG; that governs the data pin multiplexer you mentioned.

Then there's the auxiliary I2SxExt module, which is another independent SPI/I2S module, crippled-down in that it does not work as SPI, it works only as an I2S slave, and its word- and bit-clocks (WS and CK) are internally connected to its respective SPIx/I2Sx module. Direction of its data pin (I2SxExt_SD, note that it may have a different AF number than its respective SPIx/I2Sx!, see again the table in DS) is again given by whether this module is set to Rx or Tx in its own SPI_I2SCFGR.I2SCFG. As from programming point I2SExt is an independent module, it has its own register address space (see memory map in RM), so you set it up there, and its data go to/from its own DR register.

JW

Posted on October 30, 2017 at 22:23

Hi:

Before posting I had read that section of the manual several times and was still confused...  Of course my confusion is compounded by the HAL reference document which says nothing about I2S2ext.  I do have the correct AF6 setting for I2S2ext_SD.  It seems that HAL_I2S_Init figures out that you want full duplex and initializes I2S2ext.  The problem I'm having now is that the connection to the DMA is wrong when I use HAL_I2S_Receive_DMA().  I have written my own HAL_I2S_RxCpltCallback function, but it is not ever getting called.  The DMA Stream3 Channel3 NDTR never decrements.  So, I think that the DMA is not configured correctly by HAL_I2S_Receive_DMA.  It is definitely pointing to the wrong (SPI2, not I2S2ext) Data Register as its source. 

Unless you have some better idea, I think I am going to bail on the HAL functions for this and just deal directly with the registers.  If this is a bug, it's the second one I've found so far in the HAL functions.

Posted on October 30, 2017 at 23:37

I wouldn't touch Cube with a stick, but that's considered an extreme attitude here.

Your call.

JW