Skip to main content
AScha.3
Super User
September 18, 2022
Question

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

  • September 18, 2022
  • 9 replies
  • 4300 views

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);

compile...run : 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.

This topic has been closed for replies.

9 replies

AScha.3
AScha.3Author
Super User
September 24, 2022

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

If you feel a post has answered your question, please click on " Best Answer ".
ST Technical Moderator
September 26, 2022

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.

0693W00000SwH7RQAV.jpg 

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
AScha.3
AScha.3Author
Super User
October 22, 2022

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 on " Best Answer ".
AScha.3
AScha.3Author
Super User
September 27, 2022

Hello @Imen DAHMEN​ ,

so...i use :

STM32CubeIDE

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: 11.0.14.1+1

Java version: 11.0.14.1

STM32CubeMX 6.6.1.2022

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

Alfred

If you feel a post has answered your question, please click on " Best Answer ".
AScha.3
AScha.3Author
Super User
October 7, 2022

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

If you feel a post has answered your question, please click on " Best Answer ".
Ghofrane GSOURI
ST Technical Moderator
January 16, 2023

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.

Thx,

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
LCE
Principal II
February 8, 2023

Hello,

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.

FCocc.3
Visitor II
March 24, 2023

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

else
 hi2s->Instance->CFG2 = 0x008000;

solves the issue.

Associate II
April 23, 2025

thank you so much @FCocc.3 !! after adding it in now I can see data from I2S printed out. Before that there was constantly 0 printed out even though i could see the pulses coming out from the data line on logic analyzer.