The Stm32f103 Arm Microcontroller And Embedded Systems Work

If you have used Mazidi’s famous books on the 8051 or x86 processors, you know exactly what to expect. The pedagogical philosophy here is "Ground Up."

PWM example (TIM2, Channel 1 on PA0):

// Configure TIM2 for PWM, 1 kHz, 50% duty
TIM2->PSC = 7200 - 1;   // 72 MHz / 7200 = 10 kHz counter clock
TIM2->ARR = 100 - 1;    // 10 kHz / 100 = 100 Hz
TIM2->CCR1 = 50;        // 50% duty
TIM2->CCMR1 |= (6 << 4); // PWM mode 1
TIM2->CCER |= (1 << 0);  // Enable channel 1 output
TIM2->CR1 |= (1 << 0);   // Start timer

Despite its strengths, the STM32F103 has limitations: the stm32f103 arm microcontroller and embedded systems work

For such tasks, newer STM32F4 series (Cortex-M4 with FPU) or STM32H7 series are more appropriate.

![STM32F103 Block Diagram - In text: Core, Memory, Bus Matrix, Peripherals] If you have used Mazidi’s famous books on


Given newer, faster, cheaper chips exist (e.g., ESP32, RP2040), why does the STM32F103 remain the educational and industrial standard?

To make the STM32F103 work, engineers write firmware. This process fundamentally involves manipulating Memory-Mapped Registers. Despite its strengths, the STM32F103 has limitations:

Every peripheral (like a GPIO port or a Timer) is controlled by a set of registers—specific memory addresses that control the hardware behavior.

The advanced-control timer (TIM1) and general-purpose timers (TIM2-TIM4) are autonomous counters. Instead of a delay() loop, you use a timer:

The classic "Hello World" of embedded systems. The CPU writes a byte to the USART data register (DR). The hardware peripheral: