Module 5Módulo 5

Memory and architectureMemoria y arquitectura

Where MSP430 code, data and peripherals actually live, and the rules that govern that space. Dónde viven realmente el código, los datos y los periféricos del MSP430, y las reglas de ese espacio.

Santi Scagliusi, PhD

No single memory wins on everythingNinguna memoria gana en todo

Cut the power and watch which one forgets.Corta la energía y mira cuál olvida.

SRAM
volatilevolátil
0xCAFE
FRAM
non-volatileno volátil
0xBEEF

The real question is the lifetime of the data, not which memory is best. La pregunta real es cuánto debe vivir el dato, no qué memoria es mejor.

Two memories on the FR6989Dos memorias en el FR6989

128 KB FRAM and 2 KB SRAM, side by side in one chip.128 KB de FRAM y 2 KB de SRAM, juntas en un mismo chip.

bolt

SRAM

2 KB · 0x1C00–0x23FF
Volatile, fast to writeVolátil, rápida de escribir
Variables, buffers, the stackVariables, buffers, la pila
save

FRAM

128 KB · 0x4400–0xFFFF
Non-volatile, kept without powerNo volátil, se conserva sin energía
Code, constants, interrupt vectorsCódigo, constantes, vectores

FRAM writes a byte, Flash erases a sectorLa FRAM escribe un byte, la Flash borra un sector

Write one cell in each. Watch what the technology has to touch.Escribe una celda en cada una. Mira qué toca cada tecnología.

FRAM
one byte, in placeun byte, en el sitio

Write the target cell directly.Escribe la celda objetivo directo.

Flash
erase the sector, then writeborrar el sector, luego escribir

The whole sector erases first.Primero se borra el sector entero.

~1015 writes, byte-addressable. Reading is destructive, so the controller rewrites the cell for you. ~1015 escrituras, direccionable por byte. Leer es destructivo, así que el controlador reescribe la celda por ti.

Where each thing belongsDónde va cada cosa

Lifetime decides the region. Two bands on the same address column.El ciclo de vida decide la región. Dos bandas en la misma columna de direcciones.

FRAM 0x4400–0xFFFF
Program codeCódigo
ConstantsConstantes
Retained dataDatos retenidos

Written rarely, survives every reset.Se escribe poco, sobrevive a cada reset.

other regions: ROM, info, peripheralsotras regiones: ROM, info, periféricos
SRAM 0x1C00–0x23FF
VariablesVariables
The stackLa pila
BuffersBuffers

Changes constantly, can be lost on reset.Cambia sin parar, puede perderse en el reset.

Von Neumann: one shared busVon Neumann: un solo bus compartido

Code, data and peripherals share a single address space and one bus to reach it.Código, datos y periféricos comparten un único espacio de direcciones y un solo bus para llegar.

CPU
MAB · one address + data busun bus de direcciones + datos · MDB
one unified memory spaceun espacio de memoria unificado
codecódigo
FRAM
datadatos
SRAM
I/O
MMIO

One instruction set reaches everywhere. The cost: fetch and data access share the same bus. Un solo juego de instrucciones llega a todo. El coste: el fetch y el acceso a datos comparten el bus.

A peripheral is just an addressUn periférico es solo una dirección

The same MOV that touches RAM can change a real pin.El mismo MOV que toca la RAM puede cambiar un pin real.

MOV.B #BIT0, &P1DIR
P1.0 becomes an output.P1.0 pasa a ser salida.
BIS.B #BIT0, &P1OUT
Drive the pin high.Forzar el pin a nivel alto.

Set the direction register first. Writing P1OUT only lights the LED once the pin is an output.Primero fijá el registro de dirección. Escribir P1OUT solo enciende el LED cuando el pin ya es salida.

&P1DIR0x00
&P1OUT0x00
P1.0input / offentrada / apagado
P1OUT @ 0x0202

This is the bridge into the I/O, timer and interrupt modules: those are all just addresses on this same map. Este es el puente hacia los módulos de E/S, timers e interrupciones: todos son direcciones de este mismo mapa.

Endianness is byte order, not valueEl endianness es orden de bytes, no valor

Same word 0x1234, two ways to lay its bytes in memory.La misma palabra 0x1234, dos formas de ordenar sus bytes.

Big-endian MSB at the lower addressMSB en la dirección más baja
0x1C00
12
0x1C01
34
Little-endian LSB at the lower address · MSP430LSB en la dirección más baja · MSP430
0x1C00
34
0x1C01
12

The number never changes, only the order of its bytes across consecutive cells. El número no cambia, solo el orden de sus bytes en celdas consecutivas.

A word, byte by byte in memoryUna palabra, byte a byte en memoria

.word 0x1234 at 0x1C00 splits into two bytes, low byte first..word 0x1234 en 0x1C00 se parte en dos bytes, primero el bajo.

source wordpalabra fuente
high bytebyte alto
12
low bytebyte bajo
34

The low byte lands at the lower address, 0x1C00. The high byte follows at 0x1C01.El byte bajo cae en la dirección más baja, 0x1C00. El alto le sigue en 0x1C01.

memory, addresses growing downmemoria, direcciones creciendo hacia abajo
0x1C00
34
0x1C01
12
read back word at 0x1C00releer palabra en 0x1C00 = 0x1234

Endianness in real systemsEndianness en sistemas reales

Same value 0x1234, where each platform puts the low byte.El mismo valor 0x1234, dónde pone cada plataforma el byte bajo.

MSP430 · x86
little-endian
low
34
high
12
ARM
bi-endian, runs LEbi-endian, corre LE
low
34
high
12
TCP/IP
big-endian
low
12
high
34

It only matters when bytes cross a boundary. Over UART, SPI or a link, agree the order explicitly. Solo importa cuando los bytes cruzan una frontera. Por UART, SPI o un enlace, acordá el orden de forma explícita.

The FR6989 memory mapEl mapa de memoria del FR6989

One 16-bit address space, from 0x0000 to 0xFFFF.Un espacio de direcciones de 16 bits, de 0x0000 a 0xFFFF.

0xFF80–0xFFFF
Interrupt vectorsVectores de interrupción 128 B · reset at 0xFFFE128 B · reset en 0xFFFE
0x4400–0xFF7F
Main FRAMFRAM principal code + constantscódigo + constantes
0x1C00–0x23FF
SRAM 2 KB · variables, stack2 KB · variables, pila
0x1800–0x1BFF
Info FRAM · TLV · boot ROMFRAM info · TLV · ROM de arranque calibration, device IDcalibración, ID del chip
0x1000–0x17FF
Bootloader (BSL ROM)Bootloader (ROM BSL) 2 KB
0x0100–0x0FFF
Peripherals (MMIO)Periféricos (MMIO) ports, timers, P1OUT @ 0x0202puertos, timers, P1OUT @ 0x0202
0x0000–0x00FF
Special function registersRegistros de función especial SFR · 256 B

Three addresses worth memorizingTres direcciones que conviene memorizar

Three nodes on the same address column, top is high.Tres nodos en la misma columna de direcciones, arriba lo alto.

0xFFFE Reset vectorVector de reset

On power-up the CPU reads here to find where the program begins.Al encender, la CPU lee aquí para saber dónde empieza el programa.

0x4400 Code startsEmpieza el código

Main FRAM holds your program and constants up to 0xFFFF.La FRAM principal guarda tu programa y constantes hasta 0xFFFF.

0x1C00 SRAM startsEmpieza la SRAM

Variables, buffers and the stack, in the 2 KB up to 0x23FF.Variables, buffers y la pila, en los 2 KB hasta 0x23FF.

Memory is the terrainLa memoria es el terreno

Three ideas to carry into the next modules.Tres ideas para llevar a los próximos módulos.

FRAM + SRAMFRAM + SRAM

Lifetime decides the placeEl ciclo de vida decide el lugar

Persistent code and constants in FRAM, fast-changing state in SRAM.Código y constantes persistentes en FRAM, estado cambiante en SRAM.

One spaceUn espacio

Code, data and I/O share itCódigo, datos y E/S lo comparten

Von Neumann. The same MOV reaches RAM or a real peripheral pin.Von Neumann. El mismo MOV llega a la RAM o a un pin real.

Byte orderOrden de bytes

Little-endian, low byte firstLittle-endian, byte bajo primero

A word splits into bytes; the value never changes, only the order.Una palabra se parte en bytes; el valor no cambia, solo el orden.