[sdiy] STM32G4 SAI problems

Chris McDowell declareupdate at gmail.com
Sun Jul 16 14:58:40 CEST 2023

And also, people certainly do like to complain about cube and hal online, but I rely on it heavily for work and it is not generally broken. I've had stumblings or misunderstandings but I don't think I've ever run into an issue that was ultimately a CubeIDE bug

Chris McDowell

> On Jul 16, 2023, at 7:53 AM, Chris McDowell <declareupdate at gmail.com> wrote:
> Richie,
> Somewhere in the tool you have to tell it to actually generate code, though that setting should be on by default. I have found I also have to click on whatever tab I'm on in the tool, then save, then it will prompt to generate code. If you're not getting any new code generated, that's certainly the first hurdle. a quick check is to name a pin in the graphical pin setup tab, then check "main.h" for that pin name define. 
> The other cubeide gotcha is that most things set up with the config tool need to be enabled manually. I don't know if I2S / SAI works that way, but I'd bet it does. I often have to do a little digging in the hal library to find the associated "start" function living somewhere near the config and setup functions that cube calls in the generated code. 
> Cheers,
> Chris McDowell
>>> On Jul 16, 2023, at 7:03 AM, Mike Bryant <mbryant at futurehorizons.com> wrote:
>> 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
>> _______________________________________________
>> 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/a4e2eb6b/attachment.htm>

More information about the Synth-diy mailing list