Where is the sram stored in memory in a stm32f411e-disco microcontroller?
In the STM32F411E-DISCO microcontroller (based on the STM32F411VET6), the SRAM (Static RAM) is located in the memory map of the Cortex-M4 core. Here's a detailed breakdown:
STM32F411VET6 SRAM Memory Layout
The STM32F411 has 128 KB of SRAM, split into different regions:
SRAM Block | Address Range | Size | Purpose |
---|---|---|---|
SRAM1 | 0x2000 0000 - 0x2001 FFFF | 112 KB | Main system RAM (fastest access) |
SRAM2 | 0x2002 0000 - 0x2002 3FFF | 16 KB | Secondary RAM (slower bus) |
Key Notes:
SRAM1 (112 KB)
Primary RAM for data, stack, and heap.
Connected to the Cortex-M4 bus matrix for fast CPU/peripheral access.
SRAM2 (16 KB)
Can be used for additional data storage or DMA buffers.
Slightly slower access than SRAM1 (attached to a different bus).
Additional Memory Regions
Flash Memory:
0x0800 0000 - 0x080F FFFF
(512 KB, stores firmware).Peripherals:
0x4000 0000 - 0x5FFF FFFF
(registers for GPIO, UART, etc.).Core Coupled Memory (CCM): Not present in STM32F411 (unlike STM32F4xx "CCM-RAM" models).
How to Verify SRAM in Code
You can check SRAM usage by analyzing the linker script (.ld
file) or inspecting the compiler map file.
Example (STM32CubeIDE linker script snippet):
MEMORY { RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 112K RAM2 (xrw) : ORIGIN = 0x2001C000, LENGTH = 16K }
Practical Implications
Stack/Heap Allocation: By default, the linker places these in SRAM1.
DMA Optimization: Use SRAM2 for DMA buffers to free up SRAM1.
Critical Data: Place frequently accessed variables in SRAM1 for speed.
Checking SRAM Usage at Runtime
Add this to your code to monitor free SRAM (crude method):
extern int _estack, _sheap; // Defined in linker script void CheckFreeRAM() { int free_ram = (int)&_estack - (int)&_sheap; printf("Free SRAM: %d bytes\n", free_ram); }
Summary
SRAM1 (112 KB): Primary workspace (
0x2000 0000
).SRAM2 (16 KB): Auxiliary storage (
0x2002 0000
).No CCM-RAM in STM32F411.
评论
发表评论