ARM STM32 peripheral functions and their relation to firmware libraries

What is the role of firmware?

MCUs have a variety of built-in peripheral functions (peripherals). Typical examples are general-purpose input/output GPIOs, but GPIO control registers must be set to define the details of input/output functions for each pin of the MCU.

The reference manuals for MCUs describe register details, but it is difficult even for experienced users to program register settings according to these manuals. Embedded engineers who use MCUs are concerned with creating applications and do not want to spend time and effort on understanding and configuring the hardware-oriented parts of MCUs, which vary from company to company.

Therefore, each MCU manufacturer provides firmware, a peripheral library, as a device driver to operate the hardware. Therefore, once you understand how to use the peripheral library (device driver), which is the part that depends on the hardware of the microcontroller model used, you can concentrate only on application development.

For some embedded devices, it is possible to reduce program size and improve performance, such as response time, by directly setting control registers instead of using firmware. As your embedded skills increase and you become more familiar with it, why not give it a try?

Software and System Configuration

For relatively simple, single-function embedded devices, software can be configured with only device drivers and application software (Configuration A). However, for multifunctional embedded devices that simultaneously monitor and communicate and drive motors, an OS (Operation System) is required to operate various functions in parallel (Configuration B).

Embedded devices require real-time control, so RTOS (RealTime Operation System) is used. In addition, a software communication protocol stack is required when incorporating Ethernet communication, etc. Such software is called middleware (Configuration C).

The application is the top-level program in the system configuration, but it is completely unaffected by the hardware and can be used with any type of MCU (some modifications may be necessary). However, please be aware that it is not compatible with microcontrollers with different bit counts (from a 32-bit MCU to an 8-bit microcontroller).

Software configuration

Why use the library SPL?

The MCU used in this site is the STM32F1 series with ARM Cortex-M3 core, and the firmware uses a peripheral library (device driver) called Standrd Peripheral Library (SPL).

As manufacturers develop and release new, high-performance microcontrollers to keep pace with technological advances, they also update their development environments. Naturally, firmware is also updated, and firmware is in the process of shifting from SPL to a library called HAL (Hardware Abstraction Layer).

HAL features a driver with a high level of abstraction that also takes portability from the STM32 MCU into consideration, pursuing convenience to shorten the development period. In the future, development for STM32 MCUs will probably be centered on HAL, but the program code size will become larger and there will be black box elements.

While it is good for those who understand the basics of MCUs before using them, those who start with HAL to learn embedded technology may be left with superficial knowledge that they cannot put to practical use.

Since this site is intended for beginners in embedded technology, I will not use HAL and will proceed with SPL, which is a simple and easy-to-understand macro that relates to control registers and has a relatively small program code size.

Another advantage of the SPL is the wealth of information available on its use. You can get most of the information and application examples on the Internet. If you study intensively, you will probably be able to learn how to use MCU right away.

What is important is the skill to build a good application of the system, including the system design, which is a universal skill for any microcomputer system. SPL is suitable for learning because it is easy to understand the concept of MCU, and it is also easy to move on to other MCU systems. I think it is a good idea. Please keep in mind at all times that the purpose of this site is to learn the basic skills of embedded technology and use them in applications.

The point

Once you have become accustomed to the STM32 MCU to some extent, shifting to the latest development environment and using HAL will demonstrate its usefulness.

Follow me!