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 diagram showing the interconnection of the ARM Cortex-M0 core, DMA1 channels, Bus matrix, FLITF Flash interface, SRAM, GPIO Ports, AHB to APB bridge, Reset and clock controller (RCC), CRC, and a block of APB peripherals.

The diagram illustrates the system architecture. At the top left, the ARM ® Cortex ® -M0 core and DMA1 channels 1 to 5 are connected to a central Bus matrix via a System bus and a DMA bus, respectively. The Bus matrix is connected to several components: FLITF Flash interface (which connects to Flash memory), SRAM, GPIO Ports A,B,C,D,F (connected via the AHB2 bus), and an AHB to APB bridge (connected via the AHB1 bus). The AHB to APB bridge connects to a large block of APB peripherals, which includes SYSCFG, ADC, TIM1, TIM3, TIM6, TIM7, TIM14 to TIM17, IWDG, WWDG, RTC, PWR, I2C1, I2C2, USART1 to USART6, SPI1, SPI2, and DBGMCU. Below the Bus matrix, the Reset and clock controller (RCC) and CRC are connected to the AHB1 bus. DMA requests are shown as arrows from the APB peripherals block back to the DMA1 channels. The diagram is labeled MSV36431V1 in the bottom right corner.

Figure 1. System architecture diagram showing the interconnection of the ARM Cortex-M0 core, DMA1 channels, Bus matrix, FLITF Flash interface, SRAM, GPIO Ports, AHB to APB bridge, Reset and clock controller (RCC), CRC, and a block of APB peripherals.

System bus

This bus connects the system bus of the Arm ® 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 two masters (CPU, DMA) 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

Memory map diagram showing the layout of memory for the RM0360 microcontroller. The diagram is split into two main columns. The left column shows the main memory map from 0x0000 0000 to 0xFFFF FFFF, divided into 8 segments (0-7). Segment 0 contains CODE, 1 contains SRAM, 2 is reserved, 3 is reserved, 4 is reserved, 5 is reserved, 6 is reserved, and 7 contains Cortex-M0 peripherals. A callout box for segment 0 details the internal structure: Flash, system memory or SRAM (depending on BOOT configuration), Main Flash memory, System memory, and Option bytes. The right column shows the peripheral memory map from 0x4000 0000 to 0x4800 17FF. It includes two APB blocks (0x4000 0000-0x4001 8000), an AHB1 block (0x4002 0000-0x4002 43FF), and an AHB2 block (0x4800 0000-0x4800 17FF). A legend indicates that grey areas represent 'Reserved' memory.

Memory map details:

Legend: Reserved

Memory map diagram showing the layout of memory for the RM0360 microcontroller. The diagram is split into two main columns. The left column shows the main memory map from 0x0000 0000 to 0xFFFF FFFF, divided into 8 segments (0-7). Segment 0 contains CODE, 1 contains SRAM, 2 is reserved, 3 is reserved, 4 is reserved, 5 is reserved, 6 is reserved, and 7 contains Cortex-M0 peripherals. A callout box for segment 0 details the internal structure: Flash, system memory or SRAM (depending on BOOT configuration), Main Flash memory, System memory, and Option bytes. The right column shows the peripheral memory map from 0x4000 0000 to 0x4800 17FF. It includes two APB blocks (0x4000 0000-0x4001 8000), an AHB1 block (0x4002 0000-0x4002 43FF), and an AHB2 block (0x4800 0000-0x4800 17FF). A legend indicates that grey areas represent 'Reserved' memory.

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. STM32F0x0 memory boundary addresses

DeviceBoundary addressSizeMemory AreaRegister description
STM32F030x4,
STM32F030x6
0x2000 1000 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 0FFF4 KBSRAMSection 2.3 on page 42
0x1FFF FC00 - 0x1FFF FFFF1 KBReserved-
0x1FFF F800 - 0x1FFF FBFF1 KBOption bytesSection 4 on page 66
0x1FFF EC00 - 0x1FFF F7FF3 KBSystem memory-
0x0800 8000 - 0x1FFF EBFF~384 MBReserved-
0x0800 0000 - 0x0800 7FFF32 KB (1)Main flash memorySection 3 on page 46
0x0000 8000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0000 7FFF32 KB (1)Main flash memory, system memory or SRAM depending on BOOT configuration-
STM32F070x60x2000 1800 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 17FF6 KBSRAMSection 2.3 on page 42
0x1FFF FC00 - 0x1FFF FFFF1 KBReserved-
0x1FFF F800 - 0x1FFF FBFF1 KBOption bytesSection 4 on page 66
0x1FFF C400 - 0x1FFF F7FF13 KBSystem memory-
0x0801 8000 - 0x1FFF C7FF~384 MBReserved-
0x0800 0000 - 0x0801 7FFF32 KBMain flash memorySection 3 on page 46
0x0001 8000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0000 7FFF32 KBMain flash memory, system memory or SRAM depending on BOOT configuration-
STM32F030x80x2000 2000 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 1FFF8 KBSRAMSection 2.3 on page 42
0x1FFF FC00 - 0x1FFF FFFF1 KBReserved-
0x1FFF F800 - 0x1FFF FBFF1 KBOption bytesSection 4 on page 66
0x1FFF EC00 - 0x1FFF F7FF3 KBSystem memory-
0x0801 0000 - 0x1FFF EBFF~384 MBReserved-
0x0800 0000 - 0x0800 FFFF64 KBMain flash memorySection 3 on page 46
0x0001 0000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0000 FFFF64 KBMain flash memory, system memory or SRAM depending on BOOT configuration-
Table 1. STM32F0x0 memory boundary addresses (continued)
DeviceBoundary addressSizeMemory AreaRegister description
STM32F070xB0x2000 4000 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 3FFF16 KBSRAMSection 2.3 on page 42
0x1FFF F800 - 0x1FFF FFFF2 KBOption bytesSection 4 on page 66
0x1FFF C800 - 0x1FFF F7FF12 KBSystem memory-
0x0802 0000 - 0x1FFF C7FF~384 MBReserved-
0x0800 0000 - 0x0801 FFFF128 KBMain flash memorySection 3 on page 46
0x0002 0000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0001 FFFF128 KBMain flash memory, system memory or SRAM depending on BOOT configuration-
STM32F030xC0x2000 8000 - 0x3FFF FFFF~512 MBReserved-
0x2000 0000 - 0x2000 7FFF32 KBSRAMSection 2.3 on page 42
0x1FFF F800 - 0x1FFF FFFF2 KBOption bytesSection 4 on page 66
0x1FFF D800 - 0x1FFF F7FF8 KBSystem memory-
0x0804 0000 - 0x1FFF D7FF~384 MBReserved-
0x0800 0000 - 0x0803 FFFF256 KBMain flash memorySection 3 on page 46
0x0004 0000 - 0x07FF FFFF~128 MBReserved-
0x0000 0000 - 0x0003 FFFF256 KBMain flash memory, system memory or SRAM depending on BOOT configuration-

1. Limited to 16 KB on STM32F030x4 devices.

Table 2. STM32F0x0 peripheral register boundary addresses
BusBoundary addressSizePeripheralPeripheral register map
-0xE000 0000 - 0xE00F FFFF1MBCortex ® -M0 internal peripherals-
-0x4800 1800 - 0x5FFF FFFF~384 MBReserved-
AHB20x4800 1400 - 0x4800 17FF1KBGPIOFSection 8.4.11 on page 139
0x4800 1000 - 0x4800 13FF1KBReserved-
0x4800 0C00 - 0x4800 0FFF1KBGPIOESection 8.4.11 on page 139
0x4800 0800 - 0x4800 0BFF1KBGPIOCSection 8.4.11 on page 139
0x4800 0400 - 0x4800 07FF1KBGPIOBSection 8.4.11 on page 139
0x4800 0000 - 0x4800 03FF1KBGPIOASection 8.4.11 on page 139
-0x4002 4400 - 0x47FF FFFF~128 MBReserved-

Table 2. STM32F0x0 peripheral register boundary addresses (continued)

BusBoundary addressSizePeripheralPeripheral register map
AHB10x4002 3400 - 0x4002 43FF4 KBReserved-
0x4002 3000 - 0x4002 33FF1 KBCRCSection 5.4.5 on page 75
0x4002 2400 - 0x4002 2FFF3 KBReserved-
0x4002 2000 - 0x4002 23FF1 KBFLASH interfaceSection 3.5.9 on page 65
0x4002 1400 - 0x4002 1FFF3 KBReserved-
0x4002 1000 - 0x4002 13FF1 KBRCCSection 7.4.15 on page 123
0x4002 0400 - 0x4002 0FFF3 KBReserved-
0x4002 0000 - 0x4002 03FF1 KBDMASection 10.6.8 on page 169
-0x4001 8000 - 0x4001 FFFF32 KBReserved-
APB0x4001 5C00 - 0x4001 7FFF9 KBReserved-
0x4001 5800 - 0x4001 5BFF1 KBDBGMCU-
0x4001 4C00 - 0x4001 57FF3 KBReserved-
0x4001 4800 - 0x4001 4BFF1 KBTIM17Section 17.6.17 on page 466
0x4001 4400 - 0x4001 47FF1 KBTIM16Section 17.6.17 on page 466
0x4001 4000 - 0x4001 43FF1 KBTIM15Section 17.5.19 on page 449
0x4001 3C00 - 0x4001 3FFF1 KBReserved-
0x4001 3800 - 0x4001 3BFF1 KBUSART1Section 23.7.11 on page 635
0x4001 3400 - 0x4001 37FF1 KBReserved-
0x4001 3000 - 0x4001 33FF1 KBSPI1Section 24.6.8 on page 671
0x4001 2C00 - 0x4001 2FFF1 KBTIM1Section 13.4.21 on page 299
0x4001 2800 - 0x4001 2BFF1 KBReserved-
0x4001 2400 - 0x4001 27FF1 KBADCSection 12.11 on page 223
0x4001 1800 - 0x4001 23FF4 KBReserved-
0x4001 1400 - 0x4001 17FF1 KBUSART6Section 23.7.11 on page 635
0x4001 0800 - 0x4001 23FF7 KBReserved-
0x4001 0400 - 0x4001 07FF1 KBEXTISection 11.3.7 on page 181
0x4001 0000 - 0x4001 03FF1 KBSYSCFGSection 9.1.7 on page 148
-0x4000 8000 - 0x4000 FFFF32 KBReserved-
Table 2. STM32F0x0 peripheral register boundary addresses (continued)
BusBoundary addressSizePeripheralPeripheral register map
APB0x4000 7400 - 0x4000 7FFF3 KBReserved-
0x4000 7000 - 0x4000 73FF1 KBPWRSection 6.4.3 on page 87
0x4000 63FF - 0x4000 6FFF3 KBReserved-
0x4000 6000 - 0x4000 63FF1 KBUSB/SRAMSection 25.6.3 on page 703
0x4000 5C00 - 0x4000 5FFF1 KBUSBSection 25.6.3 on page 703
0x4000 5800 - 0x4000 5BFF1 KBI2C2Section 22.7.12 on page 588
0x4000 5400 - 0x4000 57FF1 KBI2C1Section 22.7.12 on page 588
0x4000 5000 - 0x4000 53FF1 KBUSART5Section 23.7.11 on page 635
0x4000 4C00 - 0x4000 4FFF1 KBUSART4Section 23.7.11 on page 635
0x4000 4800 - 0x4000 4BFF1 KBUSART3Section 23.7.11 on page 635
0x4000 4400 - 0x4000 47FF1 KBUSART2Section 23.7.11 on page 635
0x4000 3C00 - 0x4000 43FF2 KBReserved-
0x4000 3800 - 0x4000 3BFF1 KBSPI2Section 24.6.8 on page 671
0x4000 3400 - 0x4000 37FF1 KBReserved-
0x4000 3000 - 0x4000 33FF1 KBIWDGSection 19.4.6 on page 477
0x4000 2C00 - 0x4000 2FFF1 KBWWDGSection 20.5.4 on page 483
0x4000 2800 - 0x4000 2BFF1 KBRTCSection 21.7.17 on page 521
0x4000 2400 - 0x4000 27FF1 KBReserved-
0x4000 2000 - 0x4000 23FF1 KBTIM14Section 16.4.13 on page 399
0x4000 1800 - 0x4000 1FFF2 KBReserved-
0x4000 1400 - 0x4000 17FF1 KBTIM7Section 15.4.8 on page 379
0x4000 1000 - 0x4000 13FF1 KBTIM6Section 15.4.8 on page 379
0x4000 0800 - 0x4000 0FFF2 KBReserved-
0x4000 0400 - 0x4000 07FF1 KBTIM3Section 14.4.19 on page 365
0x4000 0000 - 0x4000 03FF1 KBReserved-

2.3 Embedded SRAM

STM32F030x4 and STM32F030x6 devices feature 4 Kbytes of SRAM. STM32F030x8 devices feature 8 Kbytes of SRAM. STM32F030xC devices feature 32 Kbytes of SRAM. STM32F070x6 devices feature 6 Kbytes of SRAM. STM32F070xB devices feature 16 Kbytes of SRAM.

The SRAM can be accessed by bytes, half-words (16 bits) or full words (32 bits), 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. In addition, to get the SRAM parity error at the same cycle time that it is occurring, a bus error is generated (triggering a HardFault exception) together with the NMI. This avoids the use of corrupted data by the application, but with the side effect of having both NMI and HardFault interrupts 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 STM32F0x0, three different boot modes can be selected through the BOOT0 pin and boot configuration bits nBOOT1 in the User option byte, as shown in the following table.

Table 3. Boot modes

Boot mode configurationMode
nBOOT1 bitBOOT0 pin
x0Main Flash memory is selected as boot area (1)
11System memory is selected as boot area
01Embedded SRAM is selected as boot area

1. For STM32F070x6 and STM32F030xC 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 STM32F070x6 and STM32F030xC 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.

Therefore, some of the GPIOs are reconfigured from the High-Z state. Refer to AN2606 for more details concerning the boot loader and GPIO configuration in System memory boot mode. It is possible to disable this feature by configuring the option bytes, to force boot from the Main flash memory (nSWBOOT0 = 0, nBOOT0 = 1).

The empty check flag is updated only during the loading of option bytes: it is set when the content of the address 0x0800 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 STM32F070x6, 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 STM32F030xC, 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.