STM32 Coding for Dummies!

Post Reply
User avatar
james@N52E01
Posts: 144
Joined: Wed Sep 18, 2019 7:02 am
Has thanked: 2 times
Been thanked: 3 times

STM32 Coding for Dummies!

Post 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.

User avatar
johu
Site Admin
Posts: 5799
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 160 times
Been thanked: 1033 times
Contact:

Re: STM32 Coding for Dummies!

Post by johu »

You mean for slightly altering the inverter firmware or starting a whole new project?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: STM32 Coding for Dummies!

Post 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:)
I'm going to need a hacksaw
User avatar
james@N52E01
Posts: 144
Joined: Wed Sep 18, 2019 7:02 am
Has thanked: 2 times
Been thanked: 3 times

Re: STM32 Coding for Dummies!

Post 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
User avatar
james@N52E01
Posts: 144
Joined: Wed Sep 18, 2019 7:02 am
Has thanked: 2 times
Been thanked: 3 times

Re: STM32 Coding for Dummies!

Post 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.
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: STM32 Coding for Dummies!

Post 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
Formerly 92 E30 BMW Cabrio with Tesla power
User avatar
rstevens81
Posts: 353
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 23 times
Been thanked: 92 times

Re: STM32 Coding for Dummies!

Post 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.
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: STM32 Coding for Dummies!

Post 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.

Formerly 92 E30 BMW Cabrio with Tesla power
Post Reply