Module 1Módulo 1

General AspectsAspectos Generales

Before we write code, we must understand the machine. From basic logic gates to complex architectures. Antes de escribir código, debemos comprender la máquina. Desde puertas lógicas básicas hasta arquitecturas complejas.

Santi Scagliusi, PhD

Bits, Binary and HexBits, Binario y Hex

What a bit is. How we group them.Qué es un bit. Cómo los agrupamos.

BitBit

Smallest digital unit. Two states: 0 or 1.Unidad digital mínima. Dos estados: 0 o 1.

Nibble and ByteNibble y Byte

4 bits = nibble. 8 bits = byte. 1 hex digit = 4 bits.4 bits = nibble. 8 bits = byte. 1 dígito hex = 4 bits.

Why HexPor Qué Hex

Addresses and masks are easier to read in hex than in binary.Direcciones y máscaras se leen mejor en hex que en binario.

Same value, three representationsMismo valor, tres representaciones
BinaryBinario
1010
Decimal
10
Hex
0xA
0x4
0100
0x3
0011
0x0
0000
0x5
0101

Example: 0x4305 is easier to scan than 0100 0011 0000 0101.Ejemplo: 0x4305 es mucho más legible que 0100 0011 0000 0101.

Real World SignalsSeñales del Mundo Real

Under the 0s and 1s: real voltages, real limits. Bajo los 0 y 1: tensiones reales, límites reales.

show_chart Voltage = LogicTensión = Lógica

0/1 is an abstraction. Signals take time to rise and fall — in between, a forbidden region. 0/1 es una abstracción. Las señales tardan en subir y bajar — en medio, una región prohibida.

  • VCC (3.3V): Logic 1 (High)Lógica 1 (Alto)
  • Undefined:Indefinido: Unpredictable behaviorComportamiento impredecible
  • VSS (0V): Logic 0 (Low/GND)Lógica 0 (Bajo/GND)
Logic 1 (>2.0V)Lógica 1 (>2.0V)
Noise Margin / UndefinedMargen de Ruido / Indefinido
Logic 0 (<0.8V)Lógica 0 (<0.8V)

A Useful Gate: XORUna Puerta Útil: XOR

Output is 1 only when the inputs differ.La salida es 1 solo cuando las entradas difieren.

science Interactive XORXOR Interactivo

In assembly: toggle bits, clear registers, compare patterns. En assembly: alterna bits, limpia registros, compara patrones.

INTERACTIVE LABLABORATORIO INTERACTIVO
0 A 0 B XOR 0
TRUTH TABLETABLA DE VERDAD
Input AEntrada A Input BEntrada B Output (A^B)Salida (A^B)
000
011
101
110
Why it matters in assemblyPor qué importa en assembly
XOR R5, R5 ; clears R5; pone R5 a cero
XOR #0xFF, R4 ; flips all bits; invierte todos los bits

What are Embedded Systems?¿Qué son los Sistemas Embebidos?

A computer dedicated to one task. Not general purpose — built to do one thing well. Un ordenador dedicado a una tarea. No de propósito general — hecho para una cosa.

bolt Resource Constrained (Power, Memory)Recursos Limitados (Energía, Memoria)
timer Real-time RequirementsRequisitos de Tiempo Real
settings_input_component Direct Hardware InteractionInteracción Directa con el Hardware
local_laundry_service ControlControl Washing MachinesLavadoras
directions_car SafetySeguridad ABS / Airbags
router IoT Smart SensorsSensores Inteligentes
ecg_heart MedicalMédico PacemakersMarcapasos

Computer Building BlocksBloques de un Computador

Every computer — laptop or MSP430 — uses the same four actors.Todo computador — portátil o MSP430 — usa los mismos cuatro actores.

CPU

Registers, ALU, control. Executes instructions.Registros, ALU, control. Ejecuta instrucciones.

MemoryMemoria

Holds code and data. Often the bottleneck.Guarda código y datos. A menudo el cuello de botella.

I/OE/S

Interface with the outside world. Adapts CPU signals to peripherals.Interfaz con el mundo exterior. Adapta las señales de la CPU a los periféricos.

BusesBuses

The shared roads: addresses, data, control.Las carreteras compartidas: direcciones, datos, control.

Scales of IntegrationEscalas de Integración

From the first chips to microprocessors, microcontrollers and SoCs.De los primeros chips a microprocesadores, microcontroladores y SoCs.

1970s: The DawnAños 70: El Amanecer

Intel 4004 & TI TMS1000. The first "computers on a chip".Intel 4004 y TI TMS1000. Las primeras "computadoras en un chip".

1980s-90s: IntegrationAños 80-90: Integración

More peripherals (ADC, UART). 8-bit dominates (8051, PIC).Más periféricos (ADC, UART). Dominan los 8 bits (8051, PIC).

Now: Efficiency & PowerAhora: Eficiencia y Potencia

16/32-bit (MSP430, ARM). Low Power for battery devices.16/32 bits (MSP430, ARM). Bajo consumo para dispositivos con batería.

µP

MicroprocessorMicroprocesador

CPU only. Needs external RAM, Flash, I/O.Solo CPU. Necesita RAM, Flash, E/S externos.

x86, Ryzen
OUR FOCUSNUESTRO ENFOQUE
µC

MicrocontrollerMicrocontrolador

CPU + RAM + FRAM + Peripherals in one chip.CPU + RAM + FRAM + Periféricos en un solo chip.

MSP430, PIC
SoC

System on Chip

CPU + GPU + Radio + DSP. Extreme integration.CPU + GPU + Radio + DSP. Integración extrema.

M1, Snapdragon

Von Neumann vs HarvardVon Neumann vs Harvard

MicrocontrollerMicrocontrolador CPU I/OE/S MemoryMemoria PeripheralPeriférico SINGLE SHARED BUSBUS ÚNICO COMPARTIDO

Von Neumann ArchitectureArquitectura Von Neumann

MSP430. One bus for code and data. Simpler, but a bottleneck.MSP430. Un bus para código y datos. Simple, pero cuello de botella.

MicrocontrollerMicrocontrolador ProgramPrograma MemoryMemoria CPU I/OE/S DataDatos MemoryMemoria Periph.Perif. Instruction busBus de instrucciones Data busBus de datos

Harvard ArchitectureArquitectura Harvard

Separate code/data memories. Simultaneous access, more complex hardware.Memorias separadas. Acceso simultáneo, hardware más complejo.

Single Bus, Arbitration & DMABus Único, Arbitraje y DMA

Shared bus: only one transfer at a time.Bus compartido: solo una transferencia a la vez.

BUS CPU MASTER Memory I/O
BUS CPU 💤 DMA MASTER Memory I/O

I/O → Memory directly. No CPU needed.E/S → Memoria directo. Sin CPU.

RISC vs CISC

CISC

Complex Instruction Set Computer

Many complex instructions, variable length.Muchas instrucciones complejas, longitud variable.

Complex hardware. Fewer lines of code.Hardware complejo. Menos líneas de código.

Intel x86

MSP430

RISC

Reduced Instruction Set Computer

Few, simple instructions, fixed length.Pocas instrucciones simples, longitud fija.

Simple, fast hardware. Compiler does the heavy lifting.Hardware simple y rápido. El compilador hace el trabajo pesado.

MSP430, ARM, RISC-VMSP430, ARM, RISC-V

Same task: add two values in memoryMisma tarea: sumar dos valores en memoria
CISC: one complex instructionCISC: una instrucción compleja
ADD Param1, Param2
Reads, adds, and writes back in one.Lee, suma y escribe en una sola.
RISC: several simple instructionsRISC: varias instrucciones simples
MOV &Param1, R4 ; load first operand; cargar primer operando
MOV &Param2, R5 ; load second operand; cargar segundo operando
ADD R5, R4 ; ALU works on registers; la ALU trabaja sobre registros
MOV R4, &Param1 ; store result; guardar resultado

Pipeline: why microcontrollers are RISCPipeline: por qué los microcontroladores son RISC

IF=fetchbúsqueda · D=decodedecod. · E=executeejec. · M=memorymem. · WB=write backescrit.

Classic CISC — no pipelineCISC clásico — sin pipeline

8086, 68000
C1
C2
C3
C4
C5
C6
C7
C8
C9
C10
ADD [m1], [m2]
MUL AX, BX
MOV CX, [m3]

One finishes before the next starts. No overlap.Una termina antes de empezar la siguiente. Sin solapamiento.

3 instructions3 instrucciones 10 cyclesciclos

RISC — 5-stage pipelineRISC — pipeline de 5 etapas

MSP430, ARM, RISC-V
C1
C2
C3
C4
C5
C6
C7
C8
C9
C10
LD R1, [m1]
IF
D
E
M
WB
LD R2, [m2]
IF
D
E
M
WB
ADD R3, R1, R2
IF
D
E
M
WB
ST R3, [m1]
IF
D
E
M
WB
MUL R4, R1, R2
IF
D
E
M
WB

Same 5 stages for all. One new instruction per cycle.Mismas 5 etapas para todas. Una nueva por ciclo.

5 instructions5 instrucciones 9 cyclesciclos

More work in less time. Every microcontroller is RISC.Más trabajo en menos tiempo. Todo microcontrolador es RISC.

Operating SystemsSistemas Operativos

Managing resources so programs coexist.Gestionar recursos para que los programas coexistan.

Without OSSin SO
Your ProgramTu Programa manages EVERYTHINGgestiona TODO ← This course!← ¡Este curso!
With OSCon SO
App A App B App C OS
SchedulingPlanificación

Who gets CPU time. When to switch.Quién usa la CPU. Cuándo cambiar.

MemoryMemoria

Allocates and protects memory regions.Asigna y protege regiones de memoria.

StorageAlmacenamiento

Abstracts disks as files.Abstrae los discos como ficheros.

DevicesDispositivos

Drivers and standard interfaces.Drivers e interfaces estándar.

Multitasking ModelsModelos de Multitarea

Different ways to share CPU time.Formas distintas de compartir la CPU.

time →tiempo → A B C A B C yield yield yield yield yield

Each task voluntarily yields. If A hangs → everything freezes.Cada tarea cede voluntariamente. Si A se cuelga → todo se congela.

Windows 3.1, Classic Mac OS

A OS B OS C OS A OS timer interruptsinterrupciones de temporizador

OS forces context switches. No task can monopolize CPU.El SO fuerza cambios de contexto. Ninguna tarea monopoliza la CPU.

Windows 95+, Linux, macOS

CORE 0 CORE 1 Task A Task B Task C Task D

Tasks run truly simultaneously on different cores.Tareas realmente simultáneas en núcleos distintos.

Multicore CPUs, modern SoCsCPUs multinúcleo, SoCs modernos

B IRQ CRITICALCRÍTICO B A A

Guaranteed bounded latency. Deterministic, not just multitasking.Latencia acotada garantizada. Determinista, no solo multitarea.

FreeRTOS, VxWorks, QNX

Why the MSP430?¿Por qué el MSP430?

Why this chip for the course.Por qué este chip para el curso.

16-bit

The Goldilocks ZoneEl Punto Justo

8-bit too limited. 32-bit too complex. 16-bit fits for learning. 8 bits se queda corto. 32 bits complica. 16 bits es justo para aprender.

battery_charging_full

Ultra Low PowerUltra Bajo Consumo

Runs on batteries for years. Rich Low Power Modes (LPM). Funciona años con pilas. Modos de bajo consumo (LPM).

settings_remote

Modern PeripheralsPeriféricos Modernos

Timers, ADCs, and comms on-chip. Real-world ready. Timers, ADCs y comunicaciones en el chip. Listo para el mundo real.