[sdiy] STM32G4 SAI problems

brianw brianw at audiobanshee.com
Sun Jul 16 02:02:11 CEST 2023


I've not worked with those particular chips, but I've worked with many, including a few with I2S or other synchronous serial interfaces for ADC chips, etc.

First of all, I got started before such tools as the CubeIDE were available. As a result, I got in a habit of studying the data sheets for clues on all the clocks, dividers, peripheral clock sources, and synchronous serial settings. Not only do I study the main processor settings, but I also study the codec chip being interfaced to, because despite standards there are still variations.

Of course, something like CubeIDE really can make things easy ... except when it doesn't work. When using such helpers, I often just look at the source code generated and then throw it away after taking the settings for my own code. It's a lot more work to write everything from scratch, but at least you have total control.

Finally, every time I've interfaced a synchronous serial converter, I've pretty much always had to attach a bus analyzer probe - on all four or more pin signals - and then verify the timing and sequence of the protocol. With many of the chips I've used (TMS320 DSP), the peripheral is so flexible that it can invert the polarity of any clock or data pin, delay certain bits, change word length, and a ton of other things. The more settings there are, the more chances that one little thing is set wrong. Looking at the signals with a bus analyzer - while keeping in mind all the available settings - usually makes it obvious what's set wrong.

Granted, your description sounds like maybe you're not even running your firmware yet, and the configuration tool isn't even happy yet. If that's the case, then maybe set CubeIDE aside for a moment and try bare metal firmware to see if you can get started communicating with the codec.

Sorry I don't have anything specific to your situation,

Brian


On Jul 15, 2023, at 1:36 PM, rburnett at richieburnett.co.uk wrote:
> Anyone using STM32G4 with STM32CubeIDE and managed to get the SAI codec interface working?
> 
> 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!  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.
> 
> 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.
> 
> -Richie,




More information about the Synth-diy mailing list