Module 11 · ClosingMódulo 11 · Cierre

System Modules: Clock, Power & LCDMódulos del sistema: reloj, alimentación y LCD

The background systems that keep the CPU fed, timed, and visible. Los sistemas de fondo que mantienen la CPU alimentada, sincronizada y visible.

Santi Scagliusi, PhD

Four systems behind the CPUCuatro sistemas detrás de la CPU

The CPU runs instructions. These keep it powered, ticking, supervised, and on-screen.La CPU ejecuta instrucciones. Estos la mantienen alimentada, en marcha, supervisada y en pantalla.

schedule
CS

Clock system. Generates MCLK, SMCLK and ACLK.Sistema de reloj. Genera MCLK, SMCLK y ACLK.

battery_charging_full
PMM

Power management. Makes VCORE, supervises the supply.Gestión de energía. Genera VCORE y supervisa la alimentación.

pets
WDT

Watchdog. Resets the chip if software hangs.Watchdog. Reinicia el chip si el software se cuelga.

grid_view
LCD_C

LCD controller. Drives the 6-digit segment display.Controlador LCD. Maneja el display de segmentos de 6 dígitos.

Three system clocks, three customersTres relojes del sistema, tres clientes

One clock system fans out to the CPU and two classes of peripheral.Un sistema de reloj se reparte a la CPU y a dos clases de periférico.

CS 0x0160 MCLK CPU + systemCPU + sistema SMCLK fast peripheralsperiféricos rápidos ACLK slow / low-powerlento / bajo consumo

Where the ticks come fromDe dónde salen los pulsos

Three oscillators feed the clock system. Each sits at a different point on the frequency line.Tres osciladores alimentan el sistema de reloj. Cada uno cae en un punto distinto de la recta de frecuencias.

VLO ~10 kHz internal, ultra-low-powerinterno, consumo mínimo LFXT 32768 Hz watch crystal, precisecristal de reloj, preciso DCO 1–24 MHz on-chip, selectableinterno, seleccionable 10 kHz 32 kHz MHz faster →más rápido → REFO, MODOSC and HFXT round out the set.REFO, MODOSC y HFXT completan el conjunto.

The clock tree you get for freeEl árbol de relojes que obtienes gratis

After reset each signal is already bound to a source. You only touch CS to change it.Tras el reset cada señal ya está ligada a una fuente. Solo tocas CS para cambiarlo.

DCO ~1 MHz REFO 32.768 kHz LFXT (Y1) wired, disabledconectado, off MCLK CPUCPU SMCLK fast periph.perif. rápidos ACLK low-powerbajo consumo

ACLK runs on REFO, not the crystal. Software must enable LFXT to use Y1.ACLK corre con REFO, no con el cristal. El software debe habilitar LFXT para usar Y1.

CS registers are password protectedLos registros de CS están protegidos por contraseña

A wrong write to CSCTL0 triggers a reset. You unlock first, then configure.Una escritura incorrecta en CSCTL0 provoca un reset. Primero desbloqueas, luego configuras.

CS register block · base 0x0160Bloque de registros CS · base 0x0160
CSCTL00x0160 · passwordcontraseña
CSCTL10x0162 · DCO
CSCTL20x0164 · sourcesfuentes
CSCTL30x0166 · dividersdivisores
CSCTL40x0168 · osc enableosc enable
Enable the watch crystalHabilitar el cristal de reloj
BIS.B #BIT4, &PJSEL0     ; PJ.4 = LFIN
MOV.B #0A5h, &CSCTL0_H   ; unlock, key = 0xA5
BIC.W #LFXTOFF, &CSCTL4 ; turn LFXT on
CSCTL0 · 16-bit registerregistro de 16 bits
0xA5
high byte · keybyte alto · clave
0x00
low byte · statusbyte bajo · estado

The key 0xA5 in the high byte opens the block.La clave 0xA5 en el byte alto abre el bloque.

Why 32768 HzPor qué 32768 Hz

It is 215. Fifteen divide-by-2 stages land exactly on 1 Hz.Es 215. Quince etapas de dividir entre 2 caen exactamente en 1 Hz.

32768 Hz ÷2 16384 ÷2 8192 ··· 15 stages15 etapas ··· 2 ÷2 1 Hz
timer

A 15-bit counter overflows once per second. That is the heartbeat of a clock.Un contador de 15 bits desborda una vez por segundo. Ese es el latido de un reloj.

PMM: supply in, core outPMM: entra alimentación, sale el núcleo

An LDO makes VCORE from DVCC. A supervisor watches the rail and resets on a droop.Un LDO genera VCORE desde DVCC. Un supervisor vigila la línea y resetea ante una caída.

DVCC 1.8–3.6 V LDO regulatorregulador VCORE CPU + memoryCPU + memoria SVS + BOR below ~1.8 V → hold / restart cleanpor debajo de ~1.8 V → reset limpio

After power-up or LPMx.5, unlock the pins with bic.b #LOCKLPM5, &PM5CTL0.Tras el encendido o LPMx.5, desbloquea los pines con bic.b #LOCKLPM5, &PM5CTL0.

Sleep is four bits inside SRDormir son cuatro bits dentro del SR

These bits in the status register choose how much of the chip keeps running.Estos bits del registro de estado eligen cuánta parte del chip sigue en marcha.

SR (R2) · bits 8–0bits 8–0
V
8
SCG1
7
SCG0
6
OSC
5
CPU
4
GIE
3
N
2
Z
1
C
0
■ clock / CPU off bits■ bits de apagado de reloj / CPU ■ GIE (wake source)■ GIE (fuente de despertar)
BIS.W #GIE|LPM3, SR
LPM3 bits = 0x00D0bits LPM3 = 0x00D0

One instruction sets the bits and the CPU stops. An interrupt wakes it; RETI restores the mode.Una instrucción pone los bits y la CPU se detiene. Una interrupción la despierta; RETI restaura el modo.

The low-power ladderLa escalera de bajo consumo

Each rung down turns off more clocks and drops the current further.Cada peldaño apaga más relojes y baja más la corriente.

ActiveActivo CPU + MCLK on, ACLK onCPU + MCLK on, ACLK on ~100 µA/MHz
LPM0 CPU + MCLK off, ACLK onCPU + MCLK off, ACLK on ~50 µA
LPM3 only ACLK on, RTC-capablesolo ACLK on, permite RTC ~0.9 µA
LPM4 all clocks off, wake on interrupttodos los relojes off, despierta por interrupción ~0.4 µA
LPM4.5 regulator off, no RAM retentionregulador off, sin retención de RAM ~0.02 µA

More awake · higher current ← → less awake · lower currentMás despierto · más corriente ← → menos despierto · menos corriente

The watchdog counts toward a resetEl watchdog cuenta hacia un reset

It runs unless software clears it. Reach the end and the chip resets.Corre salvo que el software lo borre. Llega al final y el chip se reinicia.

Stop itDetenerlo
Pet itAcariciarlo
Let it runDejarlo correr
RESET ⟲RESET ⟲
MOV.W #WDTPW|WDTHOLD, &WDTCTL

Stop it. First line of most examples. Key 0x5A, WDTHOLD = BIT7.Detenerlo. Primera línea de casi todo ejemplo. Clave 0x5A, WDTHOLD = BIT7.

MOV.W #WDTPW|WDTCNTCL, &WDTCTL

Pet it. Clear the counter on a healthy loop so it never reaches the cliff.Acariciarlo. Borra el contador en un bucle sano para que nunca llegue al borde.

LCD_C drives the 6-digit displayLCD_C maneja el display de 6 dígitos

A dedicated controller paints segments with no CPU work once it is set up.Un controlador dedicado pinta segmentos sin trabajo de CPU una vez configurado.

A1A2A3

Six alphanumeric digits, labelled A1 to A6.Seis dígitos alfanuméricos, etiquetados de A1 a A6.

0x0A00 control registers (LCDCCTL0…)registros de control (LCDCCTL0…)
LCDMx display memory, one byte per digitmemoria de display, un byte por dígito

Up to 320 segments, refreshed on the controller's own clock.Hasta 320 segmentos, refrescados con el reloj del propio controlador.

One byte lights the segmentsUn byte enciende los segmentos

Each bit of the LCDMx byte switches one segment on or off.Cada bit del byte LCDMx enciende o apaga un segmento.

LCDMx = 0x6D
shows a "5"muestra un "5"
Segment byte · bit per segmentByte de segmento · un bit por segmento
DP
g
f
e
d
c
b
a
0
1
1
0
1
1
0
1

Set up LCD_C once (LCDCCTL0) and enable the pins (LCDCPCTLx). After that, writing the byte is the whole job.Configura LCD_C una vez (LCDCCTL0) y habilita los pines (LCDCPCTLx). Después, escribir el byte es todo el trabajo.

The exact LCDMx-to-digit map is board-specific, and the simulator does not model the LCD. This one we read on real hardware.El mapa exacto de LCDMx a dígito es propio de la placa, y el simulador no modela el LCD. Este lo vemos en hardware real.

Where this course took youHasta dónde te llevó este curso

From a single bit to a whole microcontroller, twelve modules.De un solo bit a un microcontrolador completo, doce módulos.

0–4
The coreEl núcleo

Bits, registers, addressing modes, instructions and formats.Bits, registros, modos de direccionamiento, instrucciones y formatos.

5–8
Memory and I/OMemoria y E/S

Memory map, assembly with C, interrupts and power, digital I/O.Mapa de memoria, ensamblador con C, interrupciones y energía, E/S digital.

YOU ARE HEREESTÁS AQUÍ
9–11
PeripheralsPeriféricos

Timers, cooperative multitasking, and the system modules.Temporizadores, multitarea cooperativa y los módulos del sistema.

Three ideas to close onTres ideas para cerrar

The system modules, in three lines.Los módulos del sistema, en tres líneas.

CS

One tree, three clocks.Un árbol, tres relojes.

MCLK for the CPU, SMCLK for fast peripherals, ACLK for low-power ones.MCLK para la CPU, SMCLK para periféricos rápidos, ACLK para los de bajo consumo.

µA

Sleep is the default.Dormir es lo normal.

PMM keeps it powered, LPM turns clocks off, the watchdog catches hangs.El PMM la alimenta, los LPM apagan relojes, el watchdog atrapa cuelgues.

LCD

Peripherals do the work.Los periféricos hacen el trabajo.

Set up LCD_C once and it paints segments on its own. That is the whole point.Configura LCD_C una vez y pinta segmentos solo. Ese es todo el sentido.