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 Cortex M0+ core, DMA Controller, Busmatrix, and various peripherals via AHB and APB buses.

The diagram illustrates the system architecture of the STM32L0x2 microcontroller. At the center is the Busmatrix , which acts as a bridge between the system bus and the AHB bus. The Cortex M0+ core and the DMA Controller (Channels 1 to 7) are connected to the Busmatrix via the System bus and DMA respectively. The GPIO ports A,B,C,D,E,H are connected to the Cortex M0+ core via an IOPORT block. The Busmatrix is also connected to the MIF Memory interface and SRAM , which in turn connect to NVM memory . Below the Busmatrix, a vertical AHB bus connects to several functional blocks: Reset and clock controller (RCC) , Touch sensing controller (TSC) , CRC , AES , and RNG . These blocks are connected to a large block of APB buses via AHB2APB Bridges . The APB buses connect to a variety of peripherals listed in the diagram: SYSCFG , FIREWALL , PWR , CRS , EXTI , ADC , DAC , COMP1/2 , TIM2/3/6/7/21/22 , LPTIM1 , IWDG , WWDG , RTC , DBGMCU , I2C1/2/3 , USART1/2/3/4/LPUART1 , SPI1/2 , USB SRAM , and USB FS . A DMA request line is shown connecting the APB buses back to the DMA Controller. The diagram is labeled with the code MS34748V2 in the bottom right corner.

Figure 1. System architecture diagram showing the interconnection of the Cortex M0+ core, DMA Controller, Busmatrix, and various peripherals via AHB and APB buses.
  1. 1. Refer to Table 1: STM32L0x2 memory density , to Table 2: Overview of features per category and to the device datasheets for the GPIO ports and peripherals available on your device.

2.1.1 S0: Cortex ® -bus

This bus connects the DCode/ICode bus of the Cortex ® -M0+ core to the BusMatrix. This bus is used by the core to fetch instructions, get data and access the AHB/APB resources.

2.1.2 S1: DMA-bus

This bus connects the AHB master interface of the DMA to the BusMatrix which manages the access of the different masters to Flash memory and data EEPROM, the SRAM and the AHB/APB peripherals.

2.1.3 BusMatrix

The BusMatrix manages the access arbitration between masters. The arbitration uses a Round Robin algorithm. The BusMatrix is composed of two masters (CPU, DMA) and three slaves (NVM interface, SRAM, AHB2APB1/2 bridges).

AHB/APB bridges

The AHB/APB bridge provide full synchronous connections between the AHB and the 2 APB buses. APB1 and APB2 operate at a maximum frequency of 32 MHz.

Refer to Section 2.2.2: Memory map and register boundary addresses on page 58 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 MIF). Before using a peripheral you have to enable its clock in the RCC_AHBENR, RCC_APB2ENR, RCC_APB1ENR or RCC_IOPENR 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 from 0x0000 0000 to 0xFFFF FFFF. The diagram is divided into three vertical columns. The left column shows the full 4GB address space with major blocks: CODE (0x0000 0000 to 0x2000 0000), SRAM (0x2000 0000 to 0x4000 0000), Peripherals (0x4000 0000 to 0x6000 0000), Cortex-M0+ peripherals (0xE000 0000 to 0xE010 0000), and several reserved regions. The middle column provides a detailed view of the first 2MB (0x0000 0000 to 0x1FFF FFFF), showing Flash, system memory or SRAM (depending on BOOT configuration), reserved, Flash system memory, reserved, System memory, and Option bytes. The right column shows the peripheral region from 0x4000 0000 to 0x5000 1FFF, including APB1, reserved, APB2, reserved, AHB, reserved, and IOPORT. A legend at the bottom left indicates that grey-shaded areas are 'Reserved'.

Memory map details:

Zoomed-in view of 0x0000 0000 to 0x1FFF FFFF:

Peripheral region (0x4000 0000 to 0x5000 1FFF):

Legend: Reserved

MS34761V2

Memory map diagram showing the layout of memory from 0x0000 0000 to 0xFFFF FFFF. The diagram is divided into three vertical columns. The left column shows the full 4GB address space with major blocks: CODE (0x0000 0000 to 0x2000 0000), SRAM (0x2000 0000 to 0x4000 0000), Peripherals (0x4000 0000 to 0x6000 0000), Cortex-M0+ peripherals (0xE000 0000 to 0xE010 0000), and several reserved regions. The middle column provides a detailed view of the first 2MB (0x0000 0000 to 0x1FFF FFFF), showing Flash, system memory or SRAM (depending on BOOT configuration), reserved, Flash system memory, reserved, System memory, and Option bytes. The right column shows the peripheral region from 0x4000 0000 to 0x5000 1FFF, including APB1, reserved, APB2, reserved, AHB, reserved, and IOPORT. A legend at the bottom left indicates that grey-shaded areas are 'Reserved'.

All the memory map areas that are 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.

The following table gives the boundary addresses of the peripherals available in the devices.

Table 3. STM32L0x2 peripheral register boundary addresses (1)

BusBoundary addressSize (bytes)PeripheralPeripheral register map
IOPORT0X5000 1C00 - 0X5000 1FFF1KGPIOHSection 9.4.12: GPIO register map
0X5000 1400 - 0X5000 1BFF2 KReserved-
0X5000 1000 - 0X5000 13FF1KGPIOESection 9.4.12: GPIO register map
0X5000 0C00 - 0X5000 0FFF1KGIODSection 9.4.12: GPIO register map
0X5000 0800 - 0X5000 0BFF1KGPIO CSection 9.4.12: GPIO register map
0X5000 0400 - 0X5000 07FF1KGPIOBSection 9.4.12: GPIO register map
0X5000 0000 - 0X5000 03FF1KGPIOASection 9.4.12: GPIO register map
AHB0X4002 6400 - 0X4002 FFFF49 KReserved-
0X4002 6000 - 0X4002 63FF1 KAES (Cat 3 and 5 with AES only)Section 18.7.13: AES register map
0X4002 5400 - 0X4002 5FFF3 KReserved-
0X4002 5000 - 0X4002 53FF1 KRNGSection 19.7.4: RNG register map
0X4002 4400 - 0X4002 4FFF3 KReserved-
0X4002 4000 - 0X4002 43FF1 KTSCSection 17.6.11: TSC register map
0X4002 3400 - 0X4002 43FF3 KReserved-
0X4002 3000 - 0X4002 33FF1 KCRCSection 4.4.6: CRC register map
0X4002 2400 - 0X4002 2FFF3 KReserved-
0X4002 2000 - 0X4002 23FF1 KFLASHSection 3.7.11: Flash register map
0X4002 1400 - 0X4002 1FFF3 KReserved-
0X4002 1000 - 0X4002 13FF1 KRCCSection 7.3.22: RCC register map
0X4002 0400 - 0X4002 0FFF3 KReserved-
0X4002 0000 - 0X4002 03FF1 KDMA1Section 11.6.8: DMA register map
Table 3. STM32L0x2 peripheral register boundary addresses (1) (continued)
BusBoundary addressSize (bytes)PeripheralPeripheral register map
APB20X4001 5C00 - 0X4001 FFFF42 KReserved-
0X4001 5800 - 0X4001 5BFF1 KDBGSection 32.10: DBG register map
0X4001 3C00 - 0X4001 57FF7 KReserved-
0X4001 3800 - 0X4001 3BFF1 KUSART1Section 28.8.12: USART register map
0X4001 3400 - 0X4001 37FF1 KReserved-
0X4001 3000 - 0X4001 33FF1 KSPI1Section 30.7.10: SPI register map
0X4001 2800 - 0X4001 2FFF2 KReserved-
0X4001 2400 - 0X4001 27FF1 KADC1Section 14.12: ADC register map
0X4001 2000 - 0X4001 23FF1 KReserved-
0X4001 1C00 - 0X4001 1FFF1 KFirewallSection 5.4.8: Firewall register map
0X4001 1800 - 0X4001 1BFF1 KReserved-
0X4001 1400 - 0X4001 17FF1 KTIM22Section 21.4.16: TIM21/22 register map
0X4001 0C000 - 0X4001 13FF2 KReserved-
0X4001 0800 - 0X4001 0BFF1 KTIM21Section 21.4.16: TIM21/22 register map
0X4001 0400 - 0X4001 07FF1 KEXTISection 13.5.7: EXTI register map
0X4001 0000 - 0X4001 03FF1 KSYSCFG, COMPSection 10.2.8: SYSCFG register map, Section 16.5.3: COMP register map
Table 3. STM32L0x2 peripheral register boundary addresses (1) (continued)
BusBoundary addressSize (bytes)PeripheralPeripheral register map
APB10X4000 8000 - 0X4000 FFFF32 KReserved-
0X4000 7C00 - 0X4000 7FFF1 KLPTIM1Section 23.7.9: LPTIM register map
0X4000 7800 - 0X4000 7BFF1KI2C3Section 27.7.12: I2C register map
0X4000 7400 - 0X4000 77FF1 KDAC1/2Section 15.10.15: DAC register map
0X4000 7000 - 0X4000 73FF1 KPWRSection 6.4.3: PWR register map
0X4000 6C00 - 0X4000 6FFF1 KCRSSection 8.7.5: CRS register map
0X4000 68000 - 0X4000 6BFF1 KReserved-
0X4000 6000 - 0X4000 67FF2 KUSB (SRAM 512x16bit)-
0X4000 5C00 - 0X4000 5FFF1 KUSB FSSection 31.6.3: USB register map
Table 3. STM32L0x2 peripheral register boundary addresses (1) (continued)
BusBoundary addressSize (bytes)PeripheralPeripheral register map
APB10X4000 5800 - 0X4000 5BFF1 KI2C2Section 27.7.12: I2C register map
0X4000 5400 - 0X4000 57FF1 KI2C1Section 27.7.12: I2C register map
0X4000 5000 - 0X4000 53FF1 KUSART5Section 28.8.12: USART register map
0X4000 4C00 - 0X4000 4FFF1 KUSART4Section 28.8.12: USART register map
0X4000 4800 - 0X4000 4BFF1 KLPUART1Section 29.7.10: LPUART register map
0X4000 4400 - 0X4000 47FF1 KUSART2Section 28.8.12: USART register map
0X4000 3C00 - 0X4000 43FF2 KReserved-
0X4000 3800 - 0X4000 3BFF1 KSPI2Section 30.7.10: SPI register map
0X4000 3400 - 0X4000 37FF1 KReserved-
0X4000 3000 - 0X4000 33FF1 KIWDGSection 24.4.6: IWDG register map
0X4000 2C00 - 0X4000 2FFF1 KWWDGSection 25.5.4: WWDG register map
0X4000 2800 - 0X4000 2BFF1 KRTC + BKP_REGSection 26.7.21: RTC register map
0X4000 1800 - 0X4000 27FF3 KReserved-
0X4000 1400 - 0X4000 17FF1 KTIMER7Section 22.4.9: TIM6/7 register map
0X4000 1000 - 0X4000 13FF1 KTIMER6Section 22.4.9: TIM6/7 register map
0X4000 0800 - 0X4000 0FFF1 KReserved-
0X4000 0400 - 0X4000 07FF1 KTIMER3Section 20.5: TIMx register map
0X4000 0000 - 0X4000 03FF1 KTIMER2Section 20.5: TIMx register map
SRAM0X2000 2000 - 0X3FFF FFFF~524 MReserved-
0X2000 0000 - 0X2000 4FFFup to 20 KSRAM-
Table 3. STM32L0x2 peripheral register boundary addresses (1) (continued)
BusBoundary addressSize (bytes)PeripheralPeripheral register map
NVM0x0800 0000 - 0x0802 FFFFup to 192 KFlash program memory-
0x0808 0000 - 0x0808 17FFup to 6 KData EEPROM-
0x1FF0 0000 - 0x1FF0 1FFF8 KSystem memory-
0x1FF8 0020 - 0x1FF8 007F96Factory option bytes-
0x1FF8 0000 - 0x1FF8 001F32User option bytes-
  1. 1. Refer to Table 1: STM32L0x2 memory density , to Table 2: Overview of features per category and to the device datasheets for the GPIO ports and peripherals available on your device. The memory area corresponding to unavailable GPIO ports or peripherals are reserved.

2.3 Embedded SRAM

STM32L0x2 devices feature up to 20 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.

The SRAM start address is 0x2000 0000.

The CPU can access the SRAM from address 0x0000 0000 when physical remap is selected through boot pin or MEM_MODE (see Section 10.2.1: SYSCFG memory remap register (SYSCFG_CFGR1) ).

2.4 Boot configuration

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

Table 4. Boot modes (1)
Boot mode selectionBoot modeAliasings
BOOT1 pinBOOT0 pin
X0Flash program memoryFlash program memory is selected as boot area
01System memorySystem memory is selected as boot area
11Embedded SRAMEmbedded SRAM is selected as boot area
  1. 1. BOOT1 value is the opposite of nBOOT1 option bit.

The boot mode configuration is latched on the 4th rising edge of SYSCLK after reset. It is up to the user to set nBOOT1 and BOOT0 to select the required boot mode.

The boot mode configuration is also re-sampled when exiting from Standby mode. Consequently the boot mode configuration must not be modified 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, Flash program memory, system memory or SRAM is accessible as follows:

Bank swapping (category 5 devices only)

For devices featuring two banks, the bank swapping mechanism allows the CPU to point either to bank1 or to bank 2 in the boot memory space (0x0000 0000). Either Flash program and data EEPROM address are changed (see Table 8: NVM organization for UFB = 0 (128 Kbyte category 5 devices) , Table 10: NVM organization for UFB = 0 (64 Kbyte category 5 devices) ).

Physical remap

Once the boot pin and bit are 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 memory remap register (SYSCFG_CFGR1).

Embedded bootloader

The embedded bootloader 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 details concerning the bootloader serial interface corresponding I/O, refer to your device datasheet.

For further details on STM32 bootloader, please refer to AN2606.