The Cortex-M3 is an ARM processor core that is targeted for microcontroller applications. It has a flexible memory system that allows designers to customize the amount of memory included based on their specific needs.
The Cortex-M3 core itself does not contain any on-chip memory. All memory used by a Cortex-M3 system is external to the processor core. This allows system designers flexibility in choosing the right type and amount of memory for their application requirements.
There are several memory regions that can be connected to the Cortex-M3 processor:
- Flash memory – This non-volatile memory is used for storing code and constant data. The flash memory size can vary from 32KB to several MB depending on the microcontroller implementation.
- RAM – Volatile memory used for storing temporary data, variables, stack, and heap. RAM sizes can range from 4KB to over 100KB.
- ROM – Some microcontroller implementations may include a small read-only memory region for boot code or critical data storage.
The Cortex-M3 has a flexible memory map that allows up to 16 memory regions to be defined. Each region can be sized independently based on the external memory implemented in the system. The memory map includes:
- Code memory – Stores program code.
- SRAM – General purpose RAM for data storage.
- Peripheral registers – Memory mapped registers for on-chip peripherals.
- External memory – Additional external memory areas.
The processor uses different bus interfaces optimized for each type of memory. This allows concurrent access to internal and external memories in an efficient manner.
Memory Protection Unit
The Cortex-M3 includes an optional Memory Protection Unit (MPU) which can be used to set access permissions for memory regions. This can help increase reliability and security by preventing accidental or unauthorized access to critical code and data sections.
The MPU allows setting read, write and execute permissions on a per-region basis. Up to 8 protected regions can be defined. Using the MPU allows creating a robust memory map tailored for the specific application requirements.
Memory Sizes in Example Chips
Here are some examples of Cortex-M3 chips showing the memory sizes implemented:
- STM32F103xx – Flash from 16KB to 128KB, SRAM from 6KB to 20KB
- LPC1768 – 512KB Flash, 64KB SRAM
- Atmel SAM3X8E – 512KB Flash, 96KB SRAM
- TI LM3S1968 – 256KB Flash, 64KB SRAM
As can be seen, memory sizes can vary substantially across different microcontroller products. The flexibility of the Cortex-M3 architecture allows tailoring the memory configuration to meet the needs of diverse applications in different markets.
Factors Affecting Memory Size
Several factors influence the memory size implemented in a Cortex-M3 system:
- Cost – More memory increases microcontroller cost. So memory size is optimized to fulfill application requirements while minimizing cost.
- Power – Larger memories consume more power. Low power designs may limit memory size to save power.
- Chip size – Adding more memory takes up silicon area and increases chip size. There is a tradeoff between features, cost and chip size.
- Performance – Additional memory may be added to meet processing speed and real-time requirements of applications.
By carefully taking into account these factors, chip designers can create optimized Cortex-M3 products with memory sizes tailored for embedded applications in various markets like automotive, industrial, consumer and medical.
Optimizing Memory Usage
Even with memory size constraints, developers can optimize Cortex-M3 applications to make the best use of the available memory through techniques like:
- Efficient coding to minimize code size.
- Using compiler optimizations to reduce data usage.
- Allocating frequently used data to SRAM.
- Placing less critical data and code in external memories.
- Using hardware peripherals to offload tasks from the processor.
Proper use of the Cortex-M3 memory architecture and optimization strategies allows building full-featured and robust applications even when working with low-cost microcontrollers with limited on-chip memory.
The Cortex-M3 is designed to provide a flexible memory system that can be customized for diverse embedded applications in different markets. While the core itself does not contain any memory, the external memory regions can be sized based on specific application requirements and tradeoffs between cost, power, size and performance. Real-world microcontroller implementations feature memories ranging from just a few KB up to hundreds of KB. With careful optimization, even limited on-chip memory can enable powerful applications based on the capable Cortex-M3 processor.