AnsweredAssumed Answered

STM32F7 I2S DMA byte order issue

Question asked by klem on Jul 18, 2017
Latest reply on Jul 19, 2017 by waclawek.jan

Hi,

I'm trying to use the STM32F746 I2S2 with DMA (to transmit data), but my datas are send in the wrong byte order.

My I2S configuration is : slave TX 32bits @ 192KHz

 

The DMA send data from a 32bits array in memory to the I2S peripheral.

My 32bits array is filled with the value 0x12345678.

Problem is, on the reception side I receive the value : 0x56781234.

 

Apparently the I2S peripheral only handle 16bits values. So when DMA send 32bits values, the I2S start sending the lower part of it (0x5678) before the higher part (0x1234).

I tried different configuration for the DMA (normal/circular, FIFO enable/disable, different word length) but nothing worked.

 

Do you have any idea if it's possible to send the data in the correct order ?

Thank you.

 

Here are my I2S and DMA configs :

 

  hi2s2.Instance = SPI2;
  hi2s2.Init.Mode = I2S_MODE_SLAVE_TX;
  hi2s2.Init.Standard = I2S_STANDARD_PHILIPS;
  hi2s2.Init.DataFormat = I2S_DATAFORMAT_32B;
  hi2s2.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE;
  hi2s2.Init.AudioFreq = I2S_AUDIOFREQ_192K;
  hi2s2.Init.CPOL = I2S_CPOL_LOW;
  hi2s2.Init.ClockSource = I2S_CLOCK_PLL;

    hdma_spi2_tx.Instance = DMA1_Stream4;
    hdma_spi2_tx.Init.Channel = DMA_CHANNEL_0;
    hdma_spi2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
    hdma_spi2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_spi2_tx.Init.MemInc = DMA_MINC_ENABLE;
    hdma_spi2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
    hdma_spi2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
    hdma_spi2_tx.Init.Mode = DMA_CIRCULAR;
    hdma_spi2_tx.Init.Priority = DMA_PRIORITY_LOW;
    hdma_spi2_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;

Outcomes