Memory Mapped Registers vs Non Memory Mapped Registers in an STM32 Board- Explained

STM32F407G discovery board



In this article, we explain the differences between memory mapped registers and non memory mapped registers in an STM32F4xx microcontroller board. 

There are several different types of registers that are found on an STM32 microcontroller board. 

There are registers located within the processor core of the microcontroller board. These registers are referred to as processor registers, or core registers. These are non memory mapped registers. These registers do not appear in the processor map of the microcontroller because these registers do not have unique addresses associated with them.

Registers external to the processor core are memory mapped registers. These registers are outside of the processor core and are found in the processor map of the microcontroller. These registers have unique addresses associated with them so that each of these registers can be identified with a unique address. These addresses can be found in the datasheet of the microcontroller.

We will go into depth with these 2 types of registers. 

So registers that are found within the processor core are non memory mapped registers. 

These include general-purpose registers along with special-purpose registers, such as the stack pointer, link register, program counter, and program status register. 

Specifically, for the cortex-M4 processor found in many STM32 boards, there are 13 general-purpose registers and several special-purpose registers. 

These processor core registers are shown in the diagram below.


Cortex-M4 processor register set


These registers are within the processor of the microcontroller board. 

Thus, they do not appear within the memory map of the datasheet of the microcontroller board.

Being that these registers are within the processor and are processor specific, they are not external to the microcontroller board and, thus, are not given unique addressing in the memory map.

Moreover, since they do not have addressing as given by the microcontroller manufacturer, they cannot be referenced directly through C code through addressing dereferencing. Instead, they can only be referenced through assembly code.

Again, non memory mapped registers cannot be directly accessed through C code but can only be accessed through assembly code. 

Memory mapped registers are those registers that are external to the processor core, or those registers that are not found within the processor core. 

These registers have been given unique addresses by the microcontroller designer. 

There are 2 types of memory mapped registers. 

There are registers of processor-specific peripherals such as NVIC (nested vector interrupt controller), MPU (memory protection unit), SCB (system control block), and the DEBUG register. 

Other registers are microcontroller-specific peripherals such as RTC, I2C, TIMER, CAN, USB, etc. 

All of these registers have been given unique memory addresses by the microcontroller designer. Thus, these registers can be uniquely and identified and used by a C program without needing any assembly code to identify or use them. 

So a key distinction between non memory mapped registers and memory mapped registers is that a memory mapped register has a unique address assigned by the microcontroller board creator that can identify the register. Moreover, memory mapped registers can be directly referenced and used through C code through address derereferencing. Non memory mapped registers, registers within the processor, which for many STM32 processors is the cortex-M4 processor, have no address assigned by the microcontroller designer. Therefore, these addresses need in-line assembly in order to reference them, as it is not possible to do this in C code due to no allocated address. 



Related Resources





HTML Comment Box is loading comments...