<div dir="ltr"><div>My approach has always been if you can't write maintainable code by using a reasonable HAL then buy a faster processor. </div><div><br></div><div>I've yet to find any HAL code that is so bad it stops things from working - due to the conditional compilation in a lot of it, the actual code generated actually isn't that huge. You'll also find that the documentation isn't so bad provided you just read the relevant bits and not worry about the number of pages!! You will need 3 documents - the Reference Manual, the Production Data sheet (for the specific variant you have) and the HAL for the range. There are also very useful Application Notes with things like Timer cookbook, peripheral interconnect (very handy when getting DMA events organised) and several DMA specific ones.</div><div><br></div><div>One thing I will advise on - most of the examples in the HAL packages are total crap and repeat ad nauseum for most of the processors in a range which really doesn't give you many different examples to help understand what is going on . The hardware JPEG encode/decode in the F7 series had me jumping about for 6 months before I twigged that the cache memory mapping needed adjustment for that IP block to work in anything other than the default memory region used in the examples.</div><div><br></div><div>My latest project took about 2 hours to assign all the peripherals and pins for a Black Pill (stm32f411) which was USART, SPI, Timer (with 2 capture events), all using DMA (so 7 streams) plus USB and the CDC USB stack. It also has the usual debug, GPIO stuff and interrupt handlers. Generate code and run 'make' to convince yourself that it worked and then fill in the blanks of your application.</div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Jul 3, 2025 at 2:42 PM Mark Atherton <<a href="mailto:markaren1@xtra.co.nz">markaren1@xtra.co.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Ha! Well done Richard.<br>
<br>
.. and thanks Charles.<br>
<br>
-Mark<br>
<br>
<br>
On 03-Jul-25 2:32 PM, Richard Jones wrote:<br>
> I used the HAL to configure registers as needed, then read out the <br>
> results in code to write the instructions to load registers directly for <br>
> speed. In my case I printed the results as 'C' code using printf ( using <br>
> bit band or register writes ) so I just cut and pasted the printed 'C' <br>
> code into the application. Not at all portable, and not obvious to read, <br>
> but I achieved the speed that I needed at the time.<br>
> <br>
> Cheers<br>
> <br>
> Richard<br>
> <br>
> On Thu, Jul 3, 2025 at 12:56 PM Charles Manning <<a href="mailto:cdhmanning@gmail.com" target="_blank">cdhmanning@gmail.com</a> <br>
> <mailto:<a href="mailto:cdhmanning@gmail.com" target="_blank">cdhmanning@gmail.com</a>>> wrote:<br>
> <br>
> OK, I can't help in your stated quest of an AI assistant, but here<br>
> is how I tend to go about STM32 development which might get what you<br>
> want.<br>
> <br>
> First I use the CubeMX tool to do all the primary set up (peripheral<br>
> initialisation, clock trees, dma channel assignment etc).<br>
> For some of the peripherals, the performance is not too critical and<br>
> the HAL podge is not too podgy. The HAL can work there.<br>
> Then there are the few bits where the HAL is too bloaty and/or slow<br>
> and/or missing the features you want. That is where I write my own<br>
> drivers and bypass the HAL.<br>
> <br>
> It is OK to mix and match like that. It means you only need to go<br>
> datasheet mining in a few critical places.<br>
> <br>
> Obviously you don't want to do things like write to the<br>
> peripheral at the same time via HAL and your own code, but it is OK<br>
> to use HAL to set things up, then apply your own tweaks then use<br>
> your own code to do all the read/write stuff etc.<br>
> <br>
> This has worked well for me in the past and gives me the best of<br>
> both worlds (well most of the time anyway).<br>
> <br>
> <br>
> On Thu, Jul 3, 2025 at 10:49 AM Mark Atherton <<a href="mailto:markaren1@xtra.co.nz" target="_blank">markaren1@xtra.co.nz</a><br>
> <mailto:<a href="mailto:markaren1@xtra.co.nz" target="_blank">markaren1@xtra.co.nz</a>>> wrote:<br>
> <br>
> Hi Charles,<br>
> <br>
> You are quite right, I could just dig straight into the<br>
> documentation,<br>
> but at last count, there are something over 2,600 pages<br>
> associated with<br>
> the STM32G491.<br>
> <br>
> I was rather hoping to implement then experiment with some new<br>
> ideas,<br>
> rather than go into battle over trying to get peripherals<br>
> configured.<br>
> <br>
> I am also quite shameless in terms of asking for help in any<br>
> form that<br>
> might be available.<br>
> <br>
> Anyway, can anyone recommend an AI assistant that might be<br>
> useful in my<br>
> journey ?<br>
> <br>
> Thanks,<br>
> <br>
> Mark<br>
> <br>
> ----------<br>
> <br>
> Charles Manning said<br>
> <br>
> What's wrong with the grey stuff sitting on your shoulders?<br>
> <br>
> The HAL normally has multiple modes of operation, including DMA<br>
> options,<br>
> but if you're pushing the micro hard the HAL is often a bit<br>
> bloated and<br>
> slow.<br>
> <br>
> _______________________________________________<br>
> Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a><br>
> <mailto:<a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a>><br>
> <a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
> <<a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a>><br>
> Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
> <<a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a>><br>
> Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a><br>
> <<a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a>> for venue, directions and dates.<br>
> When replying, please edit your Subject line to reflect new<br>
> subjects.<br>
> <br>
> _______________________________________________<br>
> Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a><br>
> <mailto:<a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a>><br>
> <a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
> <<a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a>><br>
> Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
> <<a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a>><br>
> Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a><br>
> <<a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a>> for venue, directions and dates.<br>
> When replying, please edit your Subject line to reflect new subjects.<br>
> <br>
> <br>
> _______________________________________________<br>
> Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a><br>
> <a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
> Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
> Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
> When replying, please edit your Subject line to reflect new subjects.<br>
<br>
<br>
_______________________________________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a><br>
<a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.</blockquote></div>