An embedded system is not just a CPU; it is a memory-mapped architecture. Everything in the STM32F103 is accessed via memory addresses.
| Address Range | Function | Purpose |
| :--- | :--- | :--- |
| 0x0000 0000 | Code/Flash | Program code and constants. |
| 0x2000 0000 | SRAM | Stack, heap, variables. |
| 0x4000 0000 | Peripherals (APB1) | Lower-speed buses (USART2, I2C1) |
| 0x4001 0000 | Peripherals (APB2) | High-speed buses (GPIO, ADC, SPI1) |
To turn on an LED, you don't call a function like digitalWrite() (unless you use a library). You write a 32-bit value to a specific address. For example, to set PA5 high on GPIO Port A:
*(volatile uint32_t*)0x40010810 |= (1 << 5); // Set BSRR register
This direct memory access is why C (not C++ or Python) is the lingua franca of embedded systems. It gives you raw pointer control over the hardware.
An embedded system is a dedicated computer system designed to perform one or a few specific functions, often with real-time computing constraints. Unlike a general-purpose PC, it is embedded as part of a complete device (e.g., microwave, car engine control, medical pump).
So, how does the STM32F103 ARM microcontroller and embedded systems work? It works through a meticulously designed dance between deterministic hardware and efficient firmware.
The ARM Cortex-M3 core fetches and decodes Thumb-2 instructions at 72 MHz. The bus matrix (a crossbar switch) allows the CPU, DMA, and peripherals to access memory simultaneously without collisions. The nested vector interrupt controller (NVIC) prioritizes 60+ interrupt sources, ensuring your emergency stop button overrides a background data logging task. And the clock tree distributes precise timestamps to every subsystem.
Whether you are building a DIY oscilloscope, a 3D printer controller, or an industrial CAN bus sensor node, the STM32F103 offers the sweet spot: more power than an 8-bit Arduino, less complexity than a Linux SoC, and absolute control over how the embedded system works. The "Blue Pill" is not just a microcontroller; it is a gateway to understanding the invisible, intelligent machines that power the modern world.
Next Steps: Download STM32CubeIDE, buy a $2 Blue Pill board and a $6 ST-Link v2 clone, and write your first linker script. Only then will the magic truly click.
The STM32F103 is a 32-bit microcontroller family based on the ARM Cortex-M3 processor, widely recognized as a "gateway" into high-performance embedded systems. It is frequently found on the affordable "Blue Pill" development board, making it a favorite for both industrial prototypes and hobbyist learning. Key Technical Specifications
Processor Core: ARM® 32-bit Cortex®-M3 CPU running at a maximum frequency of 72 MHz.
Memory: Typically offers 64 KB to 128 KB of Flash memory and 20 KB of SRAM (variants can reach up to 512 KB Flash/64 KB RAM).
Operating Voltage: Functions within a range of 2.0V to 3.6V, making it compatible with many battery-powered applications.
I/O & Peripherals: Includes up to 80 fast I/O ports, two 12-bit ADCs, and various timers including PWM for motor control. How Embedded Systems Work with STM32F103
In an embedded system, the STM32F103 acts as the "brain," managing hardware through specific internal peripherals:
The STM32F103 Arm Microcontroller and Embedded Systems a prominent textbook by Muhammad Ali Mazidi Sarmad Naimi Sepehr Naimi . Published in
, it serves as a comprehensive guide for engineering students and hobbyists to master the ARM Cortex-M3 architecture using both C programming Amazon.com Core Book Overview
The book is structured into two main parts to build a foundation in both low-level and high-level development: Part 1 (Chapters 1–6): Focuses on Arm Assembly language
programming, covering the internal architecture and instruction set. Part 2 (Chapters 7–19): C language
to demonstrate the STM32F10x peripherals and interfacing with real-world hardware. Key Topics and Learning Objectives
The text provides step-by-step examples for controlling standard embedded components and protocols: Amazon.com Internal Peripherals:
Timers, PWM (Pulse Width Modulation), ADC (Analog-to-Digital Converters), and DMA controllers. Communication Protocols: Detailed implementation of serial communication including Hardware Interfacing:
Practical guides for connecting keypads, 7-segment displays, LCDs (character and graphic), various sensors, and motors. Blue Pill Development: The book specifically utilizes the affordable STM32F103 "Blue Pill"
board for its practical exercises, making it accessible for beginners. Amazon.com Technical Context of the STM32F103 the stm32f103 arm microcontroller and embedded systems work
The book explores the following specifications inherent to the STM32F103 series: STMicroelectronics STM32F103 - Arm Cortex-M3 Microcontrollers (MCU) 72 MHz
Title: "Design and Implementation of a Real-Time Operating System on the STM32F103 ARM Microcontroller for Embedded Systems Applications"
Abstract:
The STM32F103 ARM microcontroller is a popular choice for embedded systems applications due to its high performance, low power consumption, and rich peripherals. This paper presents the design and implementation of a real-time operating system (RTOS) on the STM32F103 microcontroller for embedded systems applications. The RTOS is designed to provide a flexible and efficient way to manage the microcontroller's resources and peripherals, and to enable the development of complex embedded systems. The paper discusses the architecture and components of the RTOS, including the kernel, device drivers, and system services. It also presents the implementation details of the RTOS on the STM32F103 microcontroller, including the configuration of the microcontroller's peripherals and the development of a set of system services. The paper also includes a case study of a real-time data acquisition system based on the STM32F103 microcontroller and the RTOS.
Introduction:
The STM32F103 ARM microcontroller is a 32-bit microcontroller based on the ARM Cortex-M3 core, which is widely used in embedded systems applications due to its high performance, low power consumption, and rich peripherals. The microcontroller features a maximum clock frequency of 72 MHz, 128 KB of flash memory, and 20 KB of SRAM. It also includes a range of peripherals, such as UART, SPI, I2C, and ADC.
Embedded systems are computer systems that are designed to perform a specific task or set of tasks, and are often used in a wide range of applications, including industrial control systems, medical devices, and consumer electronics. The development of embedded systems requires a deep understanding of the microcontroller's architecture and peripherals, as well as the operating system and software tools used to develop the system.
A real-time operating system (RTOS) is a type of operating system that is designed to manage the resources and peripherals of a microcontroller in a predictable and efficient way, and to enable the development of complex embedded systems. The RTOS provides a set of system services, such as task scheduling, memory management, and device drivers, that enable the development of real-time systems.
RTOS Architecture:
The RTOS architecture consists of several components, including the kernel, device drivers, and system services.
Implementation on STM32F103:
The RTOS is implemented on the STM32F103 microcontroller using the following steps:
Case Study:
A real-time data acquisition system is designed and implemented using the STM32F103 microcontroller and the RTOS. The system consists of a STM32F103 microcontroller, a ADC, and a UART. The system is designed to acquire data from the ADC and transmit it to a PC using the UART.
The system software consists of a set of tasks, including:
The system software is implemented using the RTOS's system services, including task management, memory management, and communication management.
Conclusion:
In this paper, we presented the design and implementation of a real-time operating system on the STM32F103 ARM microcontroller for embedded systems applications. The RTOS provides a flexible and efficient way to manage the microcontroller's resources and peripherals, and enables the development of complex embedded systems. The case study of a real-time data acquisition system demonstrates the effectiveness of the RTOS in managing the microcontroller's resources and peripherals.
References:
I hope this paper provides a good overview of the STM32F103 ARM microcontroller and embedded systems work! Let me know if you have any questions or need further clarification.
Here is code for above paper
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "stm32f10x.h"
// define the RTOS's system services
void task_scheduler(void);
void memory_management(void);
void device_drivers(void);
// define the device drivers
void uart_init(void);
void adc_init(void);
// define the application software
void app_task1(void);
void app_task2(void);
int main(void)
// configure the microcontroller's peripherals
uart_init();
adc_init();
// start the RTOS
task_scheduler();
while (1)
// run the application software
app_task1();
app_task2();
return 0;
// RTOS's system services
void task_scheduler(void)
// schedule the tasks
// ...
void memory_management(void)
// manage the memory
// ...
void device_drivers(void)
// manage the device drivers
// ...
// device drivers
void uart_init(void)
// initialize the UART
// ...
void adc_init(void)
// initialize the ADC
// ...
// application software
void app_task1(void)
// acquire data from the ADC
// ...
void app_task2(void)
// transmit data to a PC using the UART
// ...
Note that this code is a simple example and does not represent a complete RTOS implementation. A real-world RTOS implementation would require a much more complex and sophisticated design.
Here is some example code for task scheduling An embedded system is not just a CPU;
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
// define the task structure
typedef struct
void (*task)(void);
uint32_t priority;
bool is_running;
task_t;
// define the task scheduler
void task_scheduler(task_t *tasks, uint32_t num_tasks);
void task1(void)
printf("Task 1 is running\n");
void task2(void)
printf("Task 2 is running\n");
int main(void)
// create the tasks
task_t tasks[] =
task1, 1, false,
task2, 2, false
;
// start the task scheduler
task_scheduler(tasks, 2);
while (1)
// ...
return 0;
void task_scheduler(task_t *tasks, uint32_t num_tasks)
// schedule the tasks
for (uint32_t i = 0; i < num_tasks; i++)
if (tasks[i].priority == 1)
tasks[i].task();
tasks[i].is_running = true;
// ...
Note that this is a very simple example and a real-world task scheduler would require a much more complex design, including handling interrupts, managing task priorities, and ensuring that tasks do not interfere with each other.
Here are different types of schedulers
There are pros and cons to each type of scheduler
Rate Monotonic Scheduling (RMS) Pros:
Rate Monotonic Scheduling (RMS) Cons:
Earliest Deadline First (EDF) Scheduling Pros:
Earliest Deadline First (EDF) Scheduling Cons:
Fixed Priority Scheduling Pros:
Fixed Priority Scheduling Cons:
The STM32F103 series, developed by STMicroelectronics, is a cornerstone of the modern embedded systems landscape. Built on the 32-bit ARM Cortex-M3 architecture, it offers a powerful alternative to traditional 8-bit and 16-bit microcontrollers, balancing high performance with cost-efficiency. Core Architecture and Specifications
At its heart, the STM32F103 features a RISC processor capable of running at a maximum frequency of 72 MHz. Its architecture is designed for high efficiency, achieving 1.25 DMIPS/MHz, which allows it to handle complex computational tasks while maintaining low power consumption. Specification CPU Core ARM 32-bit Cortex-M3 Max Speed Flash Memory 16 KB to 1 MB (depending on variant) SRAM 20 KB to 96 KB Voltage Range 2.0 to 3.6 V Operating Temp -40°C to +105°C (extended range) How It Works in Embedded Systems STM32F103 - Arm Cortex-M3 Microcontrollers (MCU) 72 MHz
STM32F103 microcontrollers use the Cortex-M3 core, with a maximum CPU speed of 72 MHz. STMicroelectronics STM32F103C8 | Product - STMicroelectronics
The STM32F103, often called the "Blue Pill" in its popular development board form, is a 32-bit microcontroller based on the ARM Cortex-M3 core. It is a staple in the embedded world due to its balance of performance, low cost, and rich peripheral set. 🚀 The Core: ARM Cortex-M3
The heart of the STM32F103 is the Cortex-M3 processor. Unlike older 8-bit chips (like the Arduino Uno's ATmega328P), this is a 32-bit architecture, allowing it to process much larger chunks of data in a single clock cycle. Speed: Runs at up to 72 MHz.
Efficiency: Uses the Thumb-2 instruction set for better code density.
Interrupts: Features a Nested Vectored Interrupt Controller (NVIC) for lightning-fast response to hardware events. 🛠️ Key Hardware Features
The STM32F103 is designed to interact with almost any electronic component.
Memory: Typically offers 64KB to 128KB of Flash and 20KB of SRAM.
ADCs: 12-bit Analog-to-Digital Converters for precise sensor reading.
Communication: Includes hardware support for I2C, SPI, and UART. USB: Built-in USB 2.0 full-speed interface. PWM: Advanced timers for controlling motors or LEDs. 💻 How Embedded Systems Work
Embedded systems are specialized computers designed for a single dedicated function. Here is the typical workflow using an STM32: 1. Development Environment
Engineers write code (usually in C or C++) using an Integrated Development Environment (IDE) like STM32CubeIDE or Keil. 2. The Abstraction Layer
Instead of toggling individual bits in registers, developers often use: This direct memory access is why C (not
HAL (Hardware Abstraction Layer): High-level functions (e.g., HAL_GPIO_WritePin).
LL (Low Layer): Faster, closer-to-hardware code for performance-critical tasks. 3. Compilation & Flashing
The code is compiled into a binary file. This file is "flashed" onto the microcontroller via a debugger like an ST-LINK using the Serial Wire Debug (SWD) protocol. 4. The Execution Loop
Once powered, the chip executes a startup script, initializes its clocks, and enters a while(1) loop. It constantly polls sensors, processes logic, and drives actuators. 💡 Why Use It?
Industry Standard: Skills learned on STM32 translate directly to professional engineering.
Ecosystem: Massive community support and extensive documentation from STMicroelectronics.
Scalability: If you outgrow the F103, you can easily migrate to more powerful STM32 chips (like the F4 or H7 series).
✅ Pro Tip: Use STM32CubeMX to visually configure your pins and clocks; it generates the initialization code for you, saving hours of manual setup. To help you get started, A guide on how to set up the software (IDE and drivers)? A comparison between the Blue Pill and an Arduino?
is a popular 32-bit microcontroller based on the Arm Cortex-M3
processor architecture, widely regarded as a staple in the world of embedded systems
. It is celebrated for balancing performance, cost, and power efficiency, making it a "gateway" for engineers transitioning from 8-bit systems (like Arduino) to more powerful 32-bit platforms. STMicroelectronics Core Architecture & Specifications The heart of the STM32F103 is the Arm Cortex-M3 core , which operates at a maximum frequency of STMicroelectronics Processing Power
: It delivers approximately 1.25 DMIPS/MHz, featuring single-cycle multiplication and hardware division for efficient data handling.
: Typical "medium-density" variants (like the common STM32F103C8T6 on the Blue Pill board 64 KB to 128 KB of Flash 20 KB of SRAM Operating Voltage : It runs on 2.0V to 3.6V , which is ideal for battery-powered applications. STMicroelectronics Key Peripherals for Embedded Systems
A defining feature of the STM32F103 is its extensive set of integrated peripherals, which allow it to interact with the physical world without external components. Tuijin Jishu/Journal of Propulsion Technology STM32F103 - Arm Cortex-M3 Microcontrollers (MCU) 72 MHz
The book The STM32F103 Arm Microcontroller and Embedded Systems: Using Assembly and C
is a textbook by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi. Published in May 2020 by Microdigitaled, it spans 544 pages and uses the "Blue Pill" development board to teach embedded system design. Key Features & Content
Programming Focus: Teaches both Arm Assembly and C languages. Structure: Chapters 1–6: Cover Arm Assembly language programming.
Chapters 7–19: Focus on C programming for STM32F10x peripherals.
Peripherals Covered: Detailed examples for timers, serial communication, ADC, SPI, I2C, PWM, and interfacing with devices like keypads, LCDs, motors, and sensors.
Educational Support: Support materials, including source codes and power points, are available through the NicerLand website. Where to Purchase or Access Google Watch Action Data
This response uses data provided by Google's Knowledge Graph
The STM32F103 shines because its hardware peripherals operate independently of the CPU core. This is the key to efficient embedded systems work.