Skip to main content
SHamm.18
Associate
Mar 13, 2020 3:49 PM UTC
Question

SAI I2S Mono Mode Not An Option

When using SAI for I2S, STM32CubeIDE does not give you the option to choose Mono mode. It's only option is Stereo Mode. However, STM32 SAI HAL supports both SAI_STEREOMODE as well as SAI_MONOMODE, so I think this should be an option.

This topic has been closed for replies.

14 replies

Khouloud ZEMMELI
ST Employee
Mar 19, 2020 7:26 PM UTC

​Hello @SHamm.18​ ,

Could you please share your project ? I need to know which serie and version used.

Best Regards,

Khouloud

SHamm.18
SHamm.18Author
Associate
Mar 20, 2020 12:03 AM UTC

I am using a Nucleo-L432KC with STM32CubeIDE 1.2.0. If I enable SAI1 in I2S mode, the only option is for Output Mode is Stereo, though the SAI HAL file supports Mono mode as well.

waclawek.jan
Super User
Mar 19, 2020 11:11 PM UTC

I2S as a standard bus is inherently and specifically 2 channel.

From this viewpoint, what would you expect from a mono setting to do? What is your target codec?

JW

SHamm.18
SHamm.18Author
Associate
Mar 20, 2020 12:05 AM UTC

I am using I2S with a mono .wav file. If I use I2S in stereo mode, the .wav file is played twice as fast. By manually changing  hsai_BlockA1.Init.MonoStereoMode to mono mode in sai.c, the .wav file plays normally

victagayun
Senior III
Dec 15, 2021 2:39 AM UTC

Hello I am using STM32F407 discovery kit, CubeIDE 1.8.0 and FW_F4 V1.26.2.

I plan to connect the mono mic via I2S as well and should be connected in mono mode.

Where do you get to change hsai_BlockA1.Init.MonoStereoMode to mono mode?

I cannot seem to find this code.

I am looking in:

MX_I2S2_Init(),

stm32f4xx_hal_i2s.h,

stm32f4xx_hal_i2s_ex.h, and

stm32f4xx_hal_i2s.c.

Where should I look for to modify?

waclawek.jan
Super User
Mar 20, 2020 6:02 AM UTC

Well, given CubeMX is just a clicking configurator to Cube, if there's a working setup in Cube, it probably should be settable in CubeMX.

Nevertheless, I was still curious, what does that mean from I2S point of view. but reading the I2S chapter in RM, it's probably just setting the SAI_xCR1.MONO bit, which in Tx duplicates slot 0 data into slot 1 in hardware, and in Rx discards slot 1 data (this ought to be borne in mind when using this feature for Rx).

JW

Piranha
Principal III
Mar 21, 2020 10:06 AM UTC

That MONO bit is a really nice option if one needs to work with mono streams, because then you don't have to waste CPU and RAM on repacking that unnecessary second channel. :)

Khouloud ZEMMELI
ST Employee
Mar 23, 2020 8:59 AM UTC

​Hello @SHamm.18​ , You're right, issue confirmed and it will be fixed.

Best Regards,

Khouloud

Alexmouse
Associate III
Nov 5, 2021 3:34 PM UTC

Where do I find this bit on STM32F411?

waclawek.jan
Super User
Nov 5, 2021 4:05 PM UTC

STM32F411 does not have the SAI interface.

JW