Module 3

Memory & Map

Where code lives and variables die. Understanding the Von Neumann architecture, Endianness, and the Map.

memory CPU
Unified Bus
grid_4x4 Memory
Code + Data

The Endianness Wars

How do we store a 16-bit word (`0xABCD`) into 8-bit memory cells?

Interactive Lab
High (MSB) Low (LSB)
Memory (RAM)
0x0200
34
Address N
0x0201
12
Address N+1
MSP430 uses Little Endian: Lower byte goes to lower address.

Little Endian wins here

  • 1 Little Endian (Intel, MSP430, ARM) Least Significant Byte (LSB) goes first. It may look backwards to humans, but it's efficient for 8-bit math processing.
  • 2 Big Endian (Network, PowerPC) Most Significant Byte (MSB) goes first. It reads naturally like English numbers ("One Thousand" -> 1000).
Warning: If you send binary data over UART/WiFi to a server (Big Endian), your numbers might arrive flipped! `0x1234` becomes `0x3412`.

The Dual Nature: Volatile vs Non-Volatile

bolt

SRAM

Fast & Volatile
0xCAFE
Power ON
  • Fast access (1 cycle).
  • Volatile: Data dies without power.
  • • Used for: Variables Stack
save

FRAM

Non-Volatile
0xBEEF
Power ON
  • Non-Volatile: Remembers forever.
  • FRAM: Ultra-fast writes (no erase cycle needed), unlike Flash.
  • • Endurance: ~1015 cycles (essentially infinite).
  • • Used for: Code Constants

How to talk to Hardware?

Two philosophies for connecting peripherals (I/O) to the CPU.

security Separate I/O (Port-Mapped)

Common in Intel x86 & old systems.

  • check Safer: User programs can't accidentally touch hardware. requires OS "Superuser" mode.
  • close Complex: Needs special instructions (`IN`, `OUT`) and extra control lines.
MSP430 Way

map Memory Mapped I/O

Common in ARM, RISC, & MSP430.

  • check Simple: Use standard `MOV` instructions to control hardware. No new opcodes!
  • check Efficient: Great for small microcontrollers without complex OS modes.
  • warning Riskier: A pointer bug could accidentally turn off a motor or overwrite a port.
Same task: "Read the value of Port 1"
Port-Mapped (x86) — special instructions
MOV DX, 0x0200 ; port address
IN AL, DX ; special I/O instruction
Requires dedicated I/O bus & privilege level
Memory-Mapped (MSP430) — just MOV
MOV.B &P1IN, R4 ; same instruction as RAM!
P1IN is just an address (0x0200). No special bus needed.

The Memory Map

The MSP430FR6989 has a linear 64KB address space. Scroll to explore.

High Addr 0xFFFF 16-bit
Vectors
FRAM (Code)
Unused (Gap)
RAM (Data)
Info Mem
BSL
Peripherals (SFR)
SFR
Low Addr 0x0000 0 KB
touch_app

Click on a memory region to see details.