2. System and memory overview

2.1 System architecture

The main system consists of:

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

Figure 1. System architecture

Figure 1. System architecture block diagram

The diagram shows the system architecture centered around a Bus matrix .
Masters:
- Arm ® Cortex ® -M0 core connected via System bus .
- DMA1 channels 1 to 7 and DMA2 channels 1 to 5 connected via DMA bus lines.
Slaves and Peripherals:
- FLITF Flash interface connected to Flash memory .
- SRAM .
- AHB2 bus connected to GPIO ports A,B,C,D,E,F .
- AHB1 bus connected to AHB to APB bridge , Reset and clock controller (RCC) , Touch sensing controller (TSC) , and CRC .
- The AHB to APB bridge leads to the APB bus , which connects to a peripheral block containing: SYSCFG, ADC, DAC, COMP, TIM1, TIM2, TIM3, TIM6, TIM7, TIM14 to TIM17, IWDG, WWDG, RTC, CAN, CRS, PWR, I2C1, I2C2, USART1 to USART8, SPI1/I2S1, SPI2/I2S2, TSC, HDMI-CEC, and DBGMCU.
- DMA requests are shown feeding back from the APB peripherals to the DMA controllers.

Figure 1. System architecture block diagram

System bus

This bus connects the system bus of the Cortex ® -M0 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 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. The BusMatrix is composed of up to three masters (CPU, DMA1, DMA2) and four slaves (FLITF, SRAM, AHB1 with AHB to APB bridge and AHB2).

AHB peripherals are connected on system bus through a BusMatrix to allow DMA access.

AHB to APB bridge (APB)

The AHB to APB bridge provides full synchronous connections between the AHB and the APB bus.

Refer to Section 2.2.2: Memory map and register boundary addresses for the address mapping of the peripherals connected to this bridge.

After each device reset, all peripheral clocks are disabled (except for the SRAM and flash). 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.

2.2 Memory organization

2.2.1 Introduction

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.

The addressable memory space is divided into eight main blocks, of 512 Mbytes each.

2.2.2 Memory map and register boundary addresses

Figure 2. Memory map

Figure 2. Memory map showing the memory layout of the STM32F0xx microcontroller. The diagram illustrates the mapping of memory blocks from 0x0000 0000 to 0xFFFFFFFF. Key components include CODE, SRAM, Peripherals, Cortex-M0 peripherals, Option bytes, System memory, Main Flash memory, and various bus interfaces (AHB1, AHB2, APB). A legend indicates that unallocated areas are 'Reserved'.

The memory map shows the following components and their addresses:

Figure 2. Memory map showing the memory layout of the STM32F0xx microcontroller. The diagram illustrates the mapping of memory blocks from 0x0000 0000 to 0xFFFFFFFF. Key components include CODE, SRAM, Peripherals, Cortex-M0 peripherals, Option bytes, System memory, Main Flash memory, and various bus interfaces (AHB1, AHB2, APB). A legend indicates that unallocated areas are 'Reserved'.

All the memory map areas not allocated to on-chip memories and peripherals are considered “Reserved”. For the detailed mapping of available memory and register areas, refer to the following table, which gives the boundary addresses of the available peripherals.

Table 1. STM32F0xx peripheral register boundary addresses

BusBoundary addressSizePeripheralPeripheral register map
-0xE000 0000 - 0xE00F FFFF1MBCortex ® -M0 internal peripherals-
-0x4800 1800 - 0x5FFF FFFF~384 MBReserved-
Table 1. STM32F0xx peripheral register boundary addresses (continued)
BusBoundary addressSizePeripheralPeripheral register map
AHB20x4800 1400 - 0x4800 17FF1KBGPIOFSection 8.4.12 on page 164
0x4800 1000 - 0x4800 13FF1KBGPIOESection 8.4.12 on page 164
0x4800 0C00 - 0x4800 0FFF1KBGPIO DSection 8.4.12 on page 164
0x4800 0800 - 0x4800 0BFF1KBGPIOCSection 8.4.12 on page 164
0x4800 0400 - 0x4800 07FF1KBGPIOBSection 8.4.12 on page 164
0x4800 0000 - 0x4800 03FF1KBGPIOASection 8.4.12 on page 164
-0x4002 4400 - 0x47FF FFFF~128 MBReserved-
AHB10x4002 4000 - 0x4002 43FF1 KBTSCSection 16.6.11 on page 326
0x4002 3400 - 0x4002 3FFF3 KBReserved-
0x4002 3000 - 0x4002 33FF1 KBCRCSection 12.5.6 on page 232
0x4002 2400 - 0x4002 2FFF3 KBReserved-
0x4002 2000 - 0x4002 23FF1 KBFLASH interfaceSection 3.5.9 on page 75
0x4002 1400 - 0x4002 1FFF3 KBReserved-
0x4002 1000 - 0x4002 13FF1 KBRCCSection 6.4.15 on page 136
0x4002 0800 - 0x4002 0FFF2 KBReserved-
0x4002 0400 - 0x4002 07FF1 KBDMA2Section 10.6.8 on page 212
0x4002 0000 - 0x4002 03FF1 KBDMASection 10.6.8 on page 212
-0x4001 8000 - 0x4001 FFFF32 KBReserved-

Table 1. STM32F0xx peripheral register boundary addresses (continued)

BusBoundary addressSizePeripheralPeripheral register map
APB0x4001 5C00 - 0x4001 7FFF9 KBReserved-
0x4001 5800 - 0x4001 5BFF1 KBDBGMCUSection 32.9.6 on page 934
0x4001 4C00 - 0x4001 57FF3 KBReserved-
0x4001 4800 - 0x4001 4BFF1 KBTIM17Section 20.6.17 on page 558
0x4001 4400 - 0x4001 47FF1 KBTIM16Section 20.6.17 on page 558
0x4001 4000 - 0x4001 43FF1 KBTIM15Section 20.5.19 on page 541
0x4001 3C00 - 0x4001 3FFF1 KBReserved-
0x4001 3800 - 0x4001 3BFF1 KBUSART1Section 27.8.12 on page 765
0x4001 3400 - 0x4001 37FF1 KBReserved-
0x4001 3000 - 0x4001 33FF1 KBSPI1/I2S1Section 28.9.10 on page 824
0x4001 2C00 - 0x4001 2FFF1 KBTIM1Section 17.4.21 on page 402
0x4001 2800 - 0x4001 2BFF1 KBReserved-
0x4001 2400 - 0x4001 27FF1 KBADCSection 13.12 on page 274
0x4001 2000 - 0x4001 23FF1 KBReserved-
0x4001 1C00 - 0x4001 1FFF1 KBUSART8Section 27.8.12 on page 765
0x4001 1800 - 0x4001 1BFF1 KBUSART7Section 27.8.12 on page 765
0x4001 1400 - 0x4001 17FF1 KBUSART6Section 27.8.12 on page 765
0x4001 0800 - 0x4001 13FF3 KBReserved-
0x4001 0400 - 0x4001 07FF1 KBEXTISection 11.3.7 on page 225
0x4001 0000 - 0x4001 03FF1 KBSYSCFGSection 9.1.38 on page 185
COMPSection 15.5.2 on page 308
-0x4000 8000 - 0x4000 FFFF32 KBReserved-

Table 1. STM32F0xx peripheral register boundary addresses (continued)

BusBoundary addressSizePeripheralPeripheral register map
APB0x4000 7C00 - 0x4000 7FFF1 KBReserved-
0x4000 7800 - 0x4000 7BFF1 KBCECSection 31.7.7 on page 919
0x4000 7400 - 0x4000 77FF1 KBDACSection 14.10.15 on page 299
0x4000 7000 - 0x4000 73FF1 KBPWRSection 5.4.3 on page 94
0x4000 6C00 - 0x4000 6FFF1 KBCRSSection 7.7.5 on page 147
0x4000 6800 - 0x4000 6BFF1 KBReserved-
0x4000 6400 - 0x4000 67FF1 KBCANSection 29.9.5 on page 864
0x4000 6000 - 0x4000 63FF1 KBUSB/CAN SRAMSection 30.6.3 on page 900
0x4000 5C00 - 0x4000 5FFF1 KBUSBSection 30.6.3 on page 900
0x4000 5800 - 0x4000 5BFF1 KBI2C2Section 26.7.12 on page 698
0x4000 5400 - 0x4000 57FF1 KBI2C1Section 26.7.12 on page 698
0x4000 5000 - 0x4000 53FF1 KBUSART5Section 27.8.12 on page 765
0x4000 4C00 - 0x4000 4FFF1 KBUSART4Section 27.8.12 on page 765
0x4000 4800 - 0x4000 4BFF1 KBUSART3Section 27.8.12 on page 765
0x4000 4400 - 0x4000 47FF1 KBUSART2Section 27.8.12 on page 765
0x4000 3C00 - 0x4000 43FF2 KBReserved-
0x4000 3800 - 0x4000 3BFF1 KBSPI2Section 28.9.10 on page 824
0x4000 3400 - 0x4000 37FF1 KBReserved-
0x4000 3000 - 0x4000 33FF1 KBIWDGSection 23.4.6 on page 582
0x4000 2C00 - 0x4000 2FFF1 KBWWDGSection 24.5.4 on page 588
0x4000 2800 - 0x4000 2BFF1 KBRTCSection 25.7.18 on page 628
0x4000 2400 - 0x4000 27FF1 KBReserved-
0x4000 2000 - 0x4000 23FF1 KBTIM14Section 19.4.13 on page 490
0x4000 1800 - 0x4000 1FFF2 KBReserved-
0x4000 1400 - 0x4000 17FF1 KBTIM7Section 21.4.9 on page 572
0x4000 1000 - 0x4000 13FF1 KBTIM6Section 21.4.9 on page 572
0x4000 0800 - 0x4000 0FFF2 KBReserved-
0x4000 0400 - 0x4000 07FF1 KBTIM3Section 18.4.19 on page 469
0x4000 0000 - 0x4000 03FF1 KBTIM2Section 18.4.19 on page 469

Table 2. STM32F0xx memory boundary addresses

DeviceBoundary addressSizeMemory AreaRegister description
STM32F03x0x2000 1000 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 0FFF4 KBSRAMSection 2.3 on page 52
0x1FFF FC00 - 0x1FFF FFFF1 KBReserved-
0x1FFF F800 - 0x1FFF FBFF1 KBOption bytesSection 4 on page 76
0x1FFF EC00 - 0x1FFF F7FF3 KBSystem memory-
0x0800 8000 - 0x1FFF EBFF~384 MBReserved-
0x0800 0000 - 0x0800 7FFF32 KBMain flash memorySection 3 on page 56
0x0000 8000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0000 7FFF32 KBMain flash memory, system memory or SRAM depending on BOOT configuration-
STM32F04x0x2000 1800 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 17FF6 KBSRAMSection 2.3 on page 52
0x1FFF FC00 - 0x1FFF FFFF1 KBReserved-
0x1FFF F800 - 0x1FFF FBFF1 KBOption bytesSection 4 on page 76
0x1FFF C400 - 0x1FFF F7FF13 KBSystem memory-
0x0801 8000 - 0x1FFF C7FF~384 MBReserved-
0x0800 0000 - 0x0801 7FFF32 KBMain flash memorySection 3 on page 56
0x0001 8000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0000 7FFF32 KBMain flash memory, system memory or SRAM depending on BOOT configuration-
STM32F05x0x2000 2000 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 1FFF8 KBSRAMSection 2.3 on page 52
0x1FFF FC00 - 0x1FFF FFFF1 KBReserved-
0x1FFF F800 - 0x1FFF FBFF1 KBOption bytesSection 4 on page 76
0x1FFF EC00 - 0x1FFF F7FF3 KBSystem memory-
0x0801 0000 - 0x1FFF EBFF~384 MBReserved-
0x0800 0000 - 0x0800 FFFF64 KBMain flash memorySection 3 on page 56
0x0001 0000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0000 FFFF64 KBMain flash memory, system memory or SRAM depending on BOOT configuration-
Table 2. STM32F0xx memory boundary addresses (continued)
DeviceBoundary addressSizeMemory AreaRegister description
STM32F07x0x2000 4000 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 3FFF16 KBSRAMSection 2.3 on page 52
0x1FFF F800 - 0x1FFF FFFF2 KBOption bytesSection 4 on page 76
0x1FFF C800 - 0x1FFF F7FF12 KBSystem memory-
0x0802 0000 - 0x1FFF C7FF~384 MBReserved-
0x0800 0000 - 0x0801 FFFF128 KBMain flash memorySection 3 on page 56
0x0002 0000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0001 FFFF128 KBMain flash memory, system memory or SRAM depending on BOOT configuration-
STM32F09x0x2000 8000 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 7FFF32 KBSRAMSection 2.3 on page 52
0x1FFF F800 - 0x1FFF FFFF2 KBOption bytesSection 4 on page 76
0x1FFF D800 - 0x1FFF F7FF8 KBSystem memory-
0x0804 0000 - 0x1FFF D7FF~384 MBReserved-
0x0800 0000 - 0x0803 FFFF256 KBMain flash memorySection 3 on page 56
0x0004 0000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0003 FFFF256 KBMain flash memory, system memory or SRAM depending on BOOT configuration-

2.3 Embedded SRAM

STM32F03x devices feature 4 Kbytes of static SRAM. STM32F04x devices feature 6 Kbytes of static SRAM. STM32F05x devices feature 8 Kbytes of static SRAM. STM32F07xS devices feature 16 Kbytes of static SRAM. STM32F09x devices feature 32 Kbytes of static SRAM.

This RAM can be accessed as bytes, half-words (16 bits) or full words (32 bits). This memory can be addressed at maximum system clock frequency without wait state and thus by both CPU and DMA.

Parity check

The user can enable the parity check using the option bit RAM_PARITY_CHECK in the user option byte (refer to Section 4: Option bytes ).

The data bus width is 36 bits because 4 bits are available for parity check (1 bit per byte) in order to increase memory robustness, as required for instance by Class B or SIL norms.

The parity bits are computed and stored when writing into the SRAM. Then, they are automatically checked when reading. If one bit fails, an NMI is generated. The same error can also be linked to the BRK_IN Break input of TIM1/15/16/17, with the

SRAM_PARITY_LOCK control bit in the SYSCFG configuration register 2 (SYSCFG_CFGR2) . The SRAM Parity Error flag (SRAM_PEF) is available in the SYSCFG configuration register 2 (SYSCFG_CFGR2) .

Note: When enabling the RAM parity check, it is advised to initialize by software the whole RAM memory at the beginning of the code, to avoid getting parity errors when reading non-initialized locations.

2.4 Flash memory overview

The flash memory is composed of two distinct physical areas:

The flash interface implements instruction access and data access based on the AHB protocol. It implements the prefetch buffer that speeds up CPU code execution. It also implements the logic necessary to carry out the flash memory operations (Program/Erase) controlled through the flash registers.

2.5 Boot configuration

In the STM32F0xx, three different boot modes can be selected through the BOOT0 pin and boot configuration bits nBOOT1, BOOT_SEL and nBOOT0 in the User option byte, as shown in the following table.

Table 3. Boot modes (1)

Boot mode configurationMode
nBOOT1 bitBOOT0 pinBOOT_SEL bitnBOOT0 bit
x01xMain flash memory is selected as boot area (2)
111xSystem memory is selected as boot area
011xEmbedded SRAM is selected as boot area
xx01Main flash memory is selected as boot area
1x00System memory is selected as boot area
0x00Embedded SRAM is selected as boot area

1. Grey options are available on STM32F04x and STM32F09x devices only.

2. For STM32F04x and STM32F09x devices, see also Empty check description.

The boot mode configuration is latched on the 4th rising edge of SYSCLK after a reset. It is up to the user to set boot mode configuration related to the required boot mode.

The boot mode configuration is 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 at 0x0000 0004.

Depending on the selected boot mode, main flash memory, system memory or SRAM is accessible as follows:

Empty check

On STM32F04x and STM32F09x devices only, internal empty check flag is implemented to allow easy programming of virgin devices by the boot loader. This flag is used when BOOT0 pin is defining Main flash memory as the target boot area. When the flag is set, the device is considered as empty and System memory (boot loader) is selected instead of the main flash as a boot area to allow user to program the flash memory.

This flag is updated only during the loading of option bytes: it is set when the content of the address 0x08000 0000 is read as 0xFFFF FFFF, otherwise it is cleared. It means a power reset or setting of OBL_LAUNCH bit in FLASH_CR register is needed to clear this flag after programming of a virgin device to execute user code after System reset.

Note: If the device is programmed for a first time but the option bytes are not reloaded, the device still selects System memory as a boot area after a System reset. In the STM32F04x, the boot loader code is able to detect this situation. It then changes the boot memory mapping to main flash and performs a jump to user code programmed there. In the STM32F09x, a POR must be performed or the Option bytes reloaded before applying the system reset.

Physical remap

Once the boot mode is selected, the application software can modify the memory accessible in the code area. This modification is performed by programming the MEM_MODE bits in the SYSCFG configuration register 1 (SYSCFG_CFGR1) . Unlike Cortex ® M3 and M4, the M0 CPU does not support the vector table relocation. For application code which is located in a different address than 0x0800 0000, some additional code must be added in order to be able to serve the application interrupts. A solution is to relocate by software the vector table to the internal SRAM:

This operation should be done at the initialization phase of the application. Please refer to AN4065 and attached IAP code from www.st.com for more details.

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 using one of the following serial interfaces:

For further details, refer to the application note AN2606.