Getting started with STM32

Welcome to the first guide in a series of guides. This guide is intended for beginners (hobbyists, students) who want to get started with STM32 microcontrollers but don’t know how to or where to get started.

This guide gives you an overview of the available hardware and software for working with STM32 microcontrollers. Also, it will briefly introduce you to the STM32 family of microcontrollers.

All guides, except this one, assume you will be using the STM32-base project. To be able to follow the following guides, you will need a basic understanding of the C programming language. Prior experience with an embedded platform is not required.

Introduction to STM32

STM32 does not refer to one specific microcontroller. It is the name STMicroelectronics gave to their ARM Cortex-M based microcontroller family. The STM32 family itself can be divided into multiple groups, which in turn can be divided into series.

The STM32 family currently consists of fifteen series. These series are grouped in four different groups: High Performance, Mainstream, Ultra Low Power, and Wireless. The following list briefly describes each series:

Hardware

You will need at least one development board to get started. Without a development board, you can not run or debug your code properly. If you already own a development board, you can skip this chapter.

Microcontrollers

The STM32 family consists of many different microcontrollers. Picking one is hard for a beginner. Luckily, most things you will need to learn first are common to all microcontrollers in the STM32 family. This means you can start with virtually any STM32 microcontroller.

There are two series that are better suited for beginners than the other series. The STM32F1 series and the STM32F4 series. And the reason is simple:

Both series are around for a long time and are still popular among hobbyists. This means that there are a lot of resources available for devices in these series. Also, the devices in the STM32F1 series are not as complex as most other parts.

Development boards

Most development boards are designed to work with as few components as possible. They are designed this way to be as cheap as possible and to not limit the user in any way. There are also boards that feature additional components such as LEDs, sensors, and memories.

Most pins, if not all, of the microcontroller are exposed via headers for easy access. There is also at least one dedicated header for connecting a debugger.

Development boards are manufactured by different parties. STMicroelectronics offers three different ranges of development boards:

There are also many boards that can be bought from Ebay and AliExpress. The most popular ones are the Blue Pill and the Black Pill. The latter is an improved version of the first one.

Recommendations

Both the Nucleo and Discovery boards are very well suited for absolute beginners. They are guaranteed to work properly and include a builtin debugger. And all this for reasonable prices. If you are in a very thight budget, you can buy one of the Chinese development boards. The following boards are recommended for beginners:

Software

If you want to get started with the STM32-base project, you don’t have to make a lot of choices on the software side. The STM32-base project is designed to be used with the GNU Arm Embedded Toolchain. STM32-base can be used with you favorite code editor. A recommendation for an editor is Visual Studio Code.

Other software discussed in this chapter can be used when you do not want to use the STM32-base project. The other software is discussed to give you a better overview of all available software for STM32 microcontrollers.

IDEs

IDE stands for Integrated Development Environment. This usually means that, once installed, an IDE is ready to be used without any further actions required. IDEs install all required software, like compilers and drivers, once they are installed.

Some IDEs are free, others require a licence to be bought. The IDEs listed here are potentially interesting to beginners and hobbyists since they’re free. For a complete overview of available IDEs, refer to the ST website.

Platforms

Platforms offer, in addition to an IDE, their own API for controlling a device. Platforms like these are usually aimed at prototyping. There are two platforms available for STM32 microcontrollers.

The first one is STM32duino. This platform implements the well known Arduino API for STM32 microcontrollers. It can be used with the Arduino IDE.

The second one is Arm Mbed. This platform supports not only STM32 microcontrollers. It supports a wide range of devices from different vendors. Mbed includes an OS specifically developed for IoT applications. It has both an cloud based IDE and a downloadable variant.

Other

ST offers an CMSIS and HAL for each device series. The CMSIS contains all the register and peripheral definitions needed to make use of the available peripherals on a microcontroller. The HAL is a higher level library that offers portability of code between different series. The CMSIS and HAL code is distributed in so-called STM32Cube packages.

A popular open-source alternative to the official CMSIS is libopencm3. This project aims to create an open-source firmware library for Arm Cortex-M microcontrollers. Not all STM32 series are supported.