STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and
STM32F107xx advanced ARM
Introduction
This reference manual targets application developers. It provides complete information on
how to use the STM32F101xx, STM32F102xx, STM32F103xx and
STM32F105xx/STM32F107xx microcontroller memory and peripherals. The STM32F101xx,
STM32F102xx, STM32F103xx and STM32F105xx/STM32F107xx will be referred to as
STM32F10xxx throughout the document, unless otherwise specified.
The STM32F10xxx is a family of microcontrollers with different memory sizes, packages
and peripherals.
For ordering information, mechanical and electrical device characteristics please refer to the
low-, medium-, high- and XL-density STM32F101xx and STM32F103xx datasheets, to the
low- and medium-density STM32F102xx datasheets and to the
STM32F105xx/STM32F107xx connectivity line datasheet.
For information on programming, erasing and protection of the internal Flash memory
please refer to:
•PM0075, the Flash programming manual for low-, medium- high-density and
connectivity line STM32F10xxx devices
•PM0068, the Flash programming manual for XL-density STM32F10xxx devices.
For information on the ARM
M3 programming manual (PM0056).
®
Cortex®-M3 core, please refer to the STM32F10xxx Cortex®-
®
-based 32-bit MCUs
Related documents
Available from www.st.com:
• STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx/STM32F107xx and
datasheets
Table 2. Sections related to each peripheral (continued)
USART
Backup registers (BKP)
General-purpose I/Os (GPIOs)
Digital-to-analog converter (DAC)
Analog-to-digital converter (ADC)
Advanced-control timers (TIM1&TIM8)
General-purpose timers (TIM2 to TIM5)
General-purpose timers (TIM9 to TIM14)
Real-time clock (RTC)
Basic timers (TIM6&TIM7)
Window watchdog (WWDG)
Independent watchdog (IWDG)
Flexible static memory controller (FSMC)
USB full-speed device (USB)
Controller area network (bxCAN)
Secure digital input/output interface (SDIO)
Serial peripheral interface (SPI)
Inter-integrated circuit (I2C) interface
USB on-the-go full-speed (OTG_FS)
Ethernet (ETH)
Section 28: USB onthe-go full-speed
(OTG_FS)
Section 29: Ethernet
(ETH): media access
control (MAC) with
DMA controller
Section 30: Device
electronic signature
Section 31: Debug
support (DBG)
·
·
DocID13902 Rev 1546/1128
46
Page 47
Documentation conventionsRM0008
2 Documentation conventions
2.1 List of abbreviations for registers
The following abbreviations are used in register descriptions:
read/write (rw)Software can read and write to these bits.
read-only (r)Software can only read these bits.
write-only (w)Software can only write to this bit. Reading the bit returns the reset value.
read/clear (rc_w1)Software can read as well as clear this bit by writing 1. Writing ‘0’ has no effect on
the bit value.
read/clear (rc_w0)Software can read as well as clear this bit by writing 0. Writing ‘1’ has no effect on
the bit value.
read/clear by read
(rc_r)
read/set (rs)Software can read as well as set this bit. Writing ‘0’ has no effect on the bit value.
read-only write
trigger (rt_w)
toggle (t)Software can only toggle this bit by writing ‘1’. Writing ‘0’ has no effect.
Reserved (Res.)Reserved bit, must be kept at reset value.
Software can read this bit. Reading this bit automatically clears it to ‘0’. Writing ‘0’
has no effect on the bit value.
Software can read this bit. Writing ‘0’ or ‘1’ triggers an event but has no effect on
the bit value.
2.2 Glossary
•Low-densitydevices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
•Medium-densitydevices 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.
•Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
•Word: data of 32-bit length.
•Half-word: data of 16-bit length.
•Byte: data of 8-bit length.
2.3 Peripheral availability
For peripheral availability and number across all STM32F10xxx sales types, please refer to
the low-, medium-, high- and XL-density STM32F101xx and STM32F103xx datasheets, to
the low- and medium-density STM32F102xx datasheets and to the connectivity line devices,
STM32F105xx/STM32F107xx.
47/1128DocID13902 Rev 15
Page 48
RM0008Memory and bus architecture
FLITF
Ch.1
Ch.2
Ch.7
Cor tex-M3
DMA1
ICode
DCode
System
AHB system bus
DMA Request
APB 1
Flash
Bridge 2
Bridge 1
Ch.1
Ch.2
Ch.5
DMA2
SRAM
FSMC
SDIO
APB2
DMA request
ADC3
GPIOC
USART1
TIM8
SPI1
TIM1
ADC2
ADC1
GPIOG
GPIOF
GPIOE
GPIOD
GPIOB
GPIOA
EXTI
AFIO
DAC SPI3/I2S
TIM2
PWR
BKP
bxCAN
USB
I2C2
I2C1
UART5
UART4
USART3
USART2
SPI2/I2S
IWDG
WWDG
RTC
TIM7
TIM6
TIM5
TIM4
TIM3
ai14800c
Bus matrix
DMA
DMA
Reset & clock
control (RCC)
3 Memory and bus architecture
3.1 System architecture
In low-, medium-, high- and XL-density devices, the main system consists of:
•Four masters:
–Cortex
–GP-DMA1 & 2 (general-purpose DMA)
•Four slaves:
–Internal SRAM
–Internal Flash memory
–FSMC
–AHB to APBx (APB1 or APB2), which connect all the APB peripherals
These are interconnected using a multilayer AHB bus architecture as shown in Figure 1:
®
-M3 core DCode bus (D-bus) and System bus (S-bus)
Figure 1. System architecture (low-, medium-, XL-density devices)
DocID13902 Rev 1548/1128
63
Page 49
Memory and bus architectureRM0008
FLITF
Ch.1
Ch.2
Ch.7
Cor tex-M3
DMA1
ICode
DCode
System
DMA request
APB 1
Flash
Bridge 2
Bridge 1
Ch.1
Ch.2
Ch.5
DMA2
SRAM
APB2
GPIOC
USART1
SPI1
TIM1
ADC2
ADC1
GPIOE
GPIOD
GPIOB
GPIOA
EXTI
AFIO
DAC
SPI3/I2S
TIM2
PWR
BKP
CAN1
CAN2
I2C2
I2C1
UART5
UART4
USART3
USART2
SPI2/I2S
IWDG
WWDG
RTC
TIM7
TIM6
TIM5
TIM4
TIM3
ai15810
Bus matrix
DMA
DMA
Reset & clock
control (RCC)
USB OTG FS
AHB system bus
Ethernet MAC
DMA
DMA request
In connectivity line devices the main system consists of:
•Five masters:
–Cortex
®
-M3 core DCode bus (D-bus) and System bus (S-bus)
–GP-DMA1 & 2 (general-purpose DMA)
–Ethernet DMA
•Three slaves:
–Internal SRAM
–Internal Flash memory
–AHB to APB bridges (AHB to APBx), which connect all the APB peripherals
These are interconnected using a multilayer AHB bus architecture as shown in Figure 2:
Figure 2. System architecture in connectivity line devices
ICode bus
This bus connects the Instruction bus of the Cortex®-M3 core to the Flash memory
instruction interface. Prefetching is performed on this bus.
49/1128DocID13902 Rev 15
Page 50
RM0008Memory and bus architecture
DCode bus
This bus connects the DCode bus (literal load and debug access) of the Cortex®-M3 core to
the Flash memory Data interface.
System bus
This bus connects the system bus of the Cortex®-M3 core (peripherals bus) to a BusMatrix
which manages the arbitration between the core and the DMA.
DMA bus
This bus connects the AHB master interface of the DMA to the BusMatrix which manages
the access of CPU DCode and DMA to SRAM, Flash memory and peripherals.
BusMatrix
The BusMatrix manages the access arbitration between the core system bus and the DMA
master bus. The arbitration uses a Round Robin algorithm. In connectivity line devices, the
BusMatrix is composed of five masters (CPU DCode, System bus, Ethernet DMA, DMA1
and DMA2 bus) and three slaves (FLITF, SRAM and AHB2APB bridges). In other devices,
the BusMatrix is composed of four masters (CPU DCode, System bus, DMA1 bus and
DMA2 bus) and four slaves (FLITF, SRAM, FSMC and AHB2APB bridges).
AHB peripherals are connected on system bus through a BusMatrix to allow DMA access.
AHB/APB bridges (APB)
The two AHB/APB bridges provide full synchronous connections between the AHB and the
2 APB buses. APB1 is limited to 36 MHz, APB2 operates at full speed (up to 72 MHz
depending on the device).
Refer to Table 3 on page 51 for the address mapping of the peripherals connected to each
bridge.
After each device reset, all peripheral clocks are disabled (except for the SRAM and FLITF).
Before using a peripheral you have to enable its clock in the RCC_AHBENR,
RCC_APB2ENR or RCC_APB1ENR register.
Note:When a 16- or 8-bit access is performed on an APB register, the access is transformed into
a 32-bit access: the bridge duplicates the 16- or 8-bit data to feed the 32-bit vector.
3.2 Memory organization
Program memory, data memory, registers and I/O ports are organized within the same linear
4-Gbyte address space.
The bytes are coded in memory in Little Endian format. The lowest numbered byte in a word
is considered the word’s least significant byte and the highest numbered byte the most
significant.
For the detailed mapping of peripheral registers, please refer to the related chapters.
The addressable memory space is divided into 8 main blocks, each of 512 MB.
All the memory areas that are not allocated to on-chip memories and peripherals are
considered “Reserved”). Refer to the Memory map figure in the corresponding product
datasheet.
DocID13902 Rev 1550/1128
63
Page 51
Memory and bus architectureRM0008
3.3 Memory map
See the datasheet corresponding to your device for a comprehensive diagram of the
memory map. Tab le 3 gives the boundary addresses of the peripherals available in all
STM32F10xxx devices.
0x4000 2800 - 0x4000 2BFFRTCSection 18.4.7 on page 484
0x4000 2400 - 0x4000 27FFReserved
0x4000 2000 - 0x4000 23FFTIM14 timerSection 16.5.10 on page 459
0x4000 1C00 - 0x4000 1FFFTIM13 timerSection 16.5.10 on page 459
0x4000 1800 - 0x4000 1BFFTIM12 timerSection 16.4.13 on page 449
0x4000 1400 - 0x4000 17FFTIM7 timerSection 17.4.9 on page 472
0x4000 1000 - 0x4000 13FFTIM6 timerSection 17.4.9 on page 472
0x4000 0C00 - 0x4000 0FFFTIM5 timerSection 15.4.19 on page 416
0x4000 0800 - 0x4000 0BFFTIM4 timerSection 15.4.19 on page 416
0x4000 0400 - 0x4000 07FFTIM3 timerSection 15.4.19 on page 416
0x4000 0000 - 0x4000 03FFTIM2 timerSection 15.4.19 on page 416
1. This shared SRAM can be fully accessed only in low-, medium-, high- and XL-density devices, not in connectivity line
devices.
53/1128DocID13902 Rev 15
Page 54
RM0008Memory and bus architecture
3.3.1 Embedded SRAM
The STM32F10xxx features up to 96 Kbytes of static SRAM. It can be accessed as bytes,
half-words (16 bits) or full words (32 bits). The SRAM start address is 0x2000 0000.
3.3.2 Bit banding
The Cortex®-M3 memory map includes two bit-band regions. These regions map each word
in an alias region of memory to a bit in a bit-band region of memory. Writing to a word in the
alias region has the same effect as a read-modify-write operation on the targeted bit in the
bit-band region.
In the STM32F10xxx both peripheral registers and SRAM are mapped in a bit-band region.
This allows single bit-band write and read operations to be performed. The operations are
only available for Cortex
A mapping formula shows how to reference each word in the alias region to a corresponding
bit in the bit-band region. The mapping formula is:
Note:For further information on the Flash memory interface registers, please refer to the:
“STM32F10xxx XL-density Flash programming manual” (PM0068) for XL-density devices
“STM32F10xxx Flash programming manual” (PM0075) for other devices
Reading the Flash memory
Flash memory instructions and data access are performed through the AHB bus. The
prefetch block is used for instruction fetches through the ICode bus. Arbitration is performed
in the Flash memory interface, and priority is given to data access on the DCode bus.
Read accesses can be performed with the following configuration options:
•Latency: number of wait states for a read operation programmed on-the-fly
•Prefetch buffer (2 x 64-bit blocks): it is enabled after reset; a whole block can be
replaced with a single read from the Flash memory as the size of the block matches the
bandwidth of the Flash memory. Thanks to the prefetch buffer, faster CPU execution is
possible as the CPU fetches one word at a time with the next word readily available in
the prefetch buffer
•Half cycle: for power optimization
Note:These options should be used in accordance with the Flash memory access time. The wait
states represent the ratio of the SYSCLK (system clock) period to the Flash memory access
time:
zero wait state, if 0 < SYSCLK
one wait state, if 24 MHz < SYSCLK
two wait states, if 48 MHz < SYSCLK
Half cycle configuration is not available in combination with a prescaler on the AHB. The
system clock (SYSCLK) should be equal to the HCLK clock. This feature can therefore be
≤
24 MHz
≤
≤
48 MHz
72 MHz
59/1128DocID13902 Rev 15
Page 60
RM0008Memory and bus architecture
used only with a low-frequency clock of 8 MHz or less. It can be generated from the HSI or
the HSE but not from the PLL.
The prefetch buffer must be kept on when using a prescaler different from 1 on the AHB
clock.
The prefetch buffer must be switched on/off only when SYSCLK is lower than 24 MHz and
no prescaler is applied on the AHB clock (SYSCLK must be equal to HCLK). The prefetch
buffer is usually switched on/off during the initialization routine, while the microcontroller is
running on the internal 8 MHz RC (HSI) oscillator.
Using DMA: DMA accesses Flash memory on the DCode bus and has priority over ICode
instructions. The DMA provides one free cycle after each transfer. Some instructions can be
performed together with DMA transfer.
Programming and erasing the Flash memory
The Flash memory can be programmed 16 bits (half words) at a time.
For write and erase operations on the Flash memory (write/erase), the internal RC oscillator
(HSI) must be ON.
The Flash memory erase operation can be performed at page level or on the whole Flash
area (mass-erase). The mass-erase does not affect the information blocks.
To ensure that there is no over-programming, the Flash Programming and Erase Controller
blocks are clocked by a fixed clock.
The End of write operation (programming or erasing) can trigger an interrupt. This interrupt
can be used to exit from WFI mode, only if the FLITF clock is enabled. Otherwise, the
interrupt is served only after an exit from WFI.
The FLASH_ACR register is used to enable/disable prefetch and half cycle access, and to
control the Flash memory access time according to the CPU frequency. The tables below
provide the bit map and bit descriptions for this register.
For complete information on Flash memory operations and register configurations, please
refer to the STM32F10xxx Flash programming manual (PM0075) or to the XL
STM32F10xxx Flash programming manual (PM0068).
DocID13902 Rev 1560/1128
63
Page 61
Memory and bus architectureRM0008
Flash access control register (FLASH_ACR)
Address offset: 0x00
Reset value: 0x0000 0030
31302928272625242322212019181716
Reserved
1514131211109876543210
Reserved
Bits 31:6 Reserved, must be kept at reset value.
Bit 5 PRFTBS: Prefetch buffer status
This bit provides the status of the prefetch buffer.
0: Prefetch buffer is disabled
1: Prefetch buffer is enabled
Bit 4 PRFTBE: Prefetch buffer enable
0: Prefetch is disabled
1: Prefetch is enabled
PRFTBS PRFTBE HLFCYALATENCY
rrwrwrwrwrw
Bit 3 HLFCYA: Flash half cycle access enable
0: Half cycle is disabled
1: Half cycle is enabled
Bits 2:0 LATENCY: Latency
These bits represent the ratio of the SYSCLK (system clock) period to the Flash access
time.
000 Zero wait state, if 0 < SYSCLK≤ 24 MHz
001 One wait state, if 24 MHz < SYSCLK ≤ 48 MHz
010 Two wait states, if 48 MHz < SYSCLK ≤ 72 MHz
3.4 Boot configuration
In the STM32F10xxx, 3 different boot modes can be selected through BOOT[1:0] pins as
shown in Tab le 9.
Boot mode selection pins
Boot modeAliasing
BOOT1BOOT0
x0Main Flash memoryMain Flash memory is selected as boot space
01System memorySystem memory is selected as boot space
11Embedded SRAMEmbedded SRAM is selected as boot space
Table 9. Boot modes
61/1128DocID13902 Rev 15
Page 62
RM0008Memory and bus architecture
The values on the BOOT pins are latched on the 4th rising edge of SYSCLK after a reset. It
is up to the user to set the BOOT1 and BOOT0 pins after Reset to select the required boot
mode.
The BOOT pins are also re-sampled when exiting from Standby mode. Consequently they
must be kept in the required Boot mode configuration in Standby mode. After this startup
delay has elapsed, the CPU fetches the top-of-stack value from address 0x0000 0000, then
starts code execution from the boot memory starting from 0x0000 0004.
Due to its fixed memory map, the code area starts from address 0x0000 0000 (accessed
through the ICode/DCode buses) while the data area (SRAM) starts from address
0x2000 0000 (accessed through the system bus). The Cortex
®
-M3 CPU always fetches the
reset vector on the ICode bus, which implies to have the boot space available only in the
code area (typically, Flash memory). STM32F10xxx microcontrollers implement a special
mechanism to be able to boot also from SRAM and not only from main Flash memory and
System memory.
Depending on the selected boot mode, main Flash memory, system memory or SRAM is
accessible as follows:
•Boot from main Flash memory: the main Flash memory is aliased in the boot memory
space (0x0000 0000), but still accessible from its original memory space (0x800 0000).
In other words, the Flash memory contents can be accessed starting from address
0x0000 0000 or 0x800 0000.
•Boot from system memory: the system memory is aliased in the boot memory space
(0x0000 0000), but still accessible from its original memory space (0x1FFF B000 in
connectivity line devices, 0x1FFF F000 in other devices).
•Boot from the embedded SRAM: SRAM is accessible only at address 0x2000 0000.
Note:When booting from SRAM, in the application initialization code, you have to relocate the
vector table in SRAM using the NVIC exception table and offset register.
For XL-density devices, when booting from the main Flash memory, you have an option to
boot from any of two memory banks. By default, boot from Flash memory bank 1 is selected.
You can choose to boot from Flash memory bank 2 by clearing the BFB2 bit in the user
option bytes. When this bit is cleared and the boot pins are in the boot from main Flash
memory configuration, the device boots from system memory, and the boot loader jumps to
execute the user application programmed in Flash memory bank 2. For further details,
please refer to AN2606.
Note:When booting from Bank2 in the applications initialization code, relocate the vector table to
the Bank2 base address. (0x0808 0000) using the NVIC exception table and offset register.
Embedded boot loader
The embedded boot loader is located in the System memory, programmed by ST during
production. It is used to reprogram the Flash memory with one of the available serial
interfaces:
•In low-, medium- and high-density devices the bootoader is activated through the
USART1 interface.
•In XL-density devices the boot loader is activated through the following interfaces:
USART1 or USART2 (remapped).
•In connectivity line devices the boot loader can be activated through one of the
following interfaces: USART1, USART2 (remapped), CAN2 (remapped) or USB OTG
FS in Device mode (DFU: device firmware upgrade).
DocID13902 Rev 1562/1128
63
Page 63
Memory and bus architectureRM0008
The USART peripheral operates with the internal 8 MHz oscillator (HSI). The CAN and
USB OTG FS, however, can only function if an external 8 MHz, 14.7456 MHz or
25 MHz clock (HSE) is present.
Note:For further details, please refer to AN2606.
63/1128DocID13902 Rev 15
Page 64
RM0008CRC calculation unit
4 CRC calculation unit
Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
Medium-densitydevices 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.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
4.1 CRC introduction
The CRC (cyclic redundancy check) calculation unit is used to get a CRC code from a 32-bit
data word and a fixed generator polynomial.
Among other applications, CRC-based techniques are used to verify data transmission or
storage integrity. In the scope of the EN/IEC 60335-1 standard, they offer a means of
verifying the Flash memory integrity. The CRC calculation unit helps compute a signature of
the software during runtime, to be compared with a reference signature generated at linktime and stored at a given memory location.
4.2 CRC main features
•Uses CRC-32 (Ethernet) polynomial: 0x4C11DB7
32
–X
•Single input/output 32-bit data register
•CRC computation done in 4 AHB clock cycles (HCLK)
•General-purpose 8-bit register (can be used for temporary storage)
The CRC calculation unit mainly consists of a single 32-bit data register, which:
•is used as an input register to enter new data in the CRC calculator (when writing into
the register)
•holds the result of the previous CRC calculation (when reading the register)
Each write operation into the data register creates a combination of the previous CRC value
and the new one (CRC computation is done on the whole 32-bit data word, and not byte per
byte).
The write operation is stalled until the end of the CRC computation, thus allowing back-toback write accesses or consecutive write and read accesses.
The CRC calculator can be reset to 0xFFFF FFFF with the RESET control bit in the
CRC_CR register. This operation does not affect the contents of the CRC_IDR register.
4.4 CRC registers
The CRC calculation unit contains two data registers and a control register.The peripheral
The CRC registers have to be accessed by words (32 bits).
4.4.1 Data register (CRC_DR)
Address offset: 0x00
Reset value: 0xFFFF FFFF
31302928272625242322212019181716
DR [31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
DR [15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
Bits 31:0 Data register bits
Used as an input register when writing new data into the CRC calculator.
Holds the previous CRC calculation result when it is read.
4.4.2 Independent data register (CRC_IDR)
Address offset: 0x04
Reset value: 0x0000 0000
31302928272625242322212019181716
Reserved
1514131211109876543210
Reserved
rwrwrwrwrwrwrwrw
IDR[7:0]
65/1128DocID13902 Rev 15
Page 66
RM0008CRC calculation unit
Bits 31:8 Reserved, must be kept at reset value.
Bits 7:0 General-purpose 8-bit data register bits
Can be used as a temporary storage location for one byte.
This register is not affected by CRC resets generated by the RESET bit in the CRC_CR
register.
4.4.3 Control register (CRC_CR)
Address offset: 0x08
Reset value: 0x0000 0000
31302928272625242322212019181716
Reserved
1514131211109876543210
Reserved
Bits 31:1 Reserved, must be kept at reset value.
Bit 0 RESET bit
Resets the CRC calculation unit and sets the data register to 0xFFFF FFFF.
This bit can only be set, it is automatically cleared by hardware.
RESET
w
4.4.4 CRC register map
The following table the CRC register map and reset values.
OffsetRegister31-24 23-1615-876543210
0x00
0x04
0x08
Table 10. CRC calculation unit register map and reset values
CRC_DRData register
Reset
value
CRC_IDR
Reset
value
CRC_CR
Reset
value
0xFFFF FFFF
Independent data register
Reserved
0x00
RESET
Reserved
0
DocID13902 Rev 1566/1128
66
Page 67
Power control (PWR)RM0008
5 Power control (PWR)
Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
Medium-densitydevices 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.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
This section applies to the whole STM32F101xx family, unless otherwise specified.
5.1 Power supplies
The device requires a 2.0-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 V
when the main V
supply is powered off.
DD
BAT
voltage
67/1128DocID13902 Rev 15
Page 68
RM0008Power control (PWR)
A/D converter
V
DDA
V
DD
V
SSA
V
REF+
V
BAT
V
SS
I/O Ring
(V
DD
)
(from 2.4 V up to V
DDA
)
BKP registers
Temp. sensor
Reset block
Standby circuitry
PLL
(Wakeup logic,
IWDG)
RTC
Voltage Regulator
Core
Memories
digital
peripherals
Low voltage detector
V
REF-
V
DDA
domain
V
DD
domain
1.8 V domain
Backup domain
LSE crystal 32K osc
RCC BDCR register
(V
SSA
)
(V
SS
)
D/A converter
Figure 4. Power supply overview
5.1.1 Independent A/D and D/A converter supply and reference voltage
1. V
DDA
and V
must be connected to VDD and VSS, respectively.
SSA
To improve conversion accuracy, the ADC and the DAC have an independent power supply
which can be separately filtered and shielded from noise on the PCB.
•The ADC and DAC voltage supply input is available on a separate V
•An isolated supply ground connection is provided on pin V
When available (according to package), V
On 100-pin and 144-pin packages
To ensure a better accuracy on low-voltage inputs and outputs, the user can connect a
separate external reference voltage on V
the full scale value, for an analog input (ADC) or output (DAC) signal. The voltage on V
can range from 2.4 V to V
DDA
.
must be tied to V
REF-
. V
REF+
REF+
is the highest voltage, represented by
SSA
SSA
.
.
DDA
pin.
On 64-pin packages and packages with less pins
The V
REF+
and V
voltage supply (V
pins are not available, they are internally connected to the ADC
REF-
) and ground (V
DDA
).
SSA
REF+
DocID13902 Rev 1568/1128
80
Page 69
Power control (PWR)RM0008
5.1.2 Battery backup domain
To retain the content of the Backup registers and supply the RTC function when V
turned off, V
pin can be connected to an optional standby voltage supplied by a battery
BAT
DD
is
or by another source.
The V
the RTC to operate even when the main digital supply (V
V
BAT
pin powers the RTC unit, the LSE oscillator and the PC13 to PC15 IOs, allowing
BAT
) is turned off. The switch to the
DD
supply is controlled by the Power Down Reset embedded in the Reset block.
Warning:During t
is detected, the power switch between V
connected to V
During the startup phase, if V
t
RSTTEMPO
and V
DD
through an internal diode connected between V
power switch (V
If the power supply/battery connected to the V
RSTTEMPO
(Refer to the datasheet for the value of t
> V
(temporization at VDD startup) or after a PDR
and VDD remains
.
BAT
+ 0.6 V, a current may be injected into V
BAT
).
BAT
is established in less than
DD
BAT
DD
pin cannot
BAT
RSTTEMPO
BAT
and the
)
support this current injection, it is strongly recommended to
connect an external low-drop diode between this power
supply and the V
If no external battery is used in the application, it is recommended to connect V
BAT
pin.
BAT
externally to VDD with a 100 nF external ceramic decoupling capacitor (for more details refer
to AN2586).
When the backup domain is supplied by V
(analog switch connected to VDD), the
DD
following functions are available:
•PC14 and PC15 can be used as either GPIO or LSE pins
•PC13 can be used as GPIO, TAMPER pin, RTC Calibration Clock, RTC Alarm or
second output (refer to Section 6: Backup registers (BKP) on page 81)
Note:Due to the fact that the switch only sinks a limited amount of current (3 mA), the use of
GPIOs PC13 to PC15 in output mode is restricted: the speed has to be limited to 2 MHz with
a maximum load of 30 pF and these IOs must not be used as a current source (e.g. to drive
an LED).
When the backup domain is supplied by V
V
is not present), the following functions are available:
DD
(analog switch connected to V
BAT
because
BAT
•PC14 and PC15 can be used as LSE pins only
•PC13 can be used as TAMPER pin, RTC Alarm or Second output (refer to section
Section 6.4.2: RTC clock calibration register (BKP_RTCCR) on page 83).
69/1128DocID13902 Rev 15
Page 70
RM0008Power control (PWR)
VDD/V
DDA
Reset
40 mV
hysteresis
POR
PDR
Temporization
t
RSTTEMPO
5.1.3 Voltage regulator
The voltage regulator is always enabled after Reset. It works in three different modes
depending on the application modes.
•In Run mode, the regulator supplies full power to the 1.8 V domain (core, memories
and digital peripherals).
•In Stop mode the regulator supplies low-power to the 1.8 V domain, preserving
contents of registers and SRAM
•In Standby Mode, the regulator is powered off. The contents of the registers and SRAM
are lost except for the Standby circuitry and the Backup Domain.
5.2 Power supply supervisor
5.2.1 Power on reset (POR)/power down reset (PDR)
The device has an integrated POR/PDR circuitry that allows proper operation starting
from/down to 2 V.
The device remains in Reset mode when V
V
POR/PDR
, without the need for an external reset circuit. For more details concerning the
DD/VDDA
is below a specified threshold,
power on/power down reset threshold, refer to the electrical characteristics of the datasheet.
Figure 5. Power on reset/power down reset waveform
5.2.2 Programmable voltage detector (PVD)
You can use the PVD to monitor the VDD/V
selected by the PLS[2:0] bits in the Power control register (PWR_CR).
The PVD is enabled by setting the PVDE bit.
A PVDO flag is available, in the Power control/status register (PWR_CSR), to indicate if
V
DD/VDDA
is higher or lower than the PVD threshold. This event is internally connected to
the EXTI line16 and can generate an interrupt if enabled through the EXTI registers. The
DocID13902 Rev 1570/1128
DDA
power supply by comparing it to a threshold
80
Page 71
Power control (PWR)RM0008
VDD/V
DDA
PVD output
100 mV
hysteresis
PVD threshold
PVD output interrupt can be generated when VDD/V
and/or when V
DD/VDDA
rises above the PVD threshold depending on EXTI line16
drops below the PVD threshold
DDA
rising/falling edge configuration. As an example the service routine could perform
emergency shutdown tasks.
Figure 6. PVD thresholds
71/1128DocID13902 Rev 15
Page 72
RM0008Power control (PWR)
5.3 Low-power modes
By default, the microcontroller is in Run mode after a system or a power Reset. Several lowpower modes are available to save power when the CPU does not need to be kept running,
for example when waiting for an external event. It is up to the user to select the mode that
gives the best compromise between low-power consumption, short startup time and
available wakeup sources.
The STM32F10xxx devices feature three low-power modes:
•Sleep mode (CPU clock off, all peripherals including Cortex
NVIC, SysTick, etc. are kept running)
•Stop mode (all clocks are stopped)
•Standby mode (1.8V domain powered-off)
In addition, the power consumption in Run mode can be reduce by one of the following
means:
•Slowing down the system clocks
•Gating the clocks to the APB and AHB peripherals when they are unused.
In Run mode the speed of the system clocks (SYSCLK, HCLK, PCLK1, PCLK2) can be
reduced by programming the prescaler registers. These prescalers can also be used to slow
down peripherals before entering Sleep mode.
For more details refer to Section 7.3.2: Clock configuration register (RCC_CFGR).
no effect on other
clocks or analog
clock sources
All 1.8V domain
clocks OFF
NoneON
ON or in lowpower mode
(depends on
HSI and
HSE
oscillators
OFF
Power control
register
(PWR_CR))
OFF
DocID13902 Rev 1572/1128
80
Page 73
Power control (PWR)RM0008
5.3.2 Peripheral clock gating
In Run mode, the HCLK and PCLKx for individual peripherals and memories can be stopped
at any time to reduce power consumption.
To further reduce power consumption in Sleep mode the peripheral clocks can be disabled
prior to executing the WFI or WFE instructions.
Peripheral clock gating is controlled by the AHB peripheral clock enable register
The Sleep mode is entered by executing the WFI (Wait For Interrupt) or WFE (Wait for
Event) instructions. Two options are available to select the Sleep mode entry mechanism,
depending on the SLEEPONEXIT bit in the Cortex
•Sleep-now: if the SLEEPONEXIT bit is cleared, the MCU enters Sleep mode as soon
as WFI or WFE instruction is executed.
•Sleep-on-exit: if the SLEEPONEXIT bit is set, the MCU enters Sleep mode as soon as
it exits the lowest priority ISR.
®
-M3 System Control register:
In the Sleep mode, all I/O pins keep the same state as in the Run mode.
Refer to Tab le 1 2 and Table 13 for details on how to enter Sleep mode.
Exiting Sleep mode
If the WFI instruction is used to enter Sleep mode, any peripheral interrupt acknowledged by
the nested vectored interrupt controller (NVIC) can wake up the device from Sleep mode.
If the WFE instruction is used to enter Sleep mode, the MCU exits Sleep mode as soon as
an event occurs. The wakeup event can be generated either by:
•enabling an interrupt in the peripheral control register but not in the NVIC, and enabling
the SEVONPEND bit in the Cortex
resumes from WFE, the peripheral interrupt pending bit and the peripheral NVIC IRQ
channel pending bit (in the NVIC interrupt clear pending register) have to be cleared.
•or configuring an external or internal EXTI line in event mode. When the CPU resumes
from WFE, it is not necessary to clear the peripheral interrupt pending bit or the NVIC
IRQ channel pending bit as the pending bit corresponding to the event line is not set.
This mode offers the lowest wakeup time as no time is wasted in interrupt entry/exit.
Refer to Tab le 1 2 and Table 13 for more details on how to exit Sleep mode.
®
-M3 System Control register. When the MCU
73/1128DocID13902 Rev 15
Page 74
RM0008Power control (PWR)
Sleep-now modeDescription
WFI (Wait for Interrupt) or WFE (Wait for Event) while:
Mode entry
Mode exit
Wakeup latencyNone
Sleep-on-exitDescription
Mode entry
Mode exit
Wakeup latencyNone
– SLEEPDEEP = 0 and
– SLEEPONEXIT = 0
Refer to the Cortex
If WFI was used for entry:
Interrupt: Refer to Section 10.1.2: Interrupt and exception vectors on
page 197
If WFE was used for entry
Wakeup event: Refer to Section 10.2.3: Wakeup event management
WFI (wait for interrupt) while:
– SLEEPDEEP = 0 and
– SLEEPONEXIT = 1
Refer to the Cortex
Interrupt: refer to Section 10.1.2: Interrupt and exception vectors on
page 197.
Table 12. Sleep-now
®
-M3 System Control register.
Table 13. Sleep-on-exit
®
-M3 System Control register.
5.3.4 Stop mode
The Stop mode is based on the Cortex®-M3 deepsleep mode combined with peripheral
clock gating. The voltage regulator can be configured either in normal or low-power mode.
In Stop mode, all clocks in the 1.8 V domain are stopped, the PLL, the HSI and the HSE RC
oscillators are disabled. SRAM and register contents are preserved.
In the Stop mode, all I/O pins keep the same state as in the Run mode.
Entering Stop mode
Refer to Tab le 1 4 for details on how to enter the Stop mode.
To further reduce power consumption in Stop mode, the internal voltage regulator can be put
in low-power mode. This is configured by the LPDS bit of the Power control register
(PWR_CR).
If Flash memory programming is ongoing, the Stop mode entry is delayed until the memory
access is finished.
If an access to the APB domain is ongoing, The Stop mode entry is delayed until the APB
access is finished.
In Stop mode, the following features can be selected by programming individual control bits:
•Independent watchdog (IWDG): the IWDG is started by writing to its Key register or by
hardware option. Once started it cannot be stopped except by a Reset. See
•real-time clock (RTC): this is configured by the RTCEN bit in the Backup domain
control register (RCC_BDCR)
•Internal RC oscillator (LSI RC): this is configured by the LSION bit in the Control/status
register (RCC_CSR).
•External 32.768 kHz oscillator (LSE OSC): this is configured by the LSEON bit in the
Backup domain control register (RCC_BDCR).
The ADC or DAC can also consume power during the Stop mode, unless they are disabled
before entering it. To disable them, the ADON bit in the ADC_CR2 register and the ENx bit
in the DAC_CR register must both be written to 0.
Note:If the application needs to disable the external clock before entering Stop mode, the HSEON
bit must first be disabled and the system clock switched to HSI. Otherwise, if the HSEON bit
remains enabled and the external clock (external oscillator) is removed when entering Stop
mode, the clock security system (CSS) feature must be enabled to detect any external
oscillator failure and avoid a malfunction behavior when entering stop mode.
Exiting Stop mode
Refer to Tab le 1 4 for more details on how to exit Stop mode.
When exiting Stop mode by issuing an interrupt or a wakeup event, the HSI RC oscillator is
selected as system clock.
When the voltage regulator operates in low-power mode, an additional startup delay is
incurred when waking up from Stop mode. By keeping the internal regulator ON during Stop
mode, the consumption is higher although the startup time is reduced.
Stop modeDescription
WFI (Wait for Interrupt) or WFE (Wait for Event) while:
– Set SLEEPDEEP bit in Cortex
– Clear PDDS bit in Power Control register (PWR_CR)
Mode entry
Mode exit
Wakeup latencyHSI RC wakeup time + regulator wakeup time from Low-power mode
– Select the voltage regulator mode by configuring LPDS bit in PWR_CR
Note: To enter Stop mode, all EXTI Line pending bits (in Pending register
(EXTI_PR)), all peripheral interrupt pending bits, and RTC Alarm flag must
be reset. Otherwise, the Stop mode entry procedure is ignored and
program execution continues.
If WFI was used for entry:
Any EXTI Line configured in Interrupt mode (the corresponding EXTI
Interrupt vector must be enabled in the NVIC). Refer to Section 10.1.2:
Interrupt and exception vectors on page 197.
If WFE was used for entry:
Any EXTI Line configured in event mode. Refer to Section 10.2.3:
Wakeup event management on page 206
Table 14. Stop mode
®
-M3 System Control register
75/1128DocID13902 Rev 15
Page 76
RM0008Power control (PWR)
5.3.5 Standby mode
The Standby mode allows to achieve the lowest power consumption. It is based on the
®
Cortex
consequently powered off. The PLL, the HSI oscillator and the HSE oscillator are also
switched off. SRAM and register contents are lost except for registers in the Backup domain
and Standby circuitry (see Figure 4).
Entering Standby mode
Refer to Tab le 1 5 for more details on how to enter Standby mode.
In Standby mode, the following features can be selected by programming individual control
bits:
•Independent watchdog (IWDG): the IWDG is started by writing to its Key register or by
•real-time clock (RTC): this is configured by the RTCEN bit in the Backup domain
•Internal RC oscillator (LSI RC): this is configured by the LSION bit in the Control/status
•External 32.768 kHz oscillator (LSE OSC): this is configured by the LSEON bit in the
-M3 deepsleep mode, with the voltage regulator disabled. The 1.8 V domain is
hardware option. Once started it cannot be stopped except by a reset. See
The microcontroller exits the Standby mode when an external reset (NRST pin), an IWDG
reset, a rising edge on the WKUP pin or the rising edge of an RTC alarm occurs (see
Figure 179: RTC simplified block diagram). All registers are reset after wakeup from
Standby except for Power control/status register (PWR_CSR).
After waking up from Standby mode, program execution restarts in the same way as after a
Reset (boot pins sampling, vector reset is fetched, etc.). The SBF status flag in the Power
control/status register (PWR_CSR) indicates that the MCU was in Standby mode.
Refer to Tab le 1 5 for more details on how to exit Standby mode.
Standby modeDescription
WFI (Wait for Interrupt) or WFE (Wait for Event) while:
Mode entry
Mode exit
Wakeup latencyReset phase
– Set SLEEPDEEP in Cortex
– Set PDDS bit in Power Control register (PWR_CR)
– Clear WUF bit in Power Control/Status register (PWR_CSR)
In Standby mode, all I/O pins are high impedance except:
•Reset pad (still available)
•TAMPER pin if configured for tamper or calibration out
•WKUP pin, if enabled
Debug mode
By default, the debug connection is lost if the application puts the MCU in Stop or Standby
mode while the debug features are used. This is due to the fact that the Cortex
no longer clocked.
However, by setting some configuration bits in the DBGMCU_CR register, the software can
be debugged even when using the low-power modes extensively. For more details, refer to
Section 31.16.1: Debug support for low-power modes.
5.3.6 Auto-wakeup (AWU) from low-power mode
The RTC can be used to wakeup the MCU from low-power mode without depending on an
external interrupt (Auto-wakeup mode). The RTC provides a programmable time base for
waking up from Stop or Standby mode at regular intervals. For this purpose, two of the three
alternative RTC clock sources can be selected by programming the RTCSEL[1:0] bits in the
This clock source provides a precise time base with very low-power consumption (less
than 1µA added consumption in typical conditions)
•Low-power internal RC Oscillator (LSI RC)
This clock source has the advantage of saving the cost of the 32.768 kHz crystal. This
internal RC Oscillator is designed to add minimum power consumption.
To wakeup from Stop mode with an RTC alarm event, it is necessary to:
•Configure the EXTI Line 17 to be sensitive to rising edge
•Configure the RTC to generate the RTC alarm
®
-M3 core is
To wakeup from Standby mode, there is no need to configure the EXTI Line 17.
5.4 Power control registers
The peripheral registers can be accessed by half-words (16-bit) or words (32-bit).
5.4.1 Power control register (PWR_CR)
Address offset: 0x00
Reset value: 0x0000 0000 (reset by wakeup from Standby mode)
31302928272625242322212019181716
1514131211109876543210
77/1128DocID13902 Rev 15
Reserved
Reserved
DBPPLS[2:0]PVDE CSBF CWUF PDDS LPDS
rwrwrwrwrwrc_w1rc_w1rwrw
Page 78
RM0008Power control (PWR)
Bits 31:9Reserved, must be kept at reset value..
Bit 8 DBP: Disable backup domain write protection.
In reset state, the RTC and backup registers are protected against parasitic write access.
This bit must be set to enable write access to these registers.
0: Access to RTC and Backup registers disabled
1: Access to RTC and Backup registers enabled
Note: If the HSE divided by 128 is used as the RTC clock, this bit must remain set to 1.
Bits 7:5 PLS[2:0]: PVD level selection.
These bits are written by software to select the voltage threshold detected by the Power
Voltage Detector
Note: Refer to the electrical characteristics of the datasheet for more details.
Bit 4 PVDE: Power voltage detector enable.
This bit is set and cleared by software.
0: PVD disabled
1: PVD enabled
Bit 3 CSBF: Clear standby flag.
This bit is always read as 0.
0: No effect
1: Clear the SBF Standby Flag (write).
Bit 2 CWUF: Clear wakeup flag.
This bit is always read as 0.
0: No effect
1: Clear the WUF Wakeup Flag after 2 System clock cycles. (write)
Bit 1 PDDS: Power down deepsleep.
This bit is set and cleared by software. It works together with the LPDS bit.
0: Enter Stop mode when the CPU enters Deepsleep. The regulator status depends on the
LPDS bit.
1: Enter Standby mode when the CPU enters Deepsleep.
Bit 0 LPDS: Low-power deepsleep.
This bit is set and cleared by software. It works together with the PDDS bit.
0: Voltage regulator on during Stop mode
1: Voltage regulator in low-power mode during Stop mode
DocID13902 Rev 1578/1128
80
Page 79
Power control (PWR)RM0008
5.4.2 Power control/status register (PWR_CSR)
Address offset: 0x04
Reset value: 0x0000 0000 (not reset by wakeup from Standby mode)
Additional APB cycles are needed to read this register versus a standard APB read.
31302928272625242322212019181716
1514131211109876543210
Reserved
Reserved
EWUP
rwrrr
Bits 31:9 Reserved, must be kept at reset value.
Bit 8 EWUP: Enable WKUP pin
This bit is set and cleared by software.
0: WKUP pin is used for general purpose I/O. An event on the WKUP pin does not wakeup
the device from Standby mode.
1: WKUP pin is used for wakeup from Standby mode and forced in input pull down
configuration (rising edge on WKUP pin wakes-up the system from Standby mode).
Note: This bit is reset by a system Reset.
Reserved
PVDOSBFWUF
Bits 7:3 Reserved, must be kept at reset value.
Bit 2 PVDO: PVD output
This bit is set and cleared by hardware. It is valid only if PVD is enabled by the PVDE bit.
0: V
1: V
DD/VDDA
DD/VDDA
is higher than the PVD threshold selected with the PLS[2:0] bits.
is lower than the PVD threshold selected with the PLS[2:0] bits.
Note: The PVD is stopped by Standby mode. For this reason, this bit is equal to 0 after
Standby or reset until the PVDE bit is set.
Bit 1 SBF: Standby flag
This bit is set by hardware and cleared only by a POR/PDR (power on reset/power down reset)
or by setting the CSBF bit in the Power control register (PWR_CR)
0: Device has not been in Standby mode
1: Device has been in Standby mode
Bit 0 WUF: Wakeup flag
This bit is set by hardware and cleared by hardware, by a system reset or by setting the
CWUF bit in the Power control register (PWR_CR)
0: No wakeup event occurred
1: A wakeup event was received from the WKUP pin or from the RTC alarm
Note: An additional wakeup event is detected if the WKUP pin is enabled (by setting the
EWUP bit) when the WKUP pin level is already high.
79/1128DocID13902 Rev 15
Page 80
RM0008Power control (PWR)
5.4.3 PWR register map
The following table summarizes the PWR registers.
Table 16. PWR register map and reset values
OffsetRegister
0x000
PWR_CR
Reset value000000000
0x004
PWR_CSR
Reset value00 0 0
Refer to Table 3 on page 51 for the register boundary addresses.
31302928272625242322212019181716151413
Reserved
Reserved
121110
987654321
PLS
[2:0]
DBP
Reserved
EWUP
CSBF
PVDE
CWUF
PVDO
0
LPDS
PDDS
SBF
WUF
DocID13902 Rev 1580/1128
80
Page 81
Backup registers (BKP)RM0008
6 Backup registers (BKP)
Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
Medium-densitydevices 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.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
This section applies to the whole STM32F101xx family, unless otherwise specified.
6.1 BKP introduction
The backup registers are forty two 16-bit registers for storing 84 bytes of user application
data.
They are implemented in the backup domain that remains powered on by V
V
power is switched off. They are not reset when the device wakes up from Standby
DD
mode or by a system reset or power reset.
In addition, the BKP control registers are used to manage the Tamper detection feature and
RTC calibration.
After reset, access to the Backup registers and RTC is disabled and the Backup domain
(BKP) is protected against possible parasitic write access. To enable access to the Backup
registers and the RTC, proceed as follows:
•enable the power and backup interface clocks by setting the PWREN and BKPEN bits
in the RCC_APB1ENR register
•set the DBP bit the Power Control Register (PWR_CR) to enable access to the Backup
registers and RTC.
6.2 BKP main features
•20-byte data registers (in medium-density and low-density devices) or 84-byte data
registers (in high-density, XL-density and connectivity line devices)
•Status/control register for managing tamper detection with interrupt capability
•Calibration register for storing the RTC calibration value
•Possibility to output the RTC Calibration Clock, RTC Alarm pulse or Second pulse on
TAMPER pin PC13 (when this pin is not used for tamper detection)
when the
BAT
81/1128DocID13902 Rev 15
Page 82
RM0008Backup registers (BKP)
6.3 BKP functional description
6.3.1 Tamper detection
The TAMPER pin generates a Tamper detection event when the pin changes from 0 to 1 or
from 1 to 0 depending on the TPAL bit in the Backup control register (BKP_CR). A tamper
detection event resets all data backup registers.
However to avoid losing Tamper events, the signal used for edge detection is logically
ANDed with the Tamper enable in order to detect a Tamper event in case it occurs before
the TAMPER pin is enabled.
•When TPAL=0: If the TAMPER pin is already high before it is enabled (by setting TPE
bit), an extra Tamper event is detected as soon as the TAMPER pin is enabled (while
there was no rising edge on the TAMPER pin after TPE was set)
•When TPAL=1: If the TAMPER pin is already low before it is enabled (by setting the
TPE bit), an extra Tamper event is detected as soon as the TAMPER pin is enabled
(while there was no falling edge on the TAMPER pin after TPE was set)
By setting the TPIE bit in the BKP_CSR register, an interrupt is generated when a Tamper
detection event occurs.
After a Tamper event has been detected and cleared, the TAMPER pin should be disabled
and then re-enabled with TPE before writing to the backup data registers (BKP_DRx) again.
This prevents software from writing to the backup data registers (BKP_DRx), while the
TAMPER pin value still indicates a Tamper detection. This is equivalent to a level detection
on the TAMPER pin.
Note:Tamper detection is still active when V
of the data backup registers, the TAMPER pin should be externally tied to the correct level.
6.3.2 RTC calibration
For measurement purposes, the RTC clock with a frequency divided by 64 can be output on
the TAMPER pin. This is enabled by setting the CCO bit in the RTC clock calibration register
(BKP_RTCCR).
The clock can be slowed down by up to 121 ppm by configuring CAL[6:0] bits.
For more details about RTC calibration and how to use it to improve timekeeping accuracy,
please refer to AN2604 "STM32F101xx and STM32F103xx RTC calibration”.
power is switched off. To avoid unwanted resetting
DD
DocID13902 Rev 1582/1128
89
Page 83
Backup registers (BKP)RM0008
6.4 BKP registers
Refer to Section 2.1 on page 47 for a list of abbreviations used in register descriptions.
The peripheral registers can be accessed by half-words (16-bit) or words (32-bit).
6.4.1 Backup data register x (BKP_DRx) (x = 1 ..42)
Address offset: 0x04 to 0x28, 0x40 to 0xBC
Reset value: 0x0000 0000
1514131211109876543210
D[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
Bits 15:0 D[15:0] Backup data
These bits can be written with user data.
Note: The BKP_DRx registers are not reset by a System reset or Power reset or when the
device wakes up from Standby mode.
They are reset by a Backup Domain reset or by a TAMPER pin event (if the TAMPER
pin function is activated).
6.4.2 RTC clock calibration register (BKP_RTCCR)
Address offset: 0x2C
Reset value: 0x0000 0000
1514131211109876543210
Reserved
Bits 15:10 Reserved, must be kept at reset value.
Bit 9 ASOS: Alarm or second output selection
When the ASOE bit is set, the ASOS bit can be used to select whether the signal output on
the TAMPER pin is the RTC Second pulse signal or the Alarm pulse signal:
Note: This bit is reset only by a Backup domain reset.
ASOS ASOECCOCAL[6:0]
rwrwrwrwrwrwrwrwrwrw
83/1128DocID13902 Rev 15
Page 84
RM0008Backup registers (BKP)
Bit 8 ASOE: Alarm or second output enable
Setting this bit outputs either the RTC Alarm pulse signal or the Second pulse signal on the
TAMPER pin depending on the ASOS bit.
The output pulse duration is one RTC clock period. The TAMPER pin must not be enabled
while the ASOE bit is set.
Note: This bit is reset only by a Backup domain reset.
Bit 7 CCO: Calibration clock output
0: No effect
1: Setting this bit outputs the RTC clock with a frequency divided by 64 on the TAMPER pin.
The TAMPER pin must not be enabled while the CCO bit is set in order to avoid unwanted
Tamper detection.
Note: This bit is reset when the V
supply is powered off.
DD
Bit 6:0 CAL[6:0]: Calibration value
This value indicates the number of clock pulses that will be ignored every 2^20 clock pulses.
This allows the calibration of the RTC, slowing down the clock by steps of 1000000/2^20
PPM.
The clock of the RTC can be slowed down from 0 to 121PPM.
6.4.3 Backup control register (BKP_CR)
Address offset: 0x30
Reset value: 0x0000 0000
1514131211109876543210
Reserved
TPALTPE
rwrw
Bits 15:2 Reserved, must be kept at reset value.
Bit 1 TPAL: TAMPER pin active level
0: A high level on the TAMPER pin resets all data backup registers (if TPE bit is set).
1: A low level on the TAMPER pin resets all data backup registers (if TPE bit is set).
Bit 0 TPE: TAMPER pin enable
0: The TAMPER pin is free for general purpose I/O
1: Tamper alternate I/O function is activated.
Note:Setting the TPAL and TPE bits at the same time is always safe, however resetting both at
the same time can generate a spurious Tamper event. For this reason it is recommended to
change the TPAL bit only when the TPE bit is reset.
6.4.4 Backup control/status register (BKP_CSR)
Address offset: 0x34
Reset value: 0x0000 0000
1514131211109876543210
Reserved
TIFTEF
rrrwww
Reserved
TPIECTICTE
DocID13902 Rev 1584/1128
89
Page 85
Backup registers (BKP)RM0008
Bits 15:10 Reserved, must be kept at reset value.
Bit 9 TIF: Tamper interrupt flag
This bit is set by hardware when a Tamper event is detected and the TPIE bit is set. It is
cleared by writing 1 to the CTI bit (also clears the interrupt). It is also cleared if the TPIE bit is
reset.
0: No Tamper interrupt
1: A Tamper interrupt occurred
Note: This bit is reset only by a system reset and wakeup from Standby mode.
Bit 8 TEF: Tamper event flag
This bit is set by hardware when a Tamper event is detected. It is cleared by writing 1 to the
CTE bit.
0: No Tamper event
1: A Tamper event occurred
Note: A Tamper event resets all the BKP_DRx registers. They are held in reset as long as the
TEF bit is set. If a write to the BKP_DRx registers is performed while this bit is set, the
value will not be stored.
Bits 7:3 Reserved, must be kept at reset value.
Bit 2 TPIE: TAMPER pin interrupt enable
0: Tamper interrupt disabled
1: Tamper interrupt enabled (the TPE bit must also be set in the BKP_CR register
Note: A Tamper interrupt does not wake up the core from low-power modes.
This bit is reset only by a system reset and wakeup from Standby mode.
Bit 1 CTI: Clear tamper interrupt
This bit is write only, and is always read as 0.
0: No effect
1: Clear the Tamper interrupt and the TIF Tamper interrupt flag.
Bit 0 CTE: Clear tamper event
This bit is write only, and is always read as 0.
0: No effect
1: Reset the TEF Tamper event flag (and the Tamper detector)
6.4.5 BKP register map
BKP registers are mapped as 16-bit addressable registers as described in the table below:
OffsetRegister
0x00Reserved
0x04
BKP_DR1
Reset value
85/1128DocID13902 Rev 15
Table 17. BKP register map and reset values
31302928272625242322212019181716151413
Reserved
121110
987654321
D[15:0]
0000000000000000
0
Page 86
RM0008Backup registers (BKP)
Table 17. BKP register map and reset values (continued)
OffsetRegister
0x08
0x0C
0x10
0x14
0x18
0x1C
0x20
BKP_DR2
Reset value
BKP_DR3
Reset value
BKP_DR4
Reset value
BKP_DR5
Reset value
BKP_DR6
Reset value
BKP_DR7
Reset value
BKP_DR8
Reset value
31302928272625242322212019181716151413
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
121110
987654321
D[15:0]
D[15:0]
D[15:0]
D[15:0]
D[15:0]
D[15:0]
D[15:0]
0
0x24
0x28
0x2
0x30
0x34
0x38Reserved
0x3CReserved
0x40
BKP_DR9
Reset value
BKP_DR10
Reset value
BKP_RTCCR
Reset value
BKP_CR
Reset value00
BKP_CSR
Reset value00000
BKP_DR11
Reset value
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
D[15:0]
0000000000000000
D[15:0]
0000000000000000
CAL[6:0]
ASOS
ASOE
CCO
0000000000
TPE
TPAL
TIF
D[15:0]
TEF
Reserved
TPIE
CTI
CTE
0000000000000000
DocID13902 Rev 1586/1128
89
Page 87
Backup registers (BKP)RM0008
Table 17. BKP register map and reset values (continued)
OffsetRegister
0x44
0x48
0x4C
0x50
0x54
0x58
0x5C
BKP_DR12
Reset value
BKP_DR13
Reset value
BKP_DR14
Reset value
BKP_DR15
Reset value
BKP_DR16
Reset value
BKP_DR17
Reset value
BKP_DR18
Reset value
31302928272625242322212019181716151413
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
121110
987654321
D[15:0]
D[15:0]
D[15:0]
D[15:0]
D[15:0]
D[15:0]
D[15:0]
0
0x60BKP_DR19
Reset value
0x64
0x68
0x6C
0x70
0x74
0x78
BKP_DR20
Reset value
BKP_DR21
Reset value
BKP_DR22
Reset value0000000000000000
BKP_DR23
Reset value0000000000000000
BKP_DR24
Reset value
BKP_DR25
Reset value
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
D[15:0]
0000000000000000
D[15:0]
0000000000000000
D[15:0]
0000000000000000
D[15:0]
D[15:0]
D[15:0]
0000000000000000
D[15:0]
0000000000000000
87/1128DocID13902 Rev 15
Page 88
RM0008Backup registers (BKP)
Table 17. BKP register map and reset values (continued)
OffsetRegister
0x7C
0x80
0x84
0x88BKP_DR29
0x8C
0x90
0x94
BKP_DR26
Reset value
BKP_DR27
Reset value
BKP_DR28
Reset value
Reset value
BKP_DR30
Reset value
BKP_DR31
Reset value
BKP_DR32
Reset value
31302928272625242322212019181716151413
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
121110
987654321
D[15:0]
D[15:0]
D[15:0]
D[15:0]
D[15:0]
D[15:0]
D[15:0]
0
0x98
0x9C
0xA0
0xA4
0xA8
0xAC
0xB0BKP_DR39
BKP_DR33
Reset value
BKP_DR34
Reset value
BKP_DR35
Reset value
BKP_DR36
Reset value0000000000000000
BKP_DR37
Reset value0000000000000000
BKP_DR38
Reset value
Reset value
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
D[15:0]
0000000000000000
D[15:0]
0000000000000000
D[15:0]
0000000000000000
D[15:0]
D[15:0]
D[15:0]
0000000000000000
D[15:0]
0000000000000000
DocID13902 Rev 1588/1128
89
Page 89
Backup registers (BKP)RM0008
Table 17. BKP register map and reset values (continued)
OffsetRegister
0xB4
0xB8BKP_DR41
0xBC
BKP_DR40
Reset value
Reset value
BKP_DR42
Reset value
Refer to Table 3 on page 51 for the register boundary addresses.
31302928272625242322212019181716151413
Reserved
0000000000000000
Reserved
0000000000000000
Reserved
0000000000000000
121110
987654321
D[15:0]
D[15:0]
D[15:0]
0
89/1128DocID13902 Rev 15
Page 90
RM0008Low-, medium-, high- and XL-density reset and clock control (RCC)
7 Low-, medium-, high- and XL-density reset and clock
control (RCC)
Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
Medium-densitydevices 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.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
This Section applies to low-, medium-, high- and XL-density STM32F10xxx devices.
Connectivity line devices are discussed in a separate section (refer to Connectivity line
devices: reset and clock control (RCC) on page 123).
7.1 Reset
There are three types of reset, defined as system reset, power reset and backup domain
reset.
7.1.1 System reset
A system reset sets all registers to their reset values except the reset flags in the clock
controller CSR register and the registers in the Backup domain (see Figure 4).
A system reset is generated when one of the following events occurs:
1.A low level on the NRST pin (external reset)
2. Window watchdog end of count condition (WWDG reset)
3. Independent watchdog end of count condition (IWDG reset)
4. A software reset (SW reset) (see Software reset)
5. Low-power management reset (see Low-power management reset)
The reset source can be identified by checking the reset flags in the Control/Status register,
RCC_CSR (see Section 7.3.10: Control/status register (RCC_CSR)).
Software reset
The SYSRESETREQ bit in Cortex®-M3 Application Interrupt and Reset Control Register
must be set to force a software reset on the device. Refer to the STM32F10xxx Cortex
programming manual (see Related documents on page 1) for more details.
®
-M3
DocID13902 Rev 1590/1128
122
Page 91
Low-, medium-, high- and XL-density reset and clock control (RCC)RM0008
1567
5
38
9''9
''$
::'*UHVHW
,:'*UHVHW
3XOVH
JHQHUDWRU
3RZHUUHVHW
([WHUQDO
UHVHW
PLQV
6\VWHPUHVHW
)LOWHU
6RIWZDUHUHVHW
/RZSRZHUPDQDJHPHQWUHVHW
DLF
Low-power management reset
There are two ways to generate a low-power management reset:
1.Reset generated when entering Standby mode:
This type of reset is enabled by resetting nRST_STDBY bit in User Option Bytes. In this
case, whenever a Standby mode entry sequence is successfully executed, the device
is reset instead of entering Standby mode.
2. Reset when entering Stop mode:
This type of reset is enabled by resetting nRST_STOP bit in User Option Bytes. In this
case, whenever a Stop mode entry sequence is successfully executed, the device is
reset instead of entering Stop mode.
For further information on the User Option Bytes, refer to the STM32F10xxx Flash
programming manual.
7.1.2 Power reset
A power reset is generated when one of the following events occurs:
1.Power-on/power-down reset (POR/PDR reset)
2. When exiting Standby mode
A power reset sets all registers to their reset values except the Backup domain (see
Figure 4)
These sources act on the NRST pin and it is always kept low during the delay phase. The
RESET service routine vector is fixed at address
0x0000_0004 in the memory map.
The system reset signal provided to the device is output on the NRST pin. The pulse
generator guarantees a minimum reset pulse duration of 20 µs for each reset source
(external or internal reset). In case of an external reset, the reset pulse is generated while
the NRST pin is asserted low.
Figure 7. Simplified diagram of the reset circuit
91/1128DocID13902 Rev 15
Page 92
RM0008Low-, medium-, high- and XL-density reset and clock control (RCC)
7.1.3 Backup domain reset
The backup domain has two specific resets that affect only the backup domain (see
Figure 4).
A backup domain reset is generated when one of the following events occurs:
1.Software reset, triggered by setting the BDRST bit in the Backup domain control
register (RCC_BDCR).
2. V
DD
or V
power on, if both supplies have previously been powered off.
BAT
7.2 Clocks
Three different clock sources can be used to drive the system clock (SYSCLK):
•HSI oscillator clock
•HSE oscillator clock
•PLL clock
The devices have the following two secondary clock sources:
•40 kHz low speed internal RC (LSI RC) which drives the independent watchdog and
optionally the RTC used for Auto-wakeup from Stop/Standby mode.
•32.768 kHz low speed external crystal (LSE crystal) which optionally drives the real-
time clock (RTCCLK)
Each clock source can be switched on or off independently when it is not used, to optimize
power consumption.
DocID13902 Rev 1592/1128
122
Page 93
Low-, medium-, high- and XL-density reset and clock control (RCC)RM0008
Figure 8. Clock tree
&,)4&#,+
TO&LASHPROGRAMMINGINTERFACE
53"#,+
TO53"INTERFACE
)3#,+
)3#,+
-(ZMAX
0ERIPHERAL#LOCK
%NABLE
ELSEX
-(ZMAX
0ERIPHERAL#LOCK
%NABLE
ELSEX
!$##,+-(ZMAX
0ERIPHERALCLOCK
ENABLE
TO)3
TO)3
3$)/#,+
&3-##,+
(#,+
TO!("BUSCORE
MEMORYAND$-!
TO#ORTEX3YSTEMTIMER
&#,+#ORTEX
FREERUNNINGCLOCK
0ERIPHERAL#LOCK
%NABLE
0ERIPHERAL#LOCK
%NABLE
4O3$)/!("INTERFACE
TO3$)/
TO&3-#
0#,+
TO!0"
PERIPHERALS
TO4)-
4)-8#,+
0#,+
PERIPHERALSTO!0"
TO4)-AND
4)-X#,+
TO!$#OR
(#,+
/3#?/54
/3#?).
/3#?).
/3#?/54
-(Z
(3)2#
0,,32#
-(Z
(3%/3#
,3%/3#
K(Z
,3)2#
K(Z
(3)
0,,-5,
X
XXX
0,,
0,,8402%
,3%
,3)
37
(3)
0,,#,+
(3%
#33
24##,+
24#3%,;=
TO)NDEPENDENT7ATCHDOG )7$'
393#,+
-(Z
MAX
TO24#
!("
0RESCALER
)7$'#,+
53"
0RESCALER
0ERIPHERALCLOCK
ENABLE
0ERIPHERALCLOCK
ENABLE
4)-
)F!0"PRESCALERX
-(Z
0ERIPHERALCLOCK
ENABLE
0ERIPHERALCLOCK
ENABLE
-(ZMAX
#LOCK
%NABLE
!0"
0RESCALER
!0"
0RESCALER
4)-TIMERS
)F!0"PRESCALERX
!$#
0RESCALER
-#/
-AIN
#LOCK/UTPUT
-#/
0,,#,+
(3)
(3%
393#,+
1. When the HSI is used as a PLL clock input, the maximum system clock frequency that can be achieved is
64 MHz.
2. For full details about the internal and external clock source characteristics, please refer to the “Electrical
characteristics” section in your device datasheet.
Several prescalers allow the configuration of the AHB frequency, the high speed APB
(APB2) and the low speed APB (APB1) domains. The maximum frequency of the AHB and
the APB2 domains is 72 MHz. The maximum allowed frequency of the APB1 domain is
36 MHz. The SDIO AHB interface is clocked with a fixed frequency equal to HCLK/2
The RCC feeds the Cortex
®
System Timer (SysTick) external clock with the AHB clock
(HCLK) divided by 8. The SysTick can work either with this clock or with the Cortex
(HCLK), configurable in the SysTick Control and Status Register. The ADCs are clocked by
the clock of the High Speed domain (APB2) divided by 2, 4, 6 or 8.
The Flash memory programming interface clock (FLITFCLK) is always the HSI clock.
93/1128DocID13902 Rev 15
,EGEND
(3%(IGHSPEEDEXTERNALCLOCKSIGNAL
(3) (IGHSPEEDINTERNALCLOCKSIGNAL
,3),OWSPEEDINTERNALCLOCKSIGNAL
,3%,OWSPEEDEXTERNALCLOCKSIGNAL
AIE
®
clock
Page 94
RM0008Low-, medium-, high- and XL-density reset and clock control (RCC)
OSC_OUT
External
source
(HiZ)
OSC_IN OSC_OUT
Load
capacitors
C
L2
C
L1
The timer clock frequencies are automatically fixed by hardware. There are two cases:
1.if the APB prescaler is 1, the timer clock frequencies are set to the same frequency as
that of the APB domain to which the timers are connected.
2. otherwise, they are set to twice (×2) the frequency of the APB domain to which the
timers are connected.
FCLK acts as Cortex
®
-M3’s free-running clock. For more details refer to the ARM®
Cortex™-M3 r1p1 Technical Reference Manual (TRM).
7.2.1 HSE clock
The high speed external clock signal (HSE) can be generated from two possible clock
sources:
•HSE external crystal/ceramic resonator
•HSE user external clock
The resonator and the load capacitors have to be placed as close as possible to the
oscillator pins in order to minimize output distortion and startup stabilization time. The
loading capacitance values must be adjusted according to the selected oscillator.
Clock sourceHardware configuration
Figure 9. HSE/ LSE clock sources
External clock
Crystal/Ceramic
resonators
DocID13902 Rev 1594/1128
122
Page 95
Low-, medium-, high- and XL-density reset and clock control (RCC)RM0008
External source (HSE bypass)
In this mode, an external clock source must be provided. It can have a frequency of up to
25 MHz. You select this mode by setting the HSEBYP and HSEON
register (RCC_CR). The external clock signal (square, sinus or triangle) with ~50% duty
cycle has to drive the OSC_IN pin while the OSC_OUT pin should be left hi-Z. See Figure 9.
bits in the Clock control
External crystal/ceramic resonator (HSE crystal)
The 4 to 16 MHz external oscillator has the advantage of producing a very accurate rate on
the main clock.
The associated hardware configuration is shown in Figure 9. Refer to the electrical
characteristics section of the datasheet for more details.
The HSERDY flag in the Clock control register (RCC_CR) indicates if the high-speed
external oscillator is stable or not. At startup, the clock is not released until this bit is set by
hardware. An interrupt can be generated if enabled in the Clock interrupt register
(RCC_CIR).
The HSE Crystal can be switched on and off using the HSEON bit in the Clock control
register (RCC_CR).
7.2.2 HSI clock
The HSI clock signal is generated from an internal 8 MHz RC Oscillator and can be used
directly as a system clock or divided by 2 to be used as PLL input.
The HSI RC oscillator has the advantage of providing a clock source at low cost (no external
components). It also has a faster startup time than the HSE crystal oscillator however, even
with calibration the frequency is less accurate than an external crystal oscillator or ceramic
resonator.
Calibration
RC oscillator frequencies can vary from one chip to another due to manufacturing process
variations, this is why each device is factory calibrated by ST for 1% accuracy at T
After reset, the factory calibration value is loaded in the HSICAL[7:0] bits in the Clock control
register (RCC_CR).
If the application is subject to voltage or temperature variations this may affect the RC
oscillator speed. You can trim the HSI frequency in the application using the HSITRIM[4:0]
bits in the Clock control register (RCC_CR).
The HSIRDY flag in the Clock control register (RCC_CR) indicates if the HSI RC is stable or
not. At startup, the HSI RC output clock is not released until this bit is set by hardware.
The HSI RC can be switched on and off using the HSION bit in the Clock control register
(RCC_CR).
The HSI signal can also be used as a backup source (Auxiliary clock) if the HSE crystal
oscillator fails. Refer to Section 7.2.7: Clock security system (CSS) on page 97.
=25°C.
A
95/1128DocID13902 Rev 15
Page 96
RM0008Low-, medium-, high- and XL-density reset and clock control (RCC)
7.2.3 PLL
The internal PLL can be used to multiply the HSI RC output or HSE crystal output clock
frequency. Refer to Figure 8 and Clock control register (RCC_CR).
The PLL configuration (selection of HSI oscillator divided by 2 or HSE oscillator for PLL
input clock, and multiplication factor) must be done before enabling the PLL. Once the PLL
enabled, these parameters cannot be changed.
An interrupt can be generated when the PLL is ready if enabled in the Clock interrupt
register (RCC_CIR).
If the USB interface is used in the application, the PLL must be programmed to output 48 or
72 MHz. This is needed to provide a 48 MHz USBCLK.
7.2.4 LSE clock
The LSE crystal is a 32.768 kHz Low Speed External crystal or ceramic resonator. It has the
advantage providing a low-power but highly accurate clock source to the real-time clock
peripheral (RTC) for clock/calendar or other timing functions.
The LSE crystal is switched on and off using the LSEON bit in Backup domain control
register (RCC_BDCR).
The LSERDY flag in the Backup domain control register (RCC_BDCR) indicates if the LSE
crystal is stable or not. At startup, the LSE crystal output clock signal is not released until
this bit is set by hardware. An interrupt can be generated if enabled in the Clock interrupt
register (RCC_CIR).
External source (LSE bypass)
In this mode, an external clock source must be provided. It can have a frequency of up to
1 MHz. You select this mode by setting the LSEBYP and LSEON bits in the Backup domain
control register (RCC_BDCR). The external clock signal (square, sinus or triangle) with
~50% duty cycle has to drive the OSC32_IN pin while the OSC32_OUT pin should be left
Hi-Z. See Figure 9.
7.2.5 LSI clock
The LSI RC acts as an low-power clock source that can be kept running in Stop and
Standby mode for the independent watchdog (IWDG) and Auto-wakeup unit (AWU). The
clock frequency is around 40 kHz (between 30 kHz and 60 kHz). For more details, refer to
the electrical characteristics section of the datasheets.
The LSI RC can be switched on and off using the LSION bit in the Control/status register
(RCC_CSR).
The LSIRDY flag in the Control/status register (RCC_CSR) indicates if the low-speed
internal oscillator is stable or not. At startup, the clock is not released until this bit is set by
hardware. An interrupt can be generated if enabled in the Clock interrupt register
(RCC_CIR).
Note:LSI calibration is only available on high-density, XL-density and connectivity line devices.
DocID13902 Rev 1596/1128
122
Page 97
Low-, medium-, high- and XL-density reset and clock control (RCC)RM0008
LSI calibration
The frequency dispersion of the Low Speed Internal RC (LSI) oscillator can be calibrated to
have accurate RTC time base and/or IWDG timeout (when LSI is used as clock source for
these peripherals) with an acceptable accuracy.
This calibration is performed by measuring the LSI clock frequency with respect to TIM5
input clock (TIM5CLK). According to this measurement done at the precision of the HSE
oscillator, the software can adjust the programmable 20-bit prescaler of the RTC to get an
accurate time base or can compute accurate IWDG timeout.
Use the following procedure to calibrate the LSI:
1.Enable TIM5 timer and configure channel4 in input capture mode
2. Set the TIM5CH4_IREMAP bit in the AFIO_MAPR register to connect the LSI clock
internally to TIM5 channel4 input capture for calibration purpose.
3. Measure the frequency of LSI clock using the TIM5 Capture/compare 4 event or
interrupt.
4. Use the measured LSI frequency to update the 20-bit prescaler of the RTC depending
on the desired time base and/or to compute the IWDG timeout.
7.2.6 System clock (SYSCLK) selection
After a system reset, the HSI oscillator is selected as system clock. When a clock source is
used directly or through the PLL as system clock, it is not possible to stop it.
A switch from one clock source to another occurs only if the target clock source is ready
(clock stable after startup delay or PLL locked). If a clock source which is not yet ready is
selected, the switch will occur when the clock source will be ready. Status bits in the Clock
control register (RCC_CR) indicate which clock(s) is (are) ready and which clock is currently
used as system clock.
7.2.7 Clock security system (CSS)
Clock Security System can be activated by software. In this case, the clock detector is
enabled after the HSE oscillator startup delay, and disabled when this oscillator is stopped.
If a failure is detected on the HSE clock, the HSE oscillator is automatically disabled, a clock
failure event is sent to the break input of the advanced-control timers (TIM1 and TIM8) and
an interrupt is generated to inform the software about the failure (Clock Security System
Interrupt CSSI), allowing the MCU to perform rescue operations. The CSSI is linked to the
®
Cortex
Note:Once the CSS is enabled and if the HSE clock fails, the CSS interrupt occurs and an NMI is
automatically generated. The NMI will be executed indefinitely unless the CSS interrupt
pending bit is cleared. As a consequence, in the NMI ISR user must clear the CSS interrupt
by setting the CSSC bit in the Clock interrupt register (RCC_CIR).
If the HSE oscillator is used directly or indirectly as the system clock (indirectly means: it is
used as PLL input clock, and the PLL clock is used as system clock), a detected failure
causes a switch of the system clock to the HSI oscillator and the disabling of the HSE
oscillator. If the HSE clock (divided or not) is the clock entry of the PLL used as system clock
when the failure occurs, the PLL is disabled too.
RM0008Low-, medium-, high- and XL-density reset and clock control (RCC)
7.2.8 RTC clock
The RTCCLK clock source can be either the HSE/128, LSE or LSI clocks. This is selected
by programming the RTCSEL[1:0] bits in the Backup domain control register (RCC_BDCR).
This selection cannot be modified without resetting the Backup domain.
The LSE clock is in the Backup domain, whereas the HSE and LSI clocks are not.
Consequently:
•If LSE is selected as RTC clock:
–The RTC continues to work even if the V
V
supply is maintained.
BAT
•If LSI is selected as Auto-Wakeup unit (AWU) clock:
–The AWU state is not guaranteed if the V
Section 7.2.5: LSI clock on page 96 for more details on LSI calibration.
•If the HSE clock divided by 128 is used as the RTC clock:
–The RTC state is not guaranteed if the V
voltage regulator is powered off (removing power from the 1.8 V domain).
–The DPB bit (disable backup domain write protection) in the Power controller
register must be set to 1 (refer to Section 5.4.1: Power control register
(PWR_CR)).
supply is switched off, provided the
DD
supply is powered off. Refer to
DD
supply is powered off or if the internal
DD
7.2.9 Watchdog clock
If the Independent watchdog (IWDG) is started by either hardware option or software
access, the LSI oscillator is forced ON and cannot be disabled. After the LSI oscillator
temporization, the clock is provided to the IWDG.
7.2.10 Clock-out capability
The microcontroller clock output (MCO) capability allows the clock to be output onto the
external MCO pin. The configuration registers of the corresponding GPIO port must be
programmed in alternate function mode. One of 4 clock signals can be selected as the MCO
clock.
•SYSCLK
•HSI
•HSE
•PLL clock divided by 2
The selection is controlled by the MCO[2:0] bits of the Clock configuration register
(RCC_CFGR).
DocID13902 Rev 1598/1128
122
Page 99
Low-, medium-, high- and XL-density reset and clock control (RCC)RM0008
7.3 RCC registers
Refer to Section 2.1 on page 47 for a list of abbreviations used in register descriptions.
7.3.1 Clock control register (RCC_CR)
Address offset: 0x00
Reset value: 0x0000 XX83 where X is undefined.
Access: no wait state, word, half-word and byte access
31302928272625242322212019181716
1514131211109876543210
rrrrrrr rrwrwrwrwrwrrw
PLL
PLLON
Reserved
HSICAL[7:0]HSITRIM[4:0]
RDY
rrwrwrwrrw
Bits 31:26Reserved, must be kept at reset value.
Bit 25 PLLRDY: PLL clock ready flag
Set by hardware to indicate that the PLL is locked.
0: PLL unlocked
1: PLL locked
Reserved
CSS ONHSE
BYP
Res.
HSE
RDY
HSI
RDY
HSE
ON
HSION
Bit 24 PLLON: PLL enable
Set and cleared by software to enable PLL.
Cleared by hardware when entering Stop or Standby mode. This bit can not be reset if the
PLL clock is used as system clock or is selected to become the system clock.
0: PLL OFF
1: PLL ON
Bits 23:20Reserved, must be kept at reset value.
Bit 19 CSSON: Clock security system enable
Set and cleared by software to enable the clock security system. When CSSON is set, the
clock detector is enabled by hardware when the HSE oscillator is ready, and disabled by
hardware if a HSE clock failure is detected.
0: Clock detector OFF
1: Clock detector ON (Clock detector ON if the HSE oscillator is ready , OFF if not).
Bit 18 HSEBYP: External high-speed clock bypass
Set and cleared by software to bypass the oscillator with an external clock. The external
clock must be enabled with the HSEON bit set, to be used by the device. The HSEBYP bit
can be written only if the HSE oscillator is disabled.
0: external 4-16 MHz oscillator not bypassed
1: external 4-16 MHz oscillator bypassed with external clock
Bit 17 HSERDY: External high-speed clock ready flag
Set by hardware to indicate that the HSE oscillator is stable. This bit needs 6 cycles of the
HSE oscillator clock to fall down after HSEON reset.
0: HSE oscillator not ready
1: HSE oscillator ready
99/1128DocID13902 Rev 15
Page 100
RM0008Low-, medium-, high- and XL-density reset and clock control (RCC)
Bit 16 HSEON: HSE clock enable
Set and cleared by software.
Cleared by hardware to stop the HSE oscillator when entering Stop or Standby mode. This
bit cannot be reset if the HSE oscillator is used directly or indirectly as the system clock.
0: HSE oscillator OFF
1: HSE oscillator ON
These bits provide an additional user-programmable trimming value that is added to the
HSICAL[7:0] bits. It can be programmed to adjust to variations in voltage and temperature
that influence the frequency of the internal HSI RC.
The default value is 16, which, when added to the HSICAL value, should trim the HSI to 8
MHz ± 1%. The trimming step (F
steps.
Bit 2Reserved, must be kept at reset value.
Bit 1 HSIRDY: Internal high-speed clock ready flag
Set by hardware to indicate that internal 8 MHz RC oscillator is stable. After the HSION bit is
cleared, HSIRDY goes low after 6 internal 8 MHz RC oscillator clock cycles.
Set and cleared by software.
Set by hardware to force the internal 8 MHz RC oscillator ON when leaving Stop or Standby
mode or in case of failure of the external 4-16 MHz oscillator used directly or indirectly as
system clock. This bit cannot be reset if the internal 8 MHz RC is used directly or indirectly
as system clock or is selected to become the system clock.
0: internal 8 MHz RC oscillator OFF
1: internal 8 MHz RC oscillator ON
) is around 40 kHz between two consecutive HSICAL
hsitrim
DocID13902 Rev 15100/1128
122
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.