Our new book “STM32Cube Efficient Development Tutorial (Basic Volume)” has finally been printed and is now available on major e-commerce platforms. Below is the “Introduction” of the book, serving as a brief overview to give everyone a preliminary understanding of it. I will write further articles to introduce the specific content of each chapter, as well as how to obtain and use the source code, example run videos, example run images, presentation materials, and other resources provided for readers. Additionally, the “STM32Cube Efficient Development Tutorial (Advanced Volume)” is expected to be printed around October.

Purpose and History of Writing
The STM32 series MCUs (Microcontrollers) are widely used 32-bit MCUs in China, and there are many books available on STM32 development. However, unbeknownst to many, the development approach for STM32 has undergone significant changes. In 2014, STMicroelectronics launched the HAL driver library and the graphical configuration software STM32CubeMX. At the end of 2017, ST acquired Atollic and converted the professional version of TrueSTUDIO into free software. In April 2019, ST officially launched its own STM32 program development IDE tool software STM32CubeIDE 1.0.0, forming a complete STM32Cube ecosystem.
@STM32Cube Ecosystem
(Source: ST Official Document STM32Cube_Ecosystem_Overview.pdf)
The STM32Cube ecosystem has completely abandoned the early standard peripheral library, and all STM32 series MCUs provide HAL firmware libraries and a wealth of expansion libraries. The two core software components of the STM32Cube ecosystem are STM32CubeMX and STM32CubeIDE, both of which are provided for free by ST. Using STM32CubeMX allows for visual configuration of MCU system functions and peripherals, and it can generate STM32CubeIDE project framework code, including system initialization code and initialization code for configured peripherals. When users want to add their application code based on the generated STM32CubeIDE initial project, they only need to write their code in the code sandbox section, and they can modify the MCU settings in STM32CubeMX and regenerate the code without affecting the user-added program code.
The development method using STM32CubeMX and STM32CubeIDE is referred to as the STM32Cube development method, which has several advantages:
● Using software that is all provided for free by ST allows for timely updates from ST and avoids potential intellectual property risks associated with commercial software.
● The STM32 ecosystem has a rich set of official or third-party expansion libraries and middleware available, such as the embedded operating system FreeRTOS, file management system FatFS, GUI creation tool TouchGFX, and AI programming implementation X-CUBE-AI.
● Using STM32CubeMX for MCU visual configuration and generating initialization code can greatly improve work efficiency, and the generated code is highly accurate and well-structured, reducing the learning difficulty of STM32 development.
● Programming based on the HAL library in STM32CubeIDE only requires following some basic programming rules (for example, rules for interrupt handling, rules for separating peripheral initialization from application code), allowing for the writing of high-quality programs that are more efficient and of higher quality than pure manual coding.
The HAL library and STM32CubeMX were introduced in 2014, and there are very few books covering this area. Some books even retain traces of the standard library when introducing HAL library programming, failing to fully utilize STM32CubeMX. Some example programs provided by development boards on the market are still based on the standard library, leading students who purchase development boards for self-study to learn the standard library development method, or to encounter numerous issues due to a lack of systematic materials when learning HAL development.
In early 2018, I became aware of ST’s acquisition of Atollic and the conversion of TrueSTUDIO’s professional version to free software, realizing that using STM32CubeMX and TrueSTUDIO for STM32 development was a good combination, and I planned to write a book to systematically introduce how to develop STM32 using STM32CubeMX and TrueSTUDIO.
In early 2019, to prepare teaching content for undergraduates, I began writing this book and designing examples using STM32CubeMX and TrueSTUDIO. In April 2019, ST released STM32CubeIDE 1.0.0, and during the initial trial, I discovered many bugs, including build errors in the initial STM32CubeIDE project generated by STM32CubeMX. Therefore, I continued to use TrueSTUDIO to complete all example designs. After finishing all examples and drafts in early 2020, I converted all example programs to the latest version of STM32CubeIDE without encountering build or runtime errors. I then rewrote all examples using STM32CubeIDE (not converted from TrueSTUDIO examples), during which I restructured and optimized the programs and rewrote the entire book content based on the final STM32CubeIDE example code.
The final version of the book is locked to the following software versions: STM32CubeMX 5.6.0; STM32CubeIDE 1.3.0; STM32F4 MCU firmware library version 1.25.0. The system platform used is a 64-bit Windows 7 system, and all example projects have been validated on the普中STM32F407 development board, with the MCU model being STM32F407ZGT6.
Content and Example Programs Covered
The two books (“STM32Cube Efficient Development Tutorial (Basic Volume)”, hereinafter referred to as “Basic Volume”; “STM32Cube Efficient Development Tutorial (Advanced Volume)”, hereinafter referred to as “Advanced Volume”) use STM32CubeMX and STM32CubeIDE as development tools, taking STM32F407 and a development board as examples to comprehensively introduce the STM32Cube development method and the use of the HAL library, including the programming of commonly used peripherals of STM32F407, as well as the use of middleware such as FreeRTOS and FatFS. Due to the extensive content, it is divided into two volumes: “Basic Volume” and “Advanced Volume”.
The “Basic Volume” introduces the development software used in the STM32Cube development method, as well as the use of the STM32F407 system functions and commonly used peripherals. The “Basic Volume” consists of 22 chapters, divided into two major parts.
● The first part is the hardware and software basics, introducing the composition of the STM32Cube ecosystem, the use of STM32CubeMX and STM32CubeIDE software, the basic architecture and minimum system circuit principles of STM32F407, as well as the functions of the普中STM32F407 development board. The use of these two software tools is the foundation of the STM32Cube development method.
● The second part covers the use of system functions and commonly used peripherals, including the principles and uses of the interrupt system, DMA, low-power principles, as well as the use of commonly used peripherals such as timers, RTC, ADC, USART, SPI, and I2C.
The “Advanced Volume” introduces the use of some middleware in the firmware library, as well as some advanced interfaces. The “Advanced Volume” consists of 22 chapters, starting from chapter 1, and the content is divided into three major parts.
● The first part is the use of the embedded operating system FreeRTOS, which contains 11 chapters, providing a comprehensive introduction to almost all the functions of FreeRTOS V10, including task management, interrupt management, inter-process communication technology, software timers, low-power modes, etc. Among them, the inter-process communication technology not only introduces conventional queues, semaphores, mutexes, event groups, and task notifications, but also covers the flow buffer and message buffer technologies introduced in version V10.
● The second part covers using FatFS for file system management, containing 6 chapters. This part introduces the process of porting FatFS to SPI interface Flash chips, methods for managing file systems using FatFS on SD cards and USB drives, as well as methods for using FatFS in FreeRTOS. This part involves the usage methods of the SDIO interface and USB-OTG as either host or peripheral.
● The third part discusses image acquisition and display, containing 5 chapters. This part introduces reading, writing, and displaying BMP image files, using middleware LibJPEG to read, write, and display JPG image files, the use of resistive and capacitive touch screens, and simple GUI program design methods, as well as methods for connecting digital cameras via the DCMI interface to acquire images.
The “Basic Volume” covers the foundational content of STM32 development, including software usage and programming of commonly used peripherals. If one only wants to learn bare-metal development and the use of commonly used peripherals of STM32, studying the “Basic Volume” is sufficient. The “Advanced Volume” includes middleware such as FreeRTOS, FatFS, USB_Host, USB_Device, LibJPEG, and advanced interface usage like SDIO, USB-OTG, and DCMI. Many examples in the “Advanced Volume” require knowledge of the content and programs introduced in the “Basic Volume”, so readers must first study the content of the “Basic Volume” to understand the “Advanced Volume”.
In each chapter that introduces specific peripherals or knowledge points, this book first explains the technical principles and the HAL driver program, followed by one or more complete example projects demonstrating the functionality. All examples have been tested and verified on the STM32F407 development board. The book provides source code downloads for all example projects, and readers can download the resources of this book from the Asynchronous Community website of People’s Posts and Telecommunications Press.
The example projects in this book are designed specifically for the普中STM32F407 development board. If readers use a different development board, they need to modify the MCU configuration in the STM32CubeMX project file or the source program according to the actual circuit of their development board. I considered the portability issues of different development boards when designing the example programs for this book, minimizing hardware-related configurations. Fortunately, the STM32Cube development method separates peripheral initialization from peripheral usage, so hardware-related modifications are primarily made in STM32CubeMX, with minimal software changes required.
Additionally, most example projects in this book require using an LCD to display information, and the LCD driver program is the foundation for designing and running all example projects. This book provides the LCD driver program used by the普中STM32F407 development board and introduces methods for rewriting the LCD standard library driver program using the STM32Cube method. If readers use a different development board, they can rewrite the LCD driver program according to the methods introduced in Chapter 8 of the “Basic Volume”.
The example project programs in this book have a clear structure and high code quality. Even if they cannot be run and tested on their own development boards, readers can easily understand the principles of program design by combining the explanations in this book.
Features and Usage Conventions of This Book
Readers of this book are expected to have studied courses in digital circuits, microcomputer principles, and C language, and it is best if they have also studied MCS-51 or MSP430 microcontrollers, having a certain foundation in microcontroller development. This book will not start from STM32 assembly language programming, nor will it specifically discuss the function and configuration of each bit of a register, as the HAL driver library encapsulates register-level operations with functions.
This book focuses on application software programming, and the analysis of the internal hardware structure and registers of STM32 is mainly to explain the working principles of the HAL driver program, without a comprehensive, in-depth analysis of the internal hardware. When introducing the use of FreeRTOS, this book primarily introduces the functionality and usage of FreeRTOS API functions, without delving into the source code of FreeRTOS unless necessary. However, for some content requiring an understanding of principles, this book will provide detailed analysis, such as the general process of HAL interrupt handling, the program principles of associating interrupt events with callback functions, and the principles of associating DMA interrupts with peripheral callback functions.
This book contains many abbreviations, and it cannot be guaranteed that every abbreviation will be explained upon its first occurrence. Some common abbreviations do not require explanation and can be referenced in Appendix E.
The example programs in this book use C language and do not use C++ language, although STM32CubeIDE supports C++ language programming. This book abbreviates STM32CubeMX as CubeMX and STM32CubeIDE as CubeIDE.
Acknowledgments
I started writing this book in early 2019, and I used parts of the initial draft as course materials for students of the 2016 and 2017 classes of Automation and Measurement Control at China University of Petroleum (East China) during the “Embedded System Development” course, and for Measurement Control students of the 2017 class in the “Fundamentals of Instrument Design” course. Many students (LJW, ZLM, LY, etc.) helped me find errors and provided valuable suggestions for revising the manuscript. Student BHL even wrote some example programs for the “Basic Volume”. Some students demonstrated strong creativity when applying the development methods taught to complete their course projects, designing some excellent works that inspired me as well, and I would like to thank these wonderful students together.
I have been engaged in teaching for many years and understand students’ learning characteristics, as well as how to teach them programming and development. As a teacher, I fear that students might not learn well and worry that I may not explain things clearly. I have diligently written down what I know, optimizing the programs repeatedly and refining the text, all to produce a good book.
Each time I see readers comment that my book has helped them in their studies and work, solving practical problems, I feel very happy. Therefore, I would like to thank the readers for their support and affirmation.