2025-10-11 3:55 AM
Created a STM32H743II prj with I2S2 enabled, half-duplex slave receive mode, and DMA1 S0 bounded to SPI2_RX, to work with an ADC in master mode.
Can't get data from the ADC ( DMA linked mem area always zero ), while my oscillograph can properly decode the ADC I2S data output pin ( CK & WS pin also connected between the ADC board and the H743 board, and the oscillograph ).
In cube, the SDI pin is mapped to SPI2_MISO, PB14. But as a slave, shouldn't the correct SDI pin map to SPI2_MOSI, PB15?
So I modified the cubeMX generated code manually, by changing PB14 to PB15 in the I2S2 GPIO initialization sector, and it worked, the DMA linked mem area shows the same value on my oscillograph.
Is this a cubeMX bug?
Solved! Go to Solution.
2025-10-11 7:49 AM - edited 2025-10-11 7:59 AM
Seems to be a bug , but no big problem, miso mosi can be swapped :
So let Cube do it, and if the pin swap missing, just set it yourself in the init.
hxxx.Init.IOSwap = SPI_IO_SWAP_DISABLE; // or _ENABLEbtw
I had same problem...and used the swap feature.
(Maybe it depends on Cube/HAL version, bug might be away. Which version you use? )
2025-10-11 7:41 AM
> In cube, the SDI pin is mapped to SPI2_MISO, PB14. But as a slave, shouldn't the correct SDI pin map to SPI2_MOSI, PB15?
A half duplex data connection on the slave side should be on the MISO pin, as shown in the reference manual.
2025-10-11 7:49 AM - edited 2025-10-11 7:59 AM
Seems to be a bug , but no big problem, miso mosi can be swapped :
So let Cube do it, and if the pin swap missing, just set it yourself in the init.
hxxx.Init.IOSwap = SPI_IO_SWAP_DISABLE; // or _ENABLEbtw
I had same problem...and used the swap feature.
(Maybe it depends on Cube/HAL version, bug might be away. Which version you use? )
2025-10-13 1:31 AM - edited 2025-10-13 1:45 AM
Hello @KimbleYoung @AScha.3 @TDK
Thank you all for your contributions.
Two internal tickets, 160926 and 143012, have been raised to our development team to address this issue.
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.
2025-10-14 3:56 AM
Thanks for your reply.
But I couldn't get it to work with the original code cube generated, maybe I did sth wrong somewhere else.
Hope the development team can give us a clear answer, let's wait.
2025-10-14 4:13 AM
Thanks for your reply, very helpful.
This IO swapping method is much better than manually modifying the init code, which will be wiped when cubeMX regenerating.
I didn't find the struct member 'Init.IOSwap' in &hi2sx, it just exist in struct &hspix.
But I find this function for I2S - HAL_I2S_EnableIOSwap, which also works.
Added this line, and changed the phyical data pin connection to PB14, works just fine.
HAL_I2S_EnableIOSwap(&hi2s2);
Hope the development team can give us a clear answer, let's wait.