[sdiy] STM32G4 SAI problems

sleepy_dog at gmx.de sleepy_dog at gmx.de
Sat Jul 15 23:00:54 CEST 2023

On 15.07.2023 22:36, rburnett at richieburnett.co.uk wrote:
> Anyone using STM32G4 with STM32CubeIDE and managed to get the SAI
> codec interface working?

alas not, but you could have a look at "efton stm32 gotchas", he has a
bunch of nice ones.
Even if this one's not in there - it's a good thing to bookmark ;)
You might even be inspired with some ideas of what it could be.

Uh yeah, about the G4 - it has a very interesting gotcha... (limited
lifetime at elevated temperature)

But I'll try to say some general things here:

> I've been banging my head against a brick wall here for the past two
> days trying to configure the SAI peripheral of a Nucleo-G474RE using
> the CubeIDE graphical config tool (MX?), and still no signs of life on
> the relevant pins!

Have you looked at the clock tree view in cubeIDE? It's, for me, one of
THE useful things, as it checks boundaries for everything.. Does
everything look good?

Are all the necessary peripheral block & bus clocks enabled?
Did you enable the relevant peripheral clocks *before* attempting the
configuration of the peripheral? It needs a clock for that.
There was a bug in the code generator, although somewhat long ago, that
produced the wrong init sequence in that regard.

> It asks me what "Audio Frequency" I want from a drop down menu of the
> usual suspects (32k, 44.1k, 48k, 96k, etc.) but the "Real Audio
> Frequency" and "Error" both stay stubbornly stuck at zero and greyed
> out.  The clock source shows as "SAI PLL Clock" but is greyed out (and
> can't be changed,) and I've tried all possible options for the SAI
> clock MUX in the actual clock config tool anyway, including an
> external I2S clock input.  Still no luck.

sounds like you should really look at the clock tree view

Also look at the complete clock tree in the reference manual, maybe
you'll discover soomething that needs to be turned on in the IDE too -
as it might check and disallow you from doing something that doesn't
work if dependencies aren't enabled, too

> Why does this have to be so difficult!?  And why do chip vendors
> always provide working examples for every peripheral except SAI / I2S
> ! (>.<)
> I have managed to get a LED blinking, and send "Hello World!" to a
> terminal via UART though, so not entirely fruitless.

I have used I2S many years ago, but not with the current devices or the
init code generator stuff.

- Steve

More information about the Synth-diy mailing list