Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Bare-Metal Embedded C Programming

You're reading from   Bare-Metal Embedded C Programming Develop high-performance embedded systems with C for Arm microcontrollers

Arrow left icon
Product type Paperback
Published in Sep 2024
Publisher Packt
ISBN-13 9781835460818
Length 438 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Israel Gbati Israel Gbati
Author Profile Icon Israel Gbati
Israel Gbati
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Chapter 1: Setting Up the Tools of the Trade FREE CHAPTER 2. Chapter 2: Constructing Peripheral Registers from Memory Addresses 3. Chapter 3: Understanding the Build Process and Exploring the GNU Toolchain 4. Chapter 4: Developing the Linker Script and Startup File 5. Chapter 5: The “Make” Build System 6. Chapter 6: The Common Microcontroller Software Interface Standard (CMSIS) 7. Chapter 7: The General-Purpose Input/Output (GPIO) Peripheral 8. Chapter 8: System Tick (SysTick) Timer 9. Chapter 9: General-Purpose Timers (TIM) 10. Chapter 10: The Universal Asynchronous Receiver/Transmitter Protocol 11. Chapter 11: Analog-to-Digital Converter (ADC) 12. Chapter 12: Serial Peripheral Interface (SPI) 13. Chapter 13: Inter-Integrated Circuit (I2C) 14. Chapter 14: External Interrupts and Events (EXTI) 15. Chapter 15: The Real-Time Clock (RTC) 16. Chapter 16: Independent Watchdog (IWDG) 17. Chapter 17: Direct Memory Access (DMA) 18. Chapter 18: Power Management and Energy Efficiency in Embedded Systems 19. Index 20. Other Books You May Enjoy

Datasheets and manuals – unraveling the details

Our main objective in this book is to write firmware code that interacts directly with the registers of our microcontroller. This means there’s no abstraction or intermediary library between our code and the target microcontroller. To achieve this, it’s important to grasp the internal architecture of the microcontroller, understand the addresses of each register we interact with, and know the functions of relevant bits within those registers. This is where datasheets and manuals come in. Manufacturers provide these documents for users to understand their products, which in our case refers to the microcontroller core architecture, the microcontroller, and the development board.

Two distinct companies play roles in the making of our development board. The first is ARM Holdings, which licenses processor and microcontroller core architecture designs to semiconductor manufacturing firms such as STMicroelectronics, Texas Instruments, and Renesas. These manufacturers then produce the physical microcontroller or processor based on the licensed designs from ARM, often with their custom additions. This explains why two different microcontrollers from separate manufacturers might share the same microcontroller core. For instance, both the TM4C123 from Texas Instruments and STM32F4 from STMicroelectronics are based on the ARM Cortex-M4 core.

Since our chosen development board, the NUCLEO-F411 from STMicroelectronics, is based on the ARM Cortex-M4 microcontroller core, in the following sections, we’ll delve into the documentation for the board, its integrated microcontroller, and the underlying core.

Understanding STMicroelectronics’ documentation

A significant reason for the popularity of STM32 microcontrollers is STMicroelectronics’ continued commitment to providing comprehensive support. This includes well-organized documentation and various firmware development resources.

STMicroelectronics has a range of documents, each following a specific naming convention. Let’s discuss those relevant to our work:

  • Reference Manual (RM): All RMs start with the letters RM, followed by a number. For instance, the RM for our microcontroller is RM0383. This document details every register in our microcontroller, clarifying each bit’s role and providing insights on register configurations.
  • Datasheet: The datasheet is named after the microcontroller, so for the STM32F411 microcontroller, the datasheet is simply called STM32F411. This document provides a functional overview of the microcontroller, a complete memory map, a block diagram showcasing the microcontroller’s peripherals and connecting buses, as well as the pinout and electrical characteristics of the microcontroller.
  • UM (User Manual): Starting with the letters UM and followed by a number, such as UM1724 for our NUCLEO-F411, this document focuses on the development board. It describes how components on our board, such as LEDs and buttons, are connected to specific ports and pins of the microcontroller.

The generic user guide by ARM

ARM provides documents for every microcontroller and processor core they design. Important to our discussion is the generic user guide for our microcontroller core. As we’re using the STM32F411, which is based on the ARM Cortex-M4 core, we’ll refer to the Cortex-M4 generic user guide.

This means that if we were using an STM32F7 microcontroller, which is based on the ARM Cortex-M7 core, then we would need to get the Cortex-M7 generic user guide. The naming convention of this document is simply the name of the microcontroller core + the phrase generic user guide.

As the name implies, this document provides information generic to the specific microcontroller core. This means that the information provided in the Cortex-M4 generic user guide applies to all microcontrollers based on the Cortex-M4 core, irrespective of the manufacturers of those microcontrollers. In contrast, the information provided in the STMicroelectronics documentation applies to only STMicroelectronics’ microcontrollers.

Figure 1.14: The relationship between the development board, microcontroller, and microcontroller core

Figure 1.14: The relationship between the development board, microcontroller, and microcontroller core

Why do we need the generic user guide?

The generic user guide provides information on the core peripherals of the processor core. As the term suggests, these core peripherals are consistent across all microcontrollers, based on a specific core. The Cortex-M4 core has five core peripherals – the System Timer, Floating-Point Unit, System Control Block, Memory Protection Unit, and the Nested Vectored Interrupt Controller. When developing bare-metal drivers for these peripherals, the generic user guide is the definitive source for the essential details.

Additionally, the guide provides information on the microcontroller core’s Instruction Set, as well as the Programmer’s Model, Exception Model, fault handling, and power management.

Getting the documents

To obtain the aforementioned documents, you can use the following search phrases on Google:

  • RM: Either STM32F11 Reference Manual or RM0383.
  • Datasheet: STM32F411 Datasheet.
  • UM: Nucleo-F11 User Manual or UM1724.
  • Generic user guide: Cortex-M4 Generic User Guide

Direct links to these documents are also available, in the Technical requirements section of this chapter.

Before analyzing the key areas of the various documents to program our development board, let’s first take a closer look at the STM32CubeIDE we installed earlier. We will familiarize ourselves with its features and functionalities in the next section.

You have been reading a chapter from
Bare-Metal Embedded C Programming
Published in: Sep 2024
Publisher: Packt
ISBN-13: 9781835460818
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime