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 BlockAddress RangeSizePurpose
SRAM10x2000 0000 - 0x2001 FFFF112 KBMain system RAM (fastest access)
SRAM20x2002 0000 - 0x2002 3FFF16 KBSecondary RAM (slower bus)

Key Notes:

  1. SRAM1 (112 KB)

    • Primary RAM for data, stack, and heap.

    • Connected to the Cortex-M4 bus matrix for fast CPU/peripheral access.

  2. 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 Memory0x0800 0000 - 0x080F FFFF (512 KB, stores firmware).

  • Peripherals0x4000 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):

ld
MEMORY
{
  RAM (xrw)  : ORIGIN = 0x20000000, LENGTH = 112K
  RAM2 (xrw) : ORIGIN = 0x2001C000, LENGTH = 16K
}

Practical Implications

  1. Stack/Heap Allocation: By default, the linker places these in SRAM1.

  2. DMA Optimization: Use SRAM2 for DMA buffers to free up SRAM1.

  3. 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):

c
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.

评论

此博客中的热门博文

How To Connect Stm32 To PC?

What are the common HDL languages used in FPGA design?

How do you set up ADC (Analog-to-Digital Converter) in STM32?