Page 1 of 1

STM32 Coding for Dummies!

Posted: Tue Feb 02, 2021 4:24 pm
by james@N52E01
I recently purchased an ST Link-2 dongle, Downloaded the STLink software as well as the latest FOC firmware from Johannes’s GitHub and managed to connect the board to the dongle and flashed the firmware onto a V1D Prius inverter board without starting any fires (for anyone reading this who wants to get this far, please see the link below to the part of Damien’s video where he kindly demonstrates this being done).

So my question is, for those of us with very little knowledge of coding but have been working with Arduino IDE for things like the VCU Boards and Olimex modules, what is a good first step for us in getting to grips with coding for STM32 microcontrollers? Is there a good beginner friendly coding software option out there for this kind of application? Many thanks in advance.


Re: STM32 Coding for Dummies!

Posted: Tue Feb 02, 2021 6:13 pm
by johu
You mean for slightly altering the inverter firmware or starting a whole new project?

Re: STM32 Coding for Dummies!

Posted: Tue Feb 02, 2021 6:37 pm
by Jack Bauer
Well I'll try and give a few pointers from my recent experiences with the vcu.

First get yourself up and running with a linux box. Yes you can do this with windoze but the less learning curve the better. I use ubuntu which is an easy distro. Either setup a dual boot or gt a cheap laptop, wipe it and install linux. Grab the codeblocks ide that Johannes uses. it's actually quite friendly once up and running and helps finding your way through process spread over many files and functions. Installing gcc toolchain is easy but getting it integrated into codeblocks is a bit messy. Might be worth doing a video on this.

once you get up and running the main difference that i encountered between dabling in arduino and stm32/gcc was the latter takes no s&*t. You screw up it will sit there looking at you and IT WILL DO EXACTLY as you tell it. Even if you don't know what you've told it. e.g. my classic screw up is the signed value in an unsigned variable.

Lastly, a good source of info I have found are last seasons C and C++ text books from colleges. I just got 4 telephone book size beasts from a calssified website for 20 euros. C hasnt changed much since the 70's and ok we are doing embedded C but the basics are the same. Currently learning about pointers and now I at least recognise all those * symbols in the vcu code:)

Re: STM32 Coding for Dummies!

Posted: Tue Feb 02, 2021 7:45 pm
by james@N52E01
johu wrote: Tue Feb 02, 2021 6:13 pm You mean for slightly altering the inverter firmware or starting a whole new project?
A little bit from column A... little bit from column B ;) I’d like to be able to contribute to the zombieverter project in some way and try to make an STM32 CAN based touch screen interface for the VCU and BMS. Doubt I’ll get very far but will post all progress as it happens

Re: STM32 Coding for Dummies!

Posted: Tue Feb 02, 2021 7:48 pm
by james@N52E01
Thanks for all the info JB that’s plenty to be getting on with. Got a very dusty laptop running Ubuntu in a cupboard somwhere, will give that a go.

Re: STM32 Coding for Dummies!

Posted: Wed Feb 03, 2021 1:27 am
by jon volk
Linux 110%. Its convenient running an install with Virtualbox on your normal Windows machine. Ive switched to doing any code stuff in that sandbox and the rest of my CAD and ECAD still in Windows since the Linux branch of Kicad is steaming dog turd.

Pointers and Structs are two concepts that I needed some time to sink in. Still not 100% sunk yet.

I also recommend reading the ST reference manual. Thing will make much more sense when you start understanding which registers things are being written to as well as how all the timers, interrupts and general peripheral settings are configured.

https://www.st.com/resource/en/referenc ... ronics.pdf

Re: STM32 Coding for Dummies!

Posted: Wed Feb 03, 2021 4:26 pm
by rstevens81
james@N52E01 wrote: Tue Feb 02, 2021 7:48 pm Thanks for all the info JB that’s plenty to be getting on with. Got a very dusty laptop running Ubuntu in a cupboard somwhere, will give that a go.
Would recommend using one of the flavours that use one of the lighter weight (memory) distribution if you find the laptop is a bit too sluggish
Example flavours are
Xubuntu (xfce I use this under debian)
Ubuntu mate (mate based on gnome2 which is what I started with back with hardy heron 8.04, only changed away from Ubuntu as gnome 3 killed my pc)
Kubuntu(KDE)
There are more but here is a few

Note: forgot to say Google is your friend when learning using Ubuntu as someone else has always been there before!

You will find that once you get over the hump of getting used to Linux you will only ever boot into windows for things that you can't do under Linux like design spark, I actually run a Windows virtual machine on my NAS so I can quickly RDP to it when I need it but that is an overly complicated way of doing things.

Re: STM32 Coding for Dummies!

Posted: Sat Feb 06, 2021 12:34 am
by jon volk
Speaking of pointers, I found this video quite helpful. It goes into far great detail with lots of examples over some of the shorter basic explanations out there.