The last few years has seen a renaissance of hobbyists and inventors building custom electronic devices. These systems utilize off-the-shelf components and modules whose development has been fueled by a technological explosion of integrated sensors and actuators that incorporate much of the analog electronics which previously presented a barrier to system development by non-engineers. Micro-controllers with custom firmware provide the glue to bind sophisticated off-the-shelf modules into complex custom systems. This book provides a series of tutorials aimed at teaching the embedded programming and hardware interfacing skills needed to use the STM32 family of micro-controllers in developing electronic devices. The book is aimed at readers with ’C’ programming experience, but no prior experience with embedded systems.
The STM32 family of micro-controllers, based upon the ARM CortexM3 core, provides a foundation for building a vast range of embedded systems from simple battery powered dongles to complex real-time systems such as helicopter autopilots. This component family includes dozens of distinct configurations providing wide-ranging choices in memory sizes, available peripherals, performance, and power. The components are sufficiently inexpensive in small quantities – a few dollars for the least complex devices – to justify their use for most low-volume applications. Indeed, the low-end “Value Line” components are comparable in cost to the ATmega parts which are used for the popular Arduino development boards yet offer significantly greater performance and more powerful peripherals. Furthermore, the peripherals used are shared across many family members (for example, the USART modules are common to all STM32 F1 components) and are supported by a single firmware library. Thus, learning how to program one member of the STM32 F1 family enables programming them all.
Unfortunately, power and flexibility are achieved at a cost – software development for the STM32 family can be extremely challenging for the uninitiated with a vast array of documentation and software libraries to wade through. For example, RM0041, the reference manual for large value-line STM32 F1 devices, is 675 pages and does not even cover the Cortex-M3 processor core ! Fortunately, it is not necessary to read this book to get started with developing software for the STM32, although it is an important reference. In addition, a beginner is faced with many tool-chain choices. 2 In contrast, the Arduino platform offers a simple application library and a single tool-chain which is accessible to relatively inexperienced programmers. For many simple systems this offers a quick path to prototype. However, simplicity has its own costs – the Arduino software platform isn’t well suited to managing concurrent activities in a complex real-time system and, for software interacting with external devices, is dependent upon libraries developed outside the Arduino programming model using tools and techniques similar to those required for the STM32. Furthermore, the Arduino platform doesn’t provide debugging capability which severely limits the development of more complex systems. Again, debugging requires breaking outside the confines of the Arduino platform. Finally, the Arduino environment does not support a real-time operating system (RTOS), which is essential when building more complex embedded systems.
For readers with prior ’C’ programming experience, the STM32 family is a far better platform than the Arduino upon which to build micro-controller powered systems if the barriers to entry can be reduced. The objective of this book is to help embedded systems beginners get jump started with programming the STM32 family. I do assume basic competence with C programming in a Linux environment – readers with no programming experience are better served by starting with a platform like Arduino. I assume familiarity with a text editor; and experience writing, compiling, and debugging C programs. I do not assume significant familiarity with hardware – the small amount of “wiring” required in this book can easily be accomplished by a rank beginner.