So let’s get started with STM32. Today we will be looking into the first part of this STM32 guide and it is just the introduction. This guide will be very useful for beginners who wants to get their hands dirty with STM32 microcontrollers. So keep follow us with this guide.
Introduction to STM32
STM32 is actually not a specific microcontroller, it is a name given by STMicroelectronics to their ARM Cortex-M based microcontroller family.
STM32 family can be mainly divided into 4 groups.
1 - High Performance (STM32F2 series, STM32F4 series, STM32F7 series, STM32H7 series, etc.)
2 - Mainstream (STM32F0 series, STM32F1 series, STM32F3 series, etc.)
3 - Wireless (STM32WB series, etc.)
4 - Ultra Low Power (STM32L0 series, STM32L1 series, STM32L4 series, STM32L4+ series, STM32L5 series, etc.)
This is a STM32F103C8 Development Board (Bluepill)
This one here is a STM32F411RE NUCLEO Development Board
1 - Comparison with Atmega328 with STM32F103
You can see how STM32F1 series performs way better than ATmega328. Not only this, the prize is also reasonable, like you can get STM32F103 chip for RS 250 – 300, while ATmega328 will cost around RS 350 – 400.
2 - Has a great graphical tool called CubeIDE for HAL (Explained in the latter part of this post) drivers which generates the startup code.
3 - Functionalities are high.
4 - 5V Tolerant - This means STM32s are capable of accepting 5V on their inputs.
5 - Pin to pin compatibility - This means pins of a one chip are mostly identical to those of other chips. So that you can swap STM32 chips with your designs very easily according to the need. Still, attention needs to be paid for some pins like supply pins and regulator caps.
6 - More resources are available to help you with your projects.
Picking a microcontroller
The STM32 family consists of many different microcontrollers, so that it will be hard for a beginner to choose one. But luckily most basic things that a beginner should learn are common to all microcontrollers in the STM32 family.
But there are two series that are better suited for a beginner than the other series. Those are the STM32F1 series and the STM32F4 series. Reason is 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 chips.
This is the view of STM32F103 chip in CubeIDE
This is the view of STM32F411 chip in CubeIDE
IDE means Integrated Development Environment and when installed, they install all needed software like compilers and drivers needed for programming.
Some IDEs can be used free of charge while some require a license to be bought. Some famous IDEs that use for STM32 programming are listed below.
b) Arm Keil MDK
e) Atollic TrueSTUDIO
f) Segger Embedded Studio
This is the view of CubeIDE
Platforms offer their own APIs for controlling a device. Mainly there are two available platforms available for stm32 microcontrollers.
a) STM32duino - This one implements the Arduino API for STM32 microcontrollers and it can be used with Arduino IDE.
b) ARM Mbed - This platform not only supports STM32 microcontrollers but also supports a wide range of devices from different vendors. Mbed includes an OS specifically developed for IoT applications. It has both a cloud based IDE and a downloadable one.
Introduction to HAL (Hardware Abstraction Layer)
Hardware abstraction layer is a layer of programming in an operating system that allows to interact with hardware at a general or abstract level rather than a detailed hardware level. Simply, a hardware platform which can run applications. When HAL is employed, applications do not need to access hardware directly. They can access hardware through the abstract layer provided by HAL.
The HAL drivers designed by STMicroelectronics, offer a rich set of APIs to interact hardware easily with the application upper layers. The STM32Cube package comes with ready to use project templates, one for each supported board. Each of these project template provides empty main loop function and can be used as a starting point to get familiar with project settings for STM32Cube. Because of this, the code used for a STM32 can easily ported to any other STM32 with minor effort, as long as the required hardware functionality is there.
Benefits of using HAL
a)Allowing applications to extract as much performance out of the hardware devices as possible.
b)Enabling device drivers to provide direct access to each hardware device, which allows programs to be device independent.
c)Allowing software programs to communicate with the hardware devices at a general level.
d)Portability facility as mentioned above.
That’s all for the introduction part. Next time we will be looking into the programming of STM32 using STM32CubeIDE.
You can download STM32CubeIDE using this site and be ready for the next time
To get some basic understanding about STM32CubeIDE watch this video
When programming in STM32CubeIDE, knowledge in C++ will be helpful. So for those who are not familiar with C++, you can start learning C++ using following courses or any other way that you like.