Introduction to STM32F103
Microcontrollers
Masaoud Houshmand
1
STM32F103 Family
STM32F1 Series with Different Densities
Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32
Kbytes.
Medium-density devices are STM32F101xx, STM32F102xx and
STM32F103xx
microcontrollers where the Flash memory density ranges between 64 and 128
Kbytes.
High-density devices are STM32F101xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 256 and 512
Kbytes.
XL-density devices are STM32F101xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 768 Kbytes and
1 Mbyte.
----------------------------------------------------------------------------------------------
STM32F103C8T6 is in Medium-density devices
STM32F103 Manuals
Datesheet:
https://www.st.com/resource/en/datasheet/stm32f103c8.pdf
Includes electrical spec, packages & pin outs info.
Programming Manual
PM0056: STM32F10xxx/20xxx/21xxx/L1xxxx Cortex-M3 programming manual
https://www.st.com/resource/en/programming_manual/pm0056-stm32f10xxx20xxx21xxxl1xxxx-cortexm3-programming-
manual-stmicroelectronics.pdf
Includes programming model, memory, exception, fault handling, power management and core peripherals.
You can ignore the instruction set altogether as we will focus on C.
"This document provides the information required for application and system-level software development. It does not provide
information on debug components, features, or operation.
This material is for microcontroller software and hardware engineers, including those who have no experience of ARM
products."
Reference Manual
RM0008: STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and STM32F107xx advanced ARM-based
32-bit MCUs
https://www.st.com/resource/en/reference_manual/cd00171190-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-
stm32f107xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf
Contains all subsystems details.
"This reference manual targets application developers. It provides complete information on how to use the STM32F101xx,
STM32F102xx, STM32F103xx and ..."
STM32F103 Block Diagram
STM32F103 BUS Architecture
I-Bus: Used to fetch instructions
D-Bus: Used to fetch constants (data in Flash)
System Bus: Used by CPU to reach peripheral units or SRAM
AHB: ARM Advanced High Speed Busses
is clocked at the same speed as the Cortex core
APB: ARM Advanced Peripheral Busses
APB2 can run at the full 72MHz
APB1 is limited to 36MHz
Memory Map in STM32F103
8 bits
4G 0xFFFF FFFF
Cortex-M3 internal
peripherals
0xE000 0000
3G 0xC000 0000
The STM32 flexible static memory
controller (FSMC) is an embedded
external memory controller that allows FSMC
the STM32 microcontroller to interface 0x8000 0000
with external memories 2G
0x6000 0000
0x5FFF FFFF
Peripherals
1G 0x4000 0000
0x3FFF FFFF
READWRITE SRAM 0x2000 0000
0x1FFF FFFF
READONLY 0
Flash
0x0000 0000
7
Popular IC Packages
Thin Profile Fine-Pitch
Ball Grid Array
(TFBGA64)
Low-profile Quad Flat Package
(LQFP)
Wafer Level Chip Scale Package 8
MLF (MicroLeadFrame) (WLCSP)
ST32 Naming Conventions
STM32F103C8T
type series package
family Sub Pin Flash
series count size
Family
Names of the new Arm
products of ST begin with
STM32.
STM32F429AIH6 STM32F103C8T6 STM32F031K6U6
9
ST32 Naming Conventions
STM32F103C8T
type series package
family Sub Pin Flash
series count size
Type
L: Low Power
F: Mainstream (Foundation)
H: High performance
W: Wireless
STM32F429AIH6 STM32F103C8T6 STM32F031K6U6
10
ST32 Naming Conventions
STM32F103C8T
type series package
family Sub Pin Flash
series count size
Series
0: Cortex-M0
1,2: Cortex-M3
3,4: Cortex-M4
7: Cortex-M7
STM32F429AIH6 STM32F103C8T6 STM32F031K6U6
11
ST32 Naming Conventions
STM32F103C8T
type series package
family Sub Pin Flash
series count size
Sub series
Chips with higher
sub-series
numbers have
richer
configurations
STM32F429AIH6 STM32F103C8T6 STM32F031K6U6
12
ST32 Naming Conventions
STM32F103C8T
type series package
family Sub Pin Flash
series count size
Pin count
F G K T S C R V Z
Number 20 28 32 36 44 48 64 100 144
of pins
STM32F429AIH6 STM32F103C8T6 STM32F031K6U6
13
ST32 Naming Conventions
STM32F103C8T
type series package
family Sub Pin Flash
series count size
Flash size
4 6 8F GB K C T DS C
E RF VG ZH I
Group Number
Low Medium
20 28 density
32 High
36 density
44 48 64 100 144
density
of pins
Flash 16K 32K 64K 128K 256K 384K 512K 768K 1M 1.5M 2M
STM32F429AIH6 STM32F103C8T6 STM32F031K6U6
14
ST32 Naming Conventions
STM32F103C8T
type series package
family Sub Pin Flash
series count size
Package
H: BGA (Ball Grid Array)
T:LQFP (Low-profile Quad Flat Pack)
U:QFN (Quad Flat No-leads)
Y:WLCSP
STM32F429AIH6 STM32F103C8T6 STM32F031K6U6
15
STM32F103C8T6
Core : ARM Cortex-M3, 72 MHz
Memory : 20 kB RAM, 64 kB ROM
Clock & Power : 2.00 V .. 3.60 V, 72 MHz
Communication : SPI, I2C, CAN, USART, USB, Device
Timer/Counter/PWM : 4 x 16-bit Timer
Analog : 10-channel 12 bit ADC
I/O & Package : -40 °C .. 85 °C, 48-QFP
STM32F103C8 Pinout
Power supply pins
3.3V
48
VDD_3
36
VDD_2
24
VDD_1
9
VDDA
STM32
47
35
VSS_3
23
VSS_2
VSS_1
8
VSSA
17
STM32F103C8 Pinout
Power supply pins
Reset
+3.3V +3.3V +3.3V
VDD VDD VDD
10K 10K 10K
NRST NRST NRST
Reset Reset
Button Button
(a) (b) (c)
18
STM32F103C8 Pinout
Power supply pins
Reset
Oscillator pins
19
Reset, Power, and Crystals
3.3V STM32F103
48 VDD_3 20pF
36 OSC_OUT
6
Vcc VDD_2
24 VDD_1
8MHz
9
VDDA 5
OSC_IN
10K
20pF
7
NRST
20pF
OSC32_OUT
4
47
VSS_3
Reset 35
Button VSS_2 32.768KHz
23
VSS_1 3
8 OSC32_IN
VSSA
20pF
20
Power supply overview
The device requires a
2.0 V to 3.6 V
operating voltage
supply (VDD). An
embedded regulator
is used to supply the
internal 1.8 V digital
power.
The real-time clock
(RTC) and backup
registers can be
powered from the
VBAT voltage when
the main VDD supply
is powered off.
The System Clock
- High Speed Internal oscillator (HSI) 8MHz (1%
accuracy).
- High Speed External oscillator (HSE) which is
typically also 8MHz, but can 4 to 16MHz.
- Phase-Lock-Loop (PLL) output that is 2 to 16 times
of HSI/2 (if HSI used), or HSE, or HSE/2 (if HSE used).
Upon power on reset, the system clock is default
to 8MHz HSI.
Range of the Clock Frequency
Using HSI and PLL one can derive multiple of
4MHz starting from 2x4=8MHz to 16x4=64MHz
for the system clock.
Using HSE and PLL (assuming 8MHz external
clock) one can derive multiple of 8MHz or 4MHz
to obtain frequency up to 72MHz (upper limit for
the MCU).
Other Clock Circuits
The devices have two secondary clock sources:
● 40 kHz low-speed internal RC (LSI RC) that
drives the independent watchdog
● 32.768 kHz low-speed external crystal (LSE
crystal) that optionally drives the real-time clock
(RTCCLK)
Boot Mode Selection
For program download, reset with BOOT1=0 BOOT0=1
the system memory containing a bootloader is selected
(Program download is through USART1)
STM32F103C8 Pin-Out Summary
Port Pins
Two 16-bit and one 3-bit and one 2-bit ports:
PA0 to PA15 (16 pins)
PB0 to PB15 (16 pins)
PC13 to PC15 (3 pins)
PD0 to PD1 (2 pins)
Total = 37 pins
Power Pins
Ten power pins:
3 × VDD
3 × VSS
1 × VDDA – analog supply and reference voltage
1 × VSSA – analog supply and reference voltage
Total = 8 pins
Dedicated Pins
Three dedicated pins:
VBAT – backup power for RTC, external 32kHz oscillator and backup
registers.
NRST – reset pin.
BOOT0 – selects boot mode, boots from main Flash when 0. (BOOT1 = PB2)
Total = 3 pins
Development boards
There are many boards available in the market,
which are from the ST, or from a 3rd party
company, or just from a seller
STM32 Nucleo boards
Nucleo-F103RB
STM32 Blue Pill
STM32F103C8
STM32 Blue Pill - Compnents
Red LED is used for power indication
Green LED (User LED) is connected to the GPIO
pin PC13.
STM32 Blue Pill - Programming
ST-Link v2
Blue-Pill Pinout