2. Memory and bus architecture

The following definition is used in this section:

2.1 System architecture

The main system consists of a 32-bit multilayer AHB bus matrix that interconnects the following masters and slaves:

The bus matrix provides access from a master to a slave, enabling concurrent access and efficient operation even when several high-speed peripherals work simultaneously.

This architecture is shown in the figure below.

Figure 1. System architecture

System architecture diagram showing CPU, DMA, and bus matrix connections to various memory and peripheral blocks.

The diagram illustrates the system architecture of a microcontroller. At the top, three main components are shown: a CPU (Arm Cortex-M4), DMA1, and DMA2. The CPU is connected to the bus matrix via three interfaces: S0 (I-bus), S1 (D-bus), and S2 (S-bus). DMA1 is connected to S4, and DMA2 is connected to S5. The bus matrix is a central grid with seven slave interfaces (M0 to M7) on the right side. These interfaces are connected to various memory and peripheral blocks:

The bus matrix itself has a grid of connections between the slave interfaces (M0-M7) and the master interfaces (S0-S5). Grey circles indicate connections that are active 'when remapped'. A legend at the bottom right indicates that a grey circle represents 'when remapped'. The diagram is labeled MSV60753V1.

System architecture diagram showing CPU, DMA, and bus matrix connections to various memory and peripheral blocks.

2.1.1 S0: CPU I-bus

This bus connects the instruction bus of the CPU core to the bus matrix. This bus is used by the core to fetch instructions. The targets of this bus are the internal flash memory, SRAM1 and SRAM2.

2.1.2 S1: CPU D-bus

This bus connects the data bus of the CPU core to the bus matrix. This bus is used by the core for literal load and debug access. The targets of this bus are the internal flash memory, SRAM1 and SRAM2.

2.1.3 S2: CPU S-bus

This bus connects the system bus of the CPU core to the bus matrix. This bus is used by the core to access data located in a peripheral or SRAM area. The targets of this bus are the SRAM1, SRAM2, the AHB1 peripherals including the APB1 and APB2 peripherals, the AHB2 peripherals and the AHB3 peripherals including the APB3.

2.1.4 S4, S5: DMA-bus

These buses connect the AHB master interface of the DMAs to the bus matrix. The targets of this bus are the internal flash memory, SRAM1, SRAM2 the AHB1 peripherals including the APB1 and APB2 peripherals, the AHB2 peripherals and the AHB3 peripherals including the APB3 peripherals.

AHB/APB bridges

The two bridges AHB to APB1 and AHB to APB2 provide full synchronous connections between the AHB1 and the two APB buses, allowing flexible selection of the peripheral frequency.

The bridge AHB to APB3 provides full synchronous connections between the AHB and the APB bus, allowing flexible selection of the frequency between the AHB and peripherals.

Refer to Section 2.4.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 SRAM1/2 and the flash memory interface. Before using a peripheral, its clock must be enabled in the RCC_AHBxENR and RCC_APBxENR registers.

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 Boot configuration

Three different CPU boot modes can be selected through the BOOT0 pin and nBOOT1 bit in the user options.

Boot is furthermore conditioned by the CPU boot lock enable and the user flash memory empty check, as shown in the table below.

Table 1. Device boot mode

Boot mode selectionValid optionsUser Flash emptyCPU aliasing space
nBOOT1 optionnBOOT0 optionPH3/BOOT0nSWBOOT0 optionBOOT_LOCK
xx01xNoxHold
11SRAM1 boot
1x0Hold
00SRAM1 boot

Table 1. Device boot mode (continued)

Boot mode selectionValid optionsUser Flash emptyCPU aliasing space
nBOOT1 optionnBOOT0 optionPH3/BOOT0nSWBOOT0 optionBOOT_LOCK
xx010Yes0User Flash boot
1System Flash boot
11xSystem Flash boot
0SRAM1 boot
x1x010User Flash boot
0System Flash boot
1xxSystem Flash boot
00SRAM1 boot
x1User Flash boot

Values on BOOT0 and BOOT1 are latched after a reset. It is up to the user to provide the correct value for the required boot mode.

BOOT0 and BOOT1 are also re-sampled when exiting Standby mode. Consequently they must be kept in the required boot mode. After the startup delay, the CPU fetches the top-of-stack 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 flash memory and SRAM1 are accessible as follows:

The main flash memory is aliased in the CPU boot memory space at address 0x0000 0000 and is also still accessible from its physical address 0x0800 0000. In other words, the flash memory contents can be accessed starting from address 0x0000 0000 or 0x0800 0000.

The system flash memory is aliased in the CPU boot memory space at address 0x0000 0000 and is also still accessible from its physical address 0x1FFF 0000.

The SRAM memory is aliased in the CPU boot memory space at address 0x0000 0000 and is also still accessible from its physical address 0x2000 0000.

CPU SRAM physical remap

Following CPU boot, the application software can modify the memory map at address 0x0000 0000. This modification is performed by programming the SYSCFG memory remap register (SYSCFG_MEMRMP) in the SYSCFG controller.

The following memories can be remapped:

Embedded bootloader

The embedded bootloader is located in the system flash memory, programmed by STMicroelectronics during production. It is used to program the flash memory using one of the following device interfaces:

The embedded bootloader runs on the CPU and can be used to load content in memory areas.

2.3 SRAM erase

SRAM1, SRAM2 and PKA SRAM provide an SRAM erase feature.

These SRAMs are erased under the conditions detailed in the table below.

Table 2. SRAM erase conditions

ConditionSRAM1 (1)SRAM2 (1)PKA SRAM (2)
System reset (3) (user option SRAM_RST = 1)RetainedRetainedHardware erased
System reset (user option SRAM_RST = 0)Hardware erasedHardware erasedHardware erased
OBL with invalid user optionsHardware erasedHardware erasedHardware erased
RDP regression from 1 to 0, on OPTSTRT.Hardware erased (4)Hardware erasedHardware erased
Tamper (5)RetainedHardware erasedHardware erased
SYSCFG_SCSR.SRAM2ERRetainedHardware erasedRetained

1. An ongoing SRAM1 or SRAM2 erase can be monitored by SYSCFG_SCSR.SRAMBSY flag.

2. An ongoing PKA SRAM erase can be monitored by SYSCFG_SCSR.PKASRAMBSY flag.

3. POR, NRST, and wake-up from Standby.

4. For more details, see Table 12: RDP regression from level 1 to level 0 and memory erase .

5. To be able to debug without SRAM erase on tamper, especially ITAM6 debug access, the tamper erase must be disabled in the TAMP by firmware.

2.4 Memory organization

2.4.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.

2.4.2 Memory map and register boundary addresses

Figure 2. Memory map

Memory map diagram showing CPU internal peripherals, Peripherals, SRAM, and CODE memory regions with their respective address ranges and detailed peripheral and memory addresses.

The memory map illustrates the allocation of memory for CPU internal peripherals, peripherals, SRAM, and CODE. The diagram is divided into two main columns of addresses. The left column shows the main memory regions, and the right column provides a detailed breakdown of specific address ranges for peripherals and memory.

Memory Regions and Address Ranges:

Detailed Address Ranges:

Legend:

MSv60755V1

Memory map diagram showing CPU internal peripherals, Peripherals, SRAM, and CODE memory regions with their respective address ranges and detailed peripheral and memory addresses.

Any memory area not allocated to on-chip memories and peripherals is considered "Reserved".

The table below details the boundary addresses of peripherals available in the device.

Table 3. Memory map and peripheral register boundary addresses

BusBoundary addressSize (bytes)PeripheralPeripheral register map
APB30x5801 0400 - 0x5801 FFFF-Reserved-
0x5801 0000 - 0x5801 03FF1 KSUBGHZSPISection 35.9.10: SPI/I2S register map
AHB30x5800 4400 - 0x5800 FFFF-Reserved-
0x5800 4000 - 0x5800 43FF1 KFLASHSection 3.8.14: FLASH register map
0x5800 3400 - 0x5800 3FFF8 KPKA continueSection 22.7.5: PKA register map
0x5800 2400 - 0x5800 33FFPKA RAM
0x5800 2000 - 0x5800 23FFPKA
0x5800 1C00 - 0x5800 1FFF-Reserved-
0x5800 1800 - 0x5800 1BFF1 KAESSection 21.7.18: AES register map
0x5800 1400 - 0x5800 17FF1 KHSEMSection 7.4.9: HSEM register map
0x5800 1000 - 0x5800 13FF1 KTrue RNGSection 20.7.5: RNG register map
0x5800 0C00 - 0x5800 0FFF-Reserved-
0x5800 0800 - 0x5800 0BFF1 KEXTISection 14.6.12: EXTI register map
0x5800 0400 - 0x5800 07FF1 KPWRSection 5.5.19: PWR register map
0x5800 0000 - 0x5800 03FF1 KRCCSection 6.4.33: RCC register map
AHB20x4800 2000 - 0x57FF FFFF-Reserved-
0x4800 1C00 - 0x4800 1FFF8 KGPIOSection 8.4.36: GPIOH register map
0x4800 0C00 - 0x4800 1BFFReserved
0x4800 0800 - 0x4800 0BFFSection 8.4.35: GPIOC register map
0x4800 0400 - 0x4800 07FFSection 8.4.34: GPIOB register map
0x4800 0000 - 0x4800 03FFSection 8.4.33: GPIOA register map
AHB10x4260 0000 - 0x47FF FFFF-Reserved-
0x4240 0000 - 0x425F FFFF2048 KAHB1 bit banding-
0x4220 0000 - 0x423F FFFF2048 KAPB2 bit banding-
0x4200 0000 - 0x421F FFFF2048 KAPB1 bit banding-
0x4002 3400 - 0x41FF FFFF-Reserved-
0x4002 3000 - 0x4002 33FF1 KCRCSection 15.4.6: CRC register map
0x4002 0C00 - 0x4002 2FFF-Reserved-
0x4002 0800 - 0x4002 0BFF1 KDMAMUX1Section 12.6.7: DMAMUX register map
0x4002 0400 - 0x4002 07FF1 KDMA2Section 11.6.7: DMA register map
0x4002 0000 - 0x4002 03FF1 KDMA1Section 11.6.7: DMA register map

Table 3. Memory map and peripheral register boundary addresses (continued)

BusBoundary addressSize (bytes)PeripheralPeripheral register map
APB20x4001 4C00 - 0x4001 FFFF-Reserved-
0x4001 4800 - 0x4001 4BFF1 KTIM17Section 25.4.23: TIM16/TIM17 register map
0x4001 4400 - 0x4001 47FF1 KTIM16Section 25.4.23: TIM16/TIM17 register map
0x4001 3C00 - 0x4001 43FF-Reserved-
0x4001 3800 - 0x4001 3BFF1 KUSART1Section 33.8.15: USART register map
0x4001 3400 - 0x4001 37FF-Reserved-
0x4001 3000 - 0x4001 33FF1 KSPI1Section 35.9.10: SPI/I2S register map
0x4001 2C00 - 0x4001 2FFF1 KTIM1Section 23.4.30: TIM1 register map
0x4001 2800 - 0x4001 2BFF-Reserved-
0x4001 2400 - 0x4001 27FF1 KADCSection 16.13: ADC register map
0x4001 0400 - 0x4001 23FF-Reserved-
0x4001 0200 - 0x4001 03FF1 KCOMPSection 19.6.3: COMP register map
0x4001 0100 - 0x4001 01FFSYSCFG continueSection 9.2.12: SYSCFG register map
0x4001 0030 - 0x4001 00FFVREFBUFSection 18.3.3: VREFBUF register map
0x4001 0000 - 0x4001 002FSYSCFGSection 9.2.12: SYSCFG register map

Table 3. Memory map and peripheral register boundary addresses (continued)

BusBoundary addressSize (bytes)PeripheralPeripheral register map
APB10x4000 B400 - 0x4000 FFFF-Reserved-
0x4000 B000 - 0x4000 B3FF1 KTAMPSection 31.6.11: TAMP register map
0x4000 9C00 - 0x4000 AFFF-Reserved-
0x4000 9800 - 0x4000 9BFF1 KLPTIM3Section 26.7.13: LPTIM register map
0x4000 9400 - 0x4000 97FF1 KLPTIM2Section 26.7.13: LPTIM register map
0x4000 8400 - 0x4000 93FF-Reserved-
0x4000 8000 - 0x4000 83FF1 KLPUART1Section 34.7.13: LPUART register map
0x4000 7C00 - 0x4000 7FFF1 KLPTIM1Section 26.7.13: LPTIM register map
0x4000 7800 - 0x4000 7BFF-Reserved-
0x4000 7400 - 0x4000 77FF1KDACSection 17.7.13: DAC register map
0x4000 6000 - 0x4000 73FF-Reserved-
0x4000 5C00 - 0x4000 5FFF1 KI2C3Section 32.9.12: I2C register map
0x4000 5800 - 0x4000 5BFF1 KI2C2Section 32.9.12: I2C register map
0x4000 5400 - 0x4000 57FF1 KI2C1Section 32.9.12: I2C register map
0x4000 4800 - 0x4000 53FF-Reserved-
0x4000 4400 - 0x4000 47FF1 KUSART2Section 33.8.15: USART register map
0x4000 3C00 - 0x4000 43FF-Reserved-
0x4000 3800 - 0x4000 3BFF1 KSPI2S2Section 35.9.10: SPI/I2S register map
0x4000 3400 - 0x4000 37FF-Reserved-
0x4000 3000 - 0x4000 33FF1 KIWDGSection 28.4.6: IWDG register map
0x4000 2C00 - 0x4000 2FFF1 KWWDGSection 29.5.4: WWDG register map
0x4000 2800 - 0x4000 2BFF1 KRTCSection 30.6.23: RTC register map
0x4000 0400 - 0x4000 27FF-Reserved-
0x4000 0000 - 0x4000 03FF1 KTIM2Section 24.4.25: TIMx register map
-0x2220 0000 - 0x3FFF FFFF-Reserved-
AHB30x2210 0000 - 0x221F FFFF1024 K (1)SRAM2 bit banding-
0x2200 0000 - 0x220F FFFF1024 K (1)SRAM1 bit banding-
-0x2001 0000 - 0x21FF FFFF-Reserved-
AHB30x2000 8000 - 0x2000 FFFF32 K (1)SRAM2-
0x2000 0000 - 0x2000 7FFF32 K (1)SRAM1-
-0x1FFF 8080 - 0x1FFF FFFF-Reserved-
Table 3. Memory map and peripheral register boundary addresses (continued)
BusBoundary addressSize (bytes)PeripheralPeripheral register map
AHB30x1FFF 7800 - 0x1FFF 7FFF2 KFlash user optionsSection 3.8.14: FLASH register map
0x1FFF 7400 - 0x1FFF 77FF1 KFlash Engi-
0x1FFF 7000 - 0x1FFF 73FF1 KFlash OTP-
0x1FFF 0000 - 0x1FFF 6FFF28 KFlash RSS and bootloader-
-0x1000 8000 - 0x1FFE FFFF-Reserved-
AHB30x1000 0000 - 0x1000 7FFF32 K (1)SRAM2-
-0x0804 0000 - 0x0FFF FFFF-Reserved-
AHB30x0800 0000 - 0x0803 FFFF256 K (1)User flash-
-0x0004 0000 - 0x07FF FFFF-Reserved-
BOOT (2)0x0000 0000 - 0x0003 FFFF256 K (1)CPU boot area-

1. Size depending on the device. Refer to the datasheet for more details.

2. Bus depends on the selected CPU boot area.

2.4.3 CPU bit banding

The CPU 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.

The AHB1, APB1, APB2 peripheral registers and the SRAM1 and SRAM2 are mapped to a bit-band region, so that single bit-band write and read operations are allowed. The operations are only available for CPU accesses and not from other bus masters (such as DMA).

The peripheral bit-band alias is located from address 0x4200 0000 to 0x425F FFFF.

The SRAM bit-band alias is located from address 0x2200 0000 to 0x221F FFFF.

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

\[ \text{bit\_word\_addr} = \text{bit\_band\_base} + (\text{byte\_offset} * 32) + (\text{bit\_number} * 4) \]

where:

Example

The following example shows how to map bit [2] of the byte located at SRAM1 address 0x2000 0300 to the alias region. The formula is then:

\[ 0x2200\ 6008 = 0x2200\ 0000 + 0x0300 * 32 + 2 * 4 \]

Writing to address 0x2200 6008 has the same effect as a read-modify-write operation on bit [2] of the byte at SRAM1 address 0x2000 0300.

Reading address 0x2200 6008 returns the value 0x01 or 0x00 of bit [2] of the byte at SRAM1 address 0x2000 0300.

For more information on bit-band, refer to the Cortex-M4 programming manual.