2. Documentation conventions

2.1 General information

The STM32F10xxx devices have an Arm ®(a) Cortex ® -M3 core.

2.2 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)Software can read this bit. Reading this bit automatically clears it to '0'. Writing '0' has no effect on the bit value.
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)Software can read this bit. Writing '0' or '1' triggers an event but has no effect on the bit value.
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.
arm logo
arm logo

a. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.

2.3 Glossary

2.4 Peripheral availability

For peripheral availability and number across all STM32F10xxx sales types, 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.

3 Memory and bus architecture

3.1 System architecture

In low-, medium-, high- and XL-density devices, the main system consists of:

These are interconnected using a multilayer AHB bus architecture as shown in Figure 1 :

Figure 1. System architecture (low-, medium-, XL-density devices)

Figure 1. System architecture (low-, medium-, XL-density devices). This block diagram illustrates the internal architecture of a microcontroller. At the top left is the Cortex-M3 core, which connects to a central 'Bus matrix'. The core has four interfaces: ICode (connected to FLITF), DCode (connected to FLITF), System (connected to SRAM), and DMA (connected to the Bus matrix). DMA1 and DMA2 are shown as DMA masters with multiple channels (Ch.1 to Ch.7 for DMA1, Ch.1 to Ch.5 for DMA2). The Bus matrix connects to several slave components: FLITF (connected to Flash), SRAM, FSMC, SDIO, and a 'Reset & clock control (RCC)' block. The Bus matrix also connects to 'Bridge 2' and 'Bridge 1', which in turn connect to 'APB2' and 'APB1' buses. The APB2 bus connects to a list of peripherals: ADC1, ADC2, ADC3, USART1, SPI1, TIM1, TIM8, GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, EXTI, AFIO. The APB1 bus connects to: DAC, PWR, BKP, bxCAN, USB, I2C1, I2C2, I2C3, UART5, USART3, USART2, SPI3/2S, SPI2/2S, IWDG, RTC, TIM7, TIM6, TIM5, TIM4, TIM3, TIM2. DMA Request lines are shown from various peripherals back to the DMA masters.
Figure 1. System architecture (low-, medium-, XL-density devices). This block diagram illustrates the internal architecture of a microcontroller. At the top left is the Cortex-M3 core, which connects to a central 'Bus matrix'. The core has four interfaces: ICode (connected to FLITF), DCode (connected to FLITF), System (connected to SRAM), and DMA (connected to the Bus matrix). DMA1 and DMA2 are shown as DMA masters with multiple channels (Ch.1 to Ch.7 for DMA1, Ch.1 to Ch.5 for DMA2). The Bus matrix connects to several slave components: FLITF (connected to Flash), SRAM, FSMC, SDIO, and a 'Reset & clock control (RCC)' block. The Bus matrix also connects to 'Bridge 2' and 'Bridge 1', which in turn connect to 'APB2' and 'APB1' buses. The APB2 bus connects to a list of peripherals: ADC1, ADC2, ADC3, USART1, SPI1, TIM1, TIM8, GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, EXTI, AFIO. The APB1 bus connects to: DAC, PWR, BKP, bxCAN, USB, I2C1, I2C2, I2C3, UART5, USART3, USART2, SPI3/2S, SPI2/2S, IWDG, RTC, TIM7, TIM6, TIM5, TIM4, TIM3, TIM2. DMA Request lines are shown from various peripherals back to the DMA masters.

In connectivity line devices the main system consists of:

These are interconnected using a multilayer AHB bus architecture as shown in Figure 2 :

Figure 2. System architecture in connectivity line devices

Figure 2. System architecture in connectivity line devices. This block diagram illustrates the internal architecture of a microcontroller. At the top left is the Cortex-M3 core, which is connected to a central 'Bus matrix'. The core has three interfaces to the matrix: ICode (Instruction Code), DCode (Data Code), and System. The ICode interface connects to an FLITF (Flash Interface) block, which in turn connects to external Flash memory. The DCode and System interfaces connect to the Bus matrix. The Bus matrix is connected to an 'AHB system bus'. On the AHB system bus, there are several components: SRAM, Reset & clock control (RCC), Bridge 2, Bridge 1, DMA1, DMA2, Ethernet MAC, and USB OTG FS. DMA1 and DMA2 are shown with multiple channels (Ch.1 to Ch.7 for DMA1, Ch.1 to Ch.5 for DMA2). The Ethernet MAC and USB OTG FS are also connected to the AHB system bus. The AHB system bus connects to Bridge 1 and Bridge 2. Bridge 1 connects to the APB2 bus, which is connected to a list of peripherals: ADC1, ADC2, USART1, SPI1, TIM1, GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, EXTI, AFIO. Bridge 2 connects to the APB1 bus, which is connected to a list of peripherals: DAC, PWR, BKP, CAN1, CAN2, I2C2, I2C1, UART5, UART4, USART3, USART2, SPI3/I2S, SPI2/I2S, IWDG, WWDG, RTC, TIM7, TIM6, TIM5, TIM4, TIM3, TIM2. DMA request lines are shown from the DMA blocks and the APB1/APB2 bridges to the Cortex-M3 core.
Figure 2. System architecture in connectivity line devices. This block diagram illustrates the internal architecture of a microcontroller. At the top left is the Cortex-M3 core, which is connected to a central 'Bus matrix'. The core has three interfaces to the matrix: ICode (Instruction Code), DCode (Data Code), and System. The ICode interface connects to an FLITF (Flash Interface) block, which in turn connects to external Flash memory. The DCode and System interfaces connect to the Bus matrix. The Bus matrix is connected to an 'AHB system bus'. On the AHB system bus, there are several components: SRAM, Reset & clock control (RCC), Bridge 2, Bridge 1, DMA1, DMA2, Ethernet MAC, and USB OTG FS. DMA1 and DMA2 are shown with multiple channels (Ch.1 to Ch.7 for DMA1, Ch.1 to Ch.5 for DMA2). The Ethernet MAC and USB OTG FS are also connected to the AHB system bus. The AHB system bus connects to Bridge 1 and Bridge 2. Bridge 1 connects to the APB2 bus, which is connected to a list of peripherals: ADC1, ADC2, USART1, SPI1, TIM1, GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, EXTI, AFIO. Bridge 2 connects to the APB1 bus, which is connected to a list of peripherals: DAC, PWR, BKP, CAN1, CAN2, I2C2, I2C1, UART5, UART4, USART3, USART2, SPI3/I2S, SPI2/I2S, IWDG, WWDG, RTC, TIM7, TIM6, TIM5, TIM4, TIM3, TIM2. DMA request lines are shown from the DMA blocks and the APB1/APB2 bridges to the Cortex-M3 core.

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.

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 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 refer to the related sections.

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.

3.3 Memory map

See the datasheet corresponding to your device for a comprehensive diagram of the memory map. Table 3 gives the boundary addresses of the peripherals available in all STM32F10xxx devices.

Table 3. Register boundary addresses

Boundary addressPeripheralBusRegister map
0xA000 0000 - 0xA000 0FFFFSMCAHBSection 21.6.9 on page 564
0x5000 0000 - 0x5003 FFFFUSB OTG FSSection 28.16.6 on page 913
0x4003 0000 - 0x4FFF FFFFReserved-
0x4002 8000 - 0x4002 9FFFEthernetSection 29.8.5 on page 1071
0x4002 3400 - 0x4002 7FFFReserved-
0x4002 3000 - 0x4002 33FFCRCSection 4.4.4 on page 65
0x4002 2000 - 0x4002 23FFFlash memory interface-
0x4002 1400 - 0x4002 1FFFReserved-
0x4002 1000 - 0x4002 13FFReset and clock control RCCSection 7.3.11 on page 121
0x4002 0800 - 0x4002 0FFFReserved-
0x4002 0400 - 0x4002 07FFDMA2Section 13.4.7 on page 289
0x4002 0000 - 0x4002 03FFDMA1
0x4001 8400 - 0x4001 FFFFReserved-
0x4001 8000 - 0x4001 83FFSDIOSection 22.9.16 on page 621

Table 3. Register boundary addresses (continued)

Boundary addressPeripheralBusRegister map
0x4001 5800 - 0x4001 7FFFReservedAPB2-
0x4001 5400 - 0x4001 57FFTIM11 timerSection 16.5.11 on page 468
0x4001 5000 - 0x4001 53FFTIM10 timerSection 16.5.11 on page 468
0x4001 4C00 - 0x4001 4FFFTIM9 timerSection 16.4.13 on page 458
0x4001 4000 - 0x4001 4BFFReserved-
0x4001 3C00 - 0x4001 3FFFADC3Section 11.12.15 on page 252
0x4001 3800 - 0x4001 3BFFUSART1Section 27.6.8 on page 827
0x4001 3400 - 0x4001 37FFTIM8 timerSection 14.4.21 on page 363
0x4001 3000 - 0x4001 33FFSPI1Section 25.5 on page 742
0x4001 2C00 - 0x4001 2FFFTIM1 timerSection 14.4.21 on page 363
0x4001 2800 - 0x4001 2BFFADC2Section 11.12.15 on page 252
0x4001 2400 - 0x4001 27FFADC1
0x4001 2000 - 0x4001 23FFGPIO Port GSection 9.5 on page 194
0x4001 1C00 - 0x4001 1FFFGPIO Port F
0x4001 1800 - 0x4001 1BFFGPIO Port E
0x4001 1400 - 0x4001 17FFGPIO Port D
0x4001 1000 - 0x4001 13FFGPIO Port C
0x4001 0C00 - 0x4001 0FFFGPIO Port B
0x4001 0800 - 0x4001 0BFFGPIO Port A
0x4001 0400 - 0x4001 07FFEXTISection 10.3.7 on page 214
0x4001 0000 - 0x4001 03FFAFIOSection 9.5 on page 194

Table 3. Register boundary addresses (continued)

Boundary addressPeripheralBusRegister map
0x4000 7800 - 0x4000 FFFFReserved-
0x4000 7400 - 0x4000 77FFDACSection 12.5.14 on page 273
0x4000 7000 - 0x4000 73FFPower control PWRSection 5.4.3 on page 80
0x4000 6C00 - 0x4000 6FFFBackup registers (BKP)Section 6.4.5 on page 85
0x4000 6400 - 0x4000 67FFbxCAN1Section 24.9.5 on page 695
0x4000 6800 - 0x4000 6BFFbxCAN2
0x4000 6000 (1) - 0x4000 63FFShared USB/CAN SRAM 512 bytes-
0x4000 5C00 - 0x4000 5FFFUSB device FS registersSection 23.5.4 on page 651
0x4000 5800 - 0x4000 5BFFI2C2Section 26.6.10 on page 784
0x4000 5400 - 0x4000 57FFI2C1
0x4000 5000 - 0x4000 53FFUART5Section 27.6.8 on page 827
0x4000 4C00 - 0x4000 4FFFUART4
0x4000 4800 - 0x4000 4BFFUSART3
0x4000 4400 - 0x4000 47FFUSART2
0x4000 4000 - 0x4000 43FFReserved-
0x4000 3C00 - 0x4000 3FFFSPI3/I2SAPB1Section 25.5 on page 742
0x4000 3800 - 0x4000 3BFFSPI2/I2SSection 25.5 on page 742
0x4000 3400 - 0x4000 37FFReserved-
0x4000 3000 - 0x4000 33FFIndependent watchdog (IWDG)Section 19.4.5 on page 499
0x4000 2C00 - 0x4000 2FFFWindow watchdog (WWDG)Section 20.6.4 on page 506
0x4000 2800 - 0x4000 2BFFRTCSection 18.4.7 on page 493
0x4000 2400 - 0x4000 27FFReserved-
0x4000 2000 - 0x4000 23FFTIM14 timerSection 16.5.11 on page 468
0x4000 1C00 - 0x4000 1FFFTIM13 timer
0x4000 1800 - 0x4000 1BFFTIM12 timerSection 16.4.13 on page 458
0x4000 1400 - 0x4000 17FFTIM7 timerSection 17.4.9 on page 481
0x4000 1000 - 0x4000 13FFTIM6 timer
0x4000 0C00 - 0x4000 0FFFTIM5 timerSection 15.4.19 on page 423
0x4000 0800 - 0x4000 0BFFTIM4 timer
0x4000 0400 - 0x4000 07FFTIM3 timer
0x4000 0000 - 0x4000 03FFTIM2 timer

1. This shared SRAM can be fully accessed only in low-, medium-, high- and XL-density devices, not in connectivity line devices.

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 ® -M3 accesses, not from other bus masters (e.g. DMA).

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:

\[ bit\_word\_addr = bit\_band\_base + (byte\_offset \times 32) + (bit\_number \times 4) \]

where:

bit_word_addr is the address of the word in the alias memory region that maps to the targeted bit.

bit_band_base is the starting address of the alias region

byte_offset is the number of the byte in the bit-band region that contains the targeted bit

bit_number is the bit position (0-7) of the targeted bit.

Example:

The following example shows how to map bit 2 of the byte located at SRAM address 0x20000300 in the alias region:

\[ 0x22006008 = 0x22000000 + (0x300*32) + (2*4). \]

Writing to address 0x22006008 has the same effect as a read-modify-write operation on bit 2 of the byte at SRAM address 0x20000300.

Reading address 0x22006008 returns the value (0x01 or 0x00) of bit 2 of the byte at SRAM address 0x20000300 (0x01: bit set; 0x00: bit reset).

For more information on Bit-Banding refer to the Cortex ® -M3 Technical Reference Manual .

3.3.3 Embedded Flash memory

The high-performance Flash memory module has the following key features:

The Flash memory interface (FLITF) features:

Table 4. Flash module organization (low-density devices)

BlockNameBase addressesSize (bytes)
Main memoryPage 00x0800 0000 - 0x0800 03FF1 K
Page 10x0800 0400 - 0x0800 07FF1 K
Page 20x0800 0800 - 0x0800 0BFF1 K
Page 30x0800 0C00 - 0x0800 0FFF1 K
Page 40x0800 1000 - 0x0800 13FF1 K
Page 310x0800 7C00 - 0x0800 7FFF1 K
Table 4. Flash module organization (low-density devices) (continued)
BlockNameBase addressesSize (bytes)
Information blockSystem memory0x1FFF F000 - 0x1FFF F7FF2 K
Option bytes0x1FFF F800 - 0x1FFF F80F16
Flash memory interface registersFLASH_ACR0x4002 2000 - 0x4002 20034
FLASH_KEYR0x4002 2004 - 0x4002 20074
FLASH_OPTKEYR0x4002 2008 - 0x4002 200B4
FLASH_SR0x4002 200C - 0x4002 200F4
FLASH_CR0x4002 2010 - 0x4002 20134
FLASH_AR0x4002 2014 - 0x4002 20174
Reserved0x4002 2018 - 0x4002 201B4
FLASH_OBR0x4002 201C - 0x4002 201F4
FLASH_WRPR0x4002 2020 - 0x4002 20234
Table 5. Flash module organization (medium-density devices)
BlockNameBase addressesSize (bytes)
Main memoryPage 00x0800 0000 - 0x0800 03FF1 K
Page 10x0800 0400 - 0x0800 07FF1 K
Page 20x0800 0800 - 0x0800 0BFF1 K
Page 30x0800 0C00 - 0x0800 0FFF1 K
Page 40x0800 1000 - 0x0800 13FF1 K
...
...
Page 1270x0801 FC00 - 0x0801 FFFF1 K
Information blockSystem memory0x1FFF F000 - 0x1FFF F7FF2 K
Option bytes0x1FFF F800 - 0x1FFF F80F16
Flash memory interface registersFLASH_ACR0x4002 2000 - 0x4002 20034
FLASH_KEYR0x4002 2004 - 0x4002 20074
FLASH_OPTKEYR0x4002 2008 - 0x4002 200B4
FLASH_SR0x4002 200C - 0x4002 200F4
FLASH_CR0x4002 2010 - 0x4002 20134
FLASH_AR0x4002 2014 - 0x4002 20174
Reserved0x4002 2018 - 0x4002 201B4
FLASH_OBR0x4002 201C - 0x4002 201F4
FLASH_WRPR0x4002 2020 - 0x4002 20234

Table 6. Flash module organization (high-density devices)

BlockNameBase addressesSize (bytes)
Main memoryPage 00x0800 0000 - 0x0800 07FF2 K
Page 10x0800 0800 - 0x0800 0FFF2 K
Page 20x0800 1000 - 0x0800 17FF2 K
Page 30x0800 1800 - 0x0800 1FFF2 K
...
Page 2550x0807 F800 - 0x0807 FFFF2 K
Information blockSystem memory0x1FFF F000 - 0x1FFF F7FF2 K
Option bytes0x1FFF F800 - 0x1FFF F80F16
Flash memory interface registersFLASH_ACR0x4002 2000 - 0x4002 20034
FLASH_KEYR0x4002 2004 - 0x4002 20074
FLASH_OPTKEYR0x4002 2008 - 0x4002 200B4
FLASH_SR0x4002 200C - 0x4002 200F4
FLASH_CR0x4002 2010 - 0x4002 20134
FLASH_AR0x4002 2014 - 0x4002 20174
Reserved0x4002 2018 - 0x4002 201B4
FLASH_OBR0x4002 201C - 0x4002 201F4
FLASH_WRPR0x4002 2020 - 0x4002 20234

Table 7. Flash module organization (connectivity line devices)

BlockNameBase addressesSize (bytes)
Main memoryPage 00x0800 0000 - 0x0800 07FF2 K
Page 10x0800 0800 - 0x0800 0FFF2 K
Page 20x0800 1000 - 0x0800 17FF2 K
Page 30x0800 1800 - 0x0800 1FFF2 K
...
Page 1270x0803 F800 - 0x0803 FFFF2 K
Information blockSystem memory0x1FFF B000 - 0x1FFF F7FF18 K
Option bytes0x1FFF F800 - 0x1FFF F80F16

Table 7. Flash module organization (connectivity line devices) (continued)

BlockNameBase addressesSize (bytes)
Flash memory interface registersFLASH_ACR0x4002 2000 - 0x4002 20034
FLASH_KEYR0x4002 2004 - 0x4002 20074
FLASH_OPTKEYR0x4002 2008 - 0x4002 200B4
FLASH_SR0x4002 200C - 0x4002 200F4
FLASH_CR0x4002 2010 - 0x4002 20134
FLASH_AR0x4002 2014 - 0x4002 20174
Reserved0x4002 2018 - 0x4002 201B4
FLASH_OBR0x4002 201C - 0x4002 201F4
FLASH_WRPR0x4002 2020 - 0x4002 20234

Table 8. XL-density Flash module organization

BlockNameBase addressesSize (bytes)
Main memoryBank 1Page 00x0800 0000 - 0x0800 07FF2 K
Page 10x0800 0800 - 0x0800 0FFF2 K
.........
Page 2550x0807 F800 - 0x0807 FFFF2 K
Bank 2Page 2560x0808 0000 - 0x0808 07FF2 K
Page 2570x0808 0800 - 0x0808 0FFF2 K
...
...
...
Page 5110x080F F800 - 0x080F FFFF2 K
Information blockSystem memory0x1FFF E000 - 0x1FFF F7FF6 K
Option bytes0x1FFF F800 - 0x1FFF F80F16

Table 8. XL-density Flash module organization (continued)

BlockNameBase addressesSize (bytes)
Flash memory interface registersFLASH_ACR0x4002 2000 - 0x4002 20034
FLASH_KEYR0x4002 2004 - 0x4002 20074
FLASH_OPTKEYR0x4002 2008 - 0x4002 200B4
FLASH_SR0x4002 200C - 0x4002 200F4
FLASH_CR0x4002 2010 - 0x4002 20134
FLASH_AR0x4002 2014 - 0x4002 20174
Reserved0x4002 2018 - 0x4002 201B4
FLASH_OBR0x4002 201C - 0x4002 201F4
FLASH_WRPR0x4002 2020 - 0x4002 20234
Reserved0x4002 2024 - 0x4002 204332
FLASH_KEYR20x4002 2044 - 0x4002 20474
Reserved0x4002 2048 - 0x4002 204B4
FLASH_SR20x4002 204C - 0x4002 204F4
FLASH_CR20x4002 2050 - 0x4002 20534
FLASH_AR20x4002 2054 - 0x4002 20574

Note: For further information on the Flash memory interface registers, 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:

Note: These options have to 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:

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

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, refer to the STM32F10xxx Flash programming manual (PM0075) or to the XL STM32F10xxx Flash programming manual (PM0068).

Flash access control register (FLASH_ACR)

Address offset: 0x00

Reset value: 0x0000 0030

31302928272625242322212019181716
Reserved
1514131211109876543210
ReservedPRFTBSPRFTBEHLFCYALATENCY
rrwrwrwrwrw

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

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 < \text{SYSCLK} \leq 24 \text{ MHz} \)
001 One wait state, if \( 24 \text{ MHz} < \text{SYSCLK} \leq 48 \text{ MHz} \)
010 Two wait states, if \( 48 \text{ MHz} < \text{SYSCLK} \leq 72 \text{ MHz} \)

3.4 Boot configuration

In the STM32F10xxx, 3 different boot modes can be selected through BOOT[1:0] pins as shown in Table 9 .

Table 9. Boot modes

Boot mode selection pinsBoot 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

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:

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 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:

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 refer to AN2606.