[sdiy] STM32G4 SAI problems

Mike Bryant mbryant at futurehorizons.com
Sun Jul 16 14:00:25 CEST 2023


Yes it should generate all the clocking arrangements, and allocate and initiate the relevant pins.

Pure guess, but try changing the selected processor to a STM32F730 or STM32H750 and see if it generates more code
________________________________
From: Synth-diy <synth-diy-bounces at synth-diy.org> on behalf of rburnett at richieburnett.co.uk <rburnett at richieburnett.co.uk>
Sent: 16 July 2023 12:42
To: Synth Diy <synth-diy at synth-diy.org>
Subject: Re: [sdiy] STM32G4 SAI problems

Thanks for all your tips and suggestions with this guys.  I really
appreciate it.  Particularly the STM32 gotchas which will be handy
generally as I'm new to STM32.

I've gone through the output generated by the graphical config tool
CubeMX and it doesn't seem to contain anywhere near enough code.  For
example when I enable one of the peripherals like I2S the pins light up
around the package drawing and take on the labels I2S2_MCK, I2S2_SD,
I2S2_CK & I2S2_WS and appear in a little table in the "GPIO settings" of
the "Configuration" window but there doesn't seem to be any
corresponding code generated to actually perform this pin configuration.
  All I can see in the automatically generated code is config for a pin
with a LED attached (which works!) and a pushbutton which I haven't
tested.  Likewise all of the clocks look valid and enabled in the RCC
clock tree diagram and appear to be being fed to the I2S peripheral, but
I can't actually find anything in the generated code to make this
happen!  This would seem like a decent explanation for why the relevant
pins just appear floating (tri-stated) when probed with the scope.

Am I right in thinking that CubeMX should be automatically generating
code to configure pins correctly when I enable a peripheral like I2S?
They're names change and they light up in the pin diagram and appear in
a table, but am I meant to be writing the code to switch the pins from
tri-state to the correct "Alternative Function" myself?  Likewise with
the clock enabling.  I can't actually find the line of code that enables
the bus clock to the I2S.

I'm relatively new to this idea of using a graphical config tool to
configure peripherals although by no means new to embedded firmware
development.  As others have said its a nice idea when it works, but
when it doesn't you're left trawling through loads of automatically
generated spaghetti code referencing multiple sprawling include files
(>.<)  At this point I can't help but feel like abandoning the graphical
config tool and just grabbing a highlighter and printing out the
relevant 55 pages or so of the device manual and thrash my way through
writing the peripheral configuration manually.  (The actual I2S protocol
part and the ping-pong DMA buffering, etc. that comes next is familiar
to me from projects on other platforms, so I'm confident of what I'm
trying to achieve.  I should be able to answer the questions of what
bits to set/clear to talk to my chosen CODEC chip.)  It just doesn't
seem like the graphical config tool is even asking anywhere near enough
questions or generating enough code.

For example, the timings that Vlad quoted would be perfect for me.  I
just can't make it do that (>.<)

Perhaps I'm putting too much faith in the IDE tool.  Is there a fair
chance that the graphical config tool (CubeMX) is just broken?  I have
read some pretty scathing stuff about CubeMX and HAL in other forums,
but had hoped things had improved over the years.

-Richie,
_______________________________________________
Synth-diy mailing list
Synth-diy at synth-diy.org
http://synth-diy.org/mailman/listinfo/synth-diy
Selling or trading? Use marketplace at synth-diy.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20230716/bab0327f/attachment.htm>


More information about the Synth-diy mailing list