STM32 memory map
Memory map of STM32 Microcontroller
In this case, I’m considering the STM32F407 microcontroller , which is on my discovery board, and the memory map of the microcontroller you can refer from the data sheet or reference manual of the microcontroller.
Most of the time, the memory map will be mentioned in the reference manual.
Here I have opened the reference manual, and here if you go to this section, memory and bus architecture, and here you can get the memory map. Figure 1 shows the memory map.
Before programming the peripheral registers of different peripherals, you must refer to the STM32F4xx register boundary addresses table. Otherwise, you’ll not have any idea what are the addresses of the peripheral registers.
Let’s take an example of our GPIOD peripheral. We know that to control the LED, we have to configure the GPIOD peripheral registers. If you browse through the document, you will see GPIOD peripheral, as shown in Figure 2.
Here, the 0x4002_0C00 number says that the first register of the GPIOD peripheral is at the address 0x4002_0C00. That’s the address of the first register of the GPIOD peripheral. So, you can also say that this is the base address of GPIOD peripheral registers.
For example, if you want to know the base address of the ADC registers, then you can explore it from this table, as shown in Figure 3.
All ADC1, ADC2, ADC3 registers are placed between 0x4001_2000 – 0x4001_23FF addresses. So, this microcontroller has 3 ADCs. And here, TIM11, TIM10, TIM9, those are timers. So, it has register space for CAN, I2C, UART, like that.
If the processor puts 0x4000_6800 this address on the address bus, then the address bus will be talking to the CAN peripheral registers.
The Ethernet MAC registers are placed between 0x4002 8000 – 0x4002 93FF addresses.
The registers used to control and configure the Ethernet MAC peripheral and registers used to read data from and write data into Ethernet MAC peripheral are mapped in the range of 0x4002_8000 to 0x4002_93FF.
This is a memory map of the lpc48xx microcontroller which is designed by NXP. So, this microcontroller is also based on ARM Cortex Mx processor.
Here also you can see that, there is a memory map table( as shown in Figure 6) in the reference manual of the lpc48xx user manual.
And here this memory map says that 0x0000_0000 to 0x1FFF_FFFF is for On-chip non-volatile memory, that’s actually a flash memory.
And the SRAM, that is the data memory starts from the address 0x1000_0000.
The Boot ROM starts from the address 0x1FFF_0000.
And AHB peripherals start from the 0x2008_0000 address.
And APB peripherals start from 0x4000_0000 address onwards.
So, it doesn’t matter which microcontroller you use, just open up your user manual and you should be able to locate the memory map, without the memory map you cannot program the peripherals.
What is the address range of GPIOD peripheral registers?
0x4002_0C00 – 0x4002_0FFF is an address range of GPIOD peripherals, and if you are using a different MCU, then please refer to your device reference manual to obtain the correct address range. This is for the STM32F407 microcontroller.
If you are using some other microcontroller, it doesn’t matter whether it is from the same vendor or a different vendor, I would highly recommend you to cross-check these numbers. It may be different. So, you have to check the reference manual.
In the following article, let’s understand peripheral registers.
FastBit Embedded Brain Academy Courses
Click here: https://fastbitlab.com/course1