Showing results for 
Search instead for 
Did you mean: 

[STM32H743 - Bug in cube] after setting I2S (SPI) from 'master' transmit to 'slave' : no more data coming...

Chief II

on H743 board (DevEboard) I2S1 (master 16b 44k1) -> ES9038 DAC (I2S slave) :

DAC playing music fine, ok.

now switching DAC to I2S master , H743 to slave transmitter mode : no data / silence.

test with DSO : pin PA7 (SDO) is tri state now! thats WRONG !!!!

looking in ds/manual , see, maybe change SDi/SDO pins, when change master -> slave mode....

so i try: set in cubeIDE pin PA6 (i2S SDI ) manual to SDI ("no mode" , "yellow" ( pin in cube) = warning); : DAC playing, so data coming from "inactive" and "no mode" pin, but from ("green": pin in cube) SDO nothing coming.

i think, this is obvious error in cube; missing the IOSWAP in SPI_CFG2 to set or wrong setting preset.

to proof , i add pinswap in HAL_I2S.c driver / init slave mode:

0693W00000Svi2RQAR.pngnow sound is ok again; so data coming from SDO now (again).

 @Imen DAHMEN​ or @Julien D_OEHAUDT​ ... STM

so please rectify, if i am right.

If you feel a post has answered your question, please click "Accept as Solution".
Chief II

seems STM has not very much interest in this...

If you feel a post has answered your question, please click "Accept as Solution".
ST Employee

Hello @AScha.3​ ,

Which Cube package version are you using?

Are you using CubeMx tool for your settings and to generate your project ? If yes, which version ?

Did you try to change IOSWP bit in SPI_CFG2 register?

hi2s1.Init.IOSwap = I2S_IO_SWAP_ENABLE;

The SPI/I2S offers the possibility to swap the function of SDI and SDO lines thanks to IOSWP bit located into SPI_CFG2. Details can be found in RM0433:

Bit 15 IOSWP: swap functionality of MISO and MOSI pins

0: no swap

1: MOSI and MISO are swapped

When this bit is set, the function of MISO and MOSI pins alternate functions are inverted.

Original MISO pin becomes MOSI and original MOSI pin becomes MISO.

Note: This bit can be also used in PCM and I2S modes.

Please see the "Serial data line swapping" table in RM0433.



When your question is answered, please close this topic by clicking "Accept as Solution".
Chief II

Hello @Imen DAHMEN​ ,

so...i use :


Version: 1.10.1

Build: 12716_20220707_0928 (UTC)

OS: Linux, v.4.19.0-1-amd64, x86_64 / gtk 3.22.11

Java vendor: Eclipse Adoptium

Java runtime version:

Java version:


and yes, to proove : i changed IOSWP bit in SPI_CFG2 , in HAL lib:

 >> SPI1->CFG2 = 0x008000; // test ! pin swap

as i wrote in first post.

so i think, solution is just : make pinSwap available in I2S mode in cube and setting initial to "1" ;

so SDO stays SDO when selecting slave mode from master mode...and reverse.

(seems , not sooo many people have ever tried, to use I2S transmittter slave mode setting in Cube/HAL on H7xx . )

best regards


If you feel a post has answered your question, please click "Accept as Solution".
Chief II

so.... make pinSwap available in I2S mode in cube ?

If you feel a post has answered your question, please click "Accept as Solution".

now i tried your idea: swap-enable in cfg , but:

>> ...error: 'I2S_InitTypeDef' {aka 'struct <anonymous>'} has no member named 'IOSwap' <<

so its really missing here.

If you feel a post has answered your question, please click "Accept as Solution".
Ghofrane GSOURI
ST Employee

Hello @AScha.3​ 

Thank you for your contributions and for your detailed explanations,

Your suggestion is taken into consideration, it has been reported to STM32CubeMX development team .

Internal ticket number:  143012 (This is an internal tracking number and is not accessible or usable by customers).

I will keep you posted with updates.





I just had the same problem with a H723, using I2S as slave RX, and only after setting IOSWP it worked.

I'm mostly using Cube and HAL libs to "learn" when using a new peripheral, and there I didn't come across IOSWP.

The problem is either:

  • Cube is setting the wrong data IO pins when in slave mode (MOSI / MISO)
  • or HAL doesn't check slave mode together with TX/RX and which data pin is used (MOSI / MISO), there's no use of the IOSWP bit in the HAL libs anywhere

So it's not only a Cube, but also a HAL problem.


I confirm that the problem is still present in STM32Cube_FW_H7 v1.11.0

and happening regardless of transmission or reception.

i am using a STM32H723ZG

Adding to stm32h7xx_hal_i2s.c @ line 455

    hi2s->Instance->CFG2 = 0x008000;

solves the issue.