I2S full-duplex on STM32H7: STM32CubeMX doesn't produce working code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-15 7:39 AM
Hi again,
I'm attempting to use the I2S peripheral on the STM32H7, and the CubeMX produces half-duplex code.
Here you see that I'm using an STM32H743, selected I2S, full-duplex slave, but the only choices of mode I get are Mode Slave Transmit and Mode Slave Receive. There is no full duplex mode selectable.
In addition, when I have mode slave transmit enabled, the data is spit out on the wrong pin (PA6 instead of PA7).
There is literally no code change between selecting 'Full-Duplex Slave' and 'Half-Duplex Slave', but there is a change in the .ioc file.
Any thoughts on how to make full duplex work? Any idea if this is a known problem in the CubeMX software?
In my case, I'm lucky, an only *require* the transmit, and not so much the receive.
Thanks so much!
-Caleb
Solved! Go to Solution.
- Labels:
-
I2S
-
STM32CubeMX
-
STM32H7 series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-15 9:58 AM
I'm just playing with that now. So far, I created my own MX_I2S1_Init that sets full duplex, and swaps TX and RX. I'm only doing polling IO for the moment, but it does work, with data going out on the correct pin (PA7).
void My_MX_I2S1_Init(void)
{
hi2s1.Instance = SPI1;
hi2s1.Init.Mode = I2S_MODE_SLAVE_FULLDUPLEX; // not supported by CubeMX 5.2, so we need to roll our own.
hi2s1.Init.Standard = I2S_STANDARD_PHILIPS;
hi2s1.Init.DataFormat = I2S_DATAFORMAT_32B;
hi2s1.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE;
hi2s1.Init.AudioFreq = I2S_AUDIOFREQ_48K;
hi2s1.Init.CPOL = I2S_CPOL_LOW;
hi2s1.Init.FirstBit = I2S_FIRSTBIT_MSB;
hi2s1.Init.WSInversion = I2S_WS_INVERSION_DISABLE;
hi2s1.Init.Data24BitAlignment = I2S_DATA_24BIT_ALIGNMENT_RIGHT;
hi2s1.Init.MasterKeepIOState = I2S_MASTER_KEEP_IO_STATE_DISABLE;
if (HAL_I2S_Init(&hi2s1) != HAL_OK)
{
Error_Handler();
}
// Swap TX and RX
MODIFY_REG(hi2s1.Instance->CFG2, SPI_CFG2_IOSWP, SPI_CFG2_IOSWP);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-15 9:45 AM
And if you simply program the I2S registers for the full-duplex slave, without relying on Cube/CubeMX, it won't work either?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-15 9:58 AM
I'm just playing with that now. So far, I created my own MX_I2S1_Init that sets full duplex, and swaps TX and RX. I'm only doing polling IO for the moment, but it does work, with data going out on the correct pin (PA7).
void My_MX_I2S1_Init(void)
{
hi2s1.Instance = SPI1;
hi2s1.Init.Mode = I2S_MODE_SLAVE_FULLDUPLEX; // not supported by CubeMX 5.2, so we need to roll our own.
hi2s1.Init.Standard = I2S_STANDARD_PHILIPS;
hi2s1.Init.DataFormat = I2S_DATAFORMAT_32B;
hi2s1.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE;
hi2s1.Init.AudioFreq = I2S_AUDIOFREQ_48K;
hi2s1.Init.CPOL = I2S_CPOL_LOW;
hi2s1.Init.FirstBit = I2S_FIRSTBIT_MSB;
hi2s1.Init.WSInversion = I2S_WS_INVERSION_DISABLE;
hi2s1.Init.Data24BitAlignment = I2S_DATA_24BIT_ALIGNMENT_RIGHT;
hi2s1.Init.MasterKeepIOState = I2S_MASTER_KEEP_IO_STATE_DISABLE;
if (HAL_I2S_Init(&hi2s1) != HAL_OK)
{
Error_Handler();
}
// Swap TX and RX
MODIFY_REG(hi2s1.Instance->CFG2, SPI_CFG2_IOSWP, SPI_CFG2_IOSWP);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-05-16 2:55 AM
Hello @caleb
This is reported internally for further check.
Best Regards,
Khouloud.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-12-29 6:06 PM
Hi @Khouloud ZEMMELI
This problem still exists on CubeIDE v1.5.1. While the I2S is configured as a duplex by the CubeIDE configurator, the generated code initializes the I2S as a simplex mode.
Any update internally?
Regards
Takemasa
