2. Memory Map in Embedded Systems

ARM Cortex-M4 Memory Map Overview

The ARM Cortex-M4 employs a 32-bit system bus, which technically allows for a whopping 4GB of addressable memory. The address range spans from 0x00000000 to 0xFFFFFFFF. However, keep in mind that not all of this address space is available for use. For instance, in the STM32F4xx series, despite having up to 0.5GB of SRAM, only 128kB is actually available for your programs.

The address space isn't uniform; different ranges correspond to different types of hardware:

Code Memory (ROM)

This is where the executable code resides. It's a read-only memory section, and the size varies depending on the microcontroller you're using.

SRAM (Static Random Access Memory)

This is the working memory for the processor where data and instructions are temporarily stored for quick access. In STM32F4xx, for example, only 128kB is available.

Peripheral Memory

This area is designated for peripherals like ADC, UART, GPIO, etc. Accessing this region allows you to control hardware components.

External RAM

When your applications need more memory than what's available on-chip, you can extend the capabilities by adding external RAM modules.

Private Peripheral Bus

This is used for accessing CPU-specific features like timers, watchdogs, etc. It's usually reserved for real-time operating systems and advanced level programming.

Vendor-Specific Memory

This portion of the memory map is specialized for manufacturer-specific features. It can include custom hardware logic, specialized IO, or other unique elements.

memory_map

Assembly vs C: Special Note

Another critical point to note is that not everything in the memory map can be accessed directly through high-level languages like C. For example, some registers are directly tied to the CPU and can only be accessed through assembly instructions.