Over 10 years we help companies reach their financial and branding goals. Engitech is a values-driven technology agency dedicated.



411 University St, Seattle, USA


+1 -800-456-478-23

Embedded MCU's Getting Started and Peripheral Coding STM32 MCU's STM32F1

STM32 Overview

What is STM32 ?

STM32 is a family of 32-bit Microcontrollers and development boards manufactured by ST Microelectronics which offer very high performance for a relatively low price. All STM32 microcontrollers are based on ARM Cortex-M processor which make them much better in terms of computing power than most of the common microcontrollers/microcontroller development boards which are available in the market. These microcontrollers also have been provided with software support by ST for developers for free.

If you have experience with microcontrollers like Arduino, this is a great step forward in understanding microcontrollers in depth. The STM32 framework allows you to control all peripherals and allows you to tweak them as per your wish, whereas in Arduino IDE, when you program in C++, it comes with in-built functions and libraries which don’t allow you to understand the backend working behind everything. This is very crucial, as it allows you to use the microcontroller to its full potential.


The STM32 family of microcontrollers is vast and expansive, offering a variety of options for the consumer to choose from. The family of microcontrollers is broadly classified into 4 categories-

High performance

ST offers a series of microcontrollers which have the fastest code execution time, high speed data transfer and relatively higher flash memory. Along with this, the feature the most advance peripherals that ST offers. This makes these controllers very useful for real-time applications such as running an RTOS.

The F4 series is broadly divided into 3 segments-


The main focus of the STM32Wx microcontroller family is wireless connectivity. They cover sub-GHz as well as 2.4Ghz frequency range operation

The STM32 wireless MCUs are further divided into 2 categories

These MCUs have a dual core processor unit, Cortex M4 & Cortex M0+, which allows for processing distribution, making it a great candidate for real-time processing and execution. The MCU series is based on STM32L4 architecture, which offers dynamic voltage scaling, reducing the power consumption of the device. They also support BLE 5.3, Open Thread and Zigbee protocols, making them a great choice for IOT applications, providing a lot of functionality onboard the chip itself.

These MCUs also come with a dual core processor unit like the STM32WB series, and some variants also come with a single ARM Cortex M4 as their processing unit. The key highlight of this series of microcontrollers is that not only do they work as a general purpose microcontroller, but also come with an integrated sub GHz radio supporting LoRa WAN which makes it a great choice for smart home applications, utilities, logistics, Industrial IOT etc.


Ultra-Low Power –

STM32 ultra-low-power microcontrollers offer designers of energy-efficient embedded systems and applications a balance between performance, power, security and cost effectiveness. The portfolio includes the STM8L (8-bit proprietary core), the STM32L4 (Arm® Cortex®-M4), the STM32L0 (Arm® Cortex®-M0+) and the STM32L1 (Arm® Cortex®-M3).

The STM32L5 MCU (Arm® Cortex®-M33) with its enhancedsecurity features is the latest addition to this rich portfolio.


The mainstream microcontrollers are more general-purpose boards which offer a large variety of applications and do not have proclivity towards only a single application. These can be considered well balanced devices in terms of performance vs power consumption and come at affordable prices meant for robust applications.

Getting Started-

To get started with STM32, it is common practice to get an evaluation board / development board.  Evaluation boards are useful when you need to test the peripherals onboard the microcontroller and see whether the selected MCU is the best choice for your project / device or not. These boards are generally breadboard friendly or sometimes come with sensors and some output devices like displays onboard, which eliminates the need for a breadboard. You can imagine these boards as the equivalent of an Arduino UNO in the STM32 world.

Blue Pill (STM32F103C8T6)-

The Blue pill is based around the STM32F103C8T6 microcontroller chip. It is based on ARM Cortex M3 and comes with many features and rich peripherals like-

 This board is also very well documented online by the community. To program this board, you can use Keil µ Vision, STM32 Cube IDE (explained here) and even Arduino IDE, as some developers have made it possible to work with it using the Arduino bootloader, which would allow you to directly program it via micro-USB. To just get started with the STM32 environment, the Blue Pill is a great choice.

To work with any STM32 microcontroller, ST Microelectronics provides a Software Development Kit (SDK), which is a collection of software tools to program and debug the device.


Let’s say you are very new to programming in general and also very new to the STM32 environment, or you are just interested in developing a project using this class of microcontrollers to get an end result. You most likely are not bothered with going down to the register level and changing values for reading/writing, some basic GPIO functionality, using PWM, or working with communication buses like UART, SPI, I2C etc. For the ease of programming for the user (i.e., you) ST provides what is called a Hardware Abstraction Layer.

The Hardware abstraction layer is an API (Application programming Interface) which allows you to simply use the functions provided in it’s files to work with the hardware in your microcontroller. Here, we can draw a very good comparison between HAL and the Arduino IDE. When you program in the Arduino IDE, you can use certain functions such as pinMode( ) digitalWrite( ) Serial.print() etc. which require the microcontroller to do some register manipulation in order to work with the pins on your Arduino. But have you ever noticed that you never have to include any library for this functionality?

The Arduino IDE by default includes some files while you write your code to make it easier to work with it. That is the reason why Arduino sketches are on average larger in size than they always need to be. But it comes with the benefit of ease for the user to program and implement ideas.

STM32 HAL is very similar to this. This API is provided for all microcontroller series manufactured by ST Microelectronics, making it simpler to use the hardware peripherals on your microcontroller and saving much of your time. HAL provides these drivers to operate certain things on your microcontroller such as Timers, Counters, Interrupts, GPIO, UART, SPI, I2C etc.

For further reading, you can refer to the official documentation done by ST – https://www.st.com/resource/en/user_manual/um1725-description-of-stm32f4-hal-and-lowlayer-drivers-stmicroelectronics.pdf

STM32 Debuggers

The STM32 environment wouldn’t be complete without debuggers. These are devices provided by STM officially and also unofficially by some vendors which are popular. Debuggers allow you to interface with your STM32 microcontroller for uploading code and also debugging your code.

They come in 2 versions, an official one provided by STM, and one unofficial which people have developed and is cheaper to buy.

STlink-V2 USB dongle (unofficial) –

This is an unofficial version which is very popular and used by many people working with STM32 microcontrollers. The device has header pins at the back to which you can attach jumper wires and attach to your STM32 microcontroller by connecting the corresponding pins. When you do this and attach this dongle to your PC, you can debug and dump programs into your flash memory. After connecting, you can open STM32 Cube Programmer and follow the steps described below to upload your code and debug it.

For connecting your STM32 board to the STlink V2 Dongle , here is a schematic-

Note that this device maybe cheap to buy, but the product quality depends on the vendor that you pick. Some of these devices either work flawlessly without any problems or can be an absolute nightmare to get working. Sometimes they straight up don’t even work. Some manufacturers provide it with older firmware and sometimes you might need to even use older versions of STM32 Cube Programmer or even use the very old ‘ST link utility’ software to get these devices to work. You can use it to program your Microcontroller, but it is advisable to read product reviews before purchasing this device.


ST-link V2 (official)-

The official ST-link V2 is provided by ST Microelectronics and accomplishes the same tasks that ST-link V2 dongle does. It provides something that the unofficial version doesn’t, that is the JTAG debugging feature. Apart from that you can use the trace feature for debugging as well. Best part about this device is that it is reliable and probably won’t require you to troubleshoot much once you connect it to your PC.



Leave a comment

Stay Updated With Us