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
A seconds clock on the LCD, CPU asleep 99% of the time.Un reloj de segundos en el LCD, con la CPU dormida el 99% del tiempo.
reloj bis.w #LPM3|GIE, SR ; 1 s clrc dadd.b #1, R10 ; BCD cmp.b #0x60, R10 jne mostrar clr.w R10 ; 59→00 mostrar call #pintar jmp reloj
00 → 59 → 00 on the two right digits. 32768 Hz crystal, ACLK/8, CCR0 = 4095.00 → 59 → 00 en los dos dígitos de la derecha. Cristal de 32768 Hz, ACLK/8, CCR0 = 4095.
Which clock keeps running while the CPU sleeps?¿Qué reloj sigue vivo mientras la CPU duerme?
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.
Clock system. Generates MCLK, SMCLK and ACLK.Sistema de reloj. Genera MCLK, SMCLK y ACLK.
Power management. Makes VCORE, supervises the supply.Gestión de energía. Genera VCORE y supervisa la alimentación.
Watchdog. Resets the chip if software hangs.Watchdog. Reinicia el chip si el software se cuelga.
LCD controller. Drives the 6-digit segment display.Controlador LCD. Maneja el display de segmentos de 6 dígitos.
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.
Three oscillators, three points on the frequency line.Tres osciladores, tres puntos en la recta de frecuencias.
After reset every clock already has a source.Tras el reset cada reloj ya tiene una fuente.
ACLK asks for LFXT. Until you enable it, ACLK falls back to LFMODOSC.ACLK pide LFXT. Hasta que lo habilitas, ACLK cae a LFMODOSC.
BIS.B #BIT4, &PJSEL0 ; PJ.4 = LFXIN MOV.B #0A5h, &CSCTL0_H ; unlock BIC.W #LFXTOFF, &CSCTL4 ; LFXT on wait BIC.W #LFXTOFFG, &CSCTL5 ; clear fault BIC.W #OFIFG, &SFRIFG1 BIT.W #OFIFG, &SFRIFG1 JNZ wait ; until stable BIC.W #SELA_7, &CSCTL2 ; ACLK = LFXT MOV.B #0, &CSCTL0_H ; lock
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.
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.
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.
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.
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.
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.
R11 = loop turns. R10 = interrupts.R11 = vueltas del bucle. R10 = interrupciones.
bucle inc.w R11
bis.w #LPM3|GIE, SR ; dormir
nop
jmp bucle
TA00ISR inc.w R10
bic.w #LPM3, 0(SP) ; despertar
reti
With LPM3, R11 = R10 + 1. Replace the bis with nop: R11 explodes.Con LPM3, R11 = R10 + 1. Cambia el bis por nop: R11 se dispara.
Without bic #LPM3, 0(SP), how many times does the loop turn?Sin bic #LPM3, 0(SP), ¿cuántas vueltas da el bucle?
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.
More awake · higher current ← → less awake · lower currentMás despierto · más corriente ← → menos despierto · menos corriente
Clear it in time, or the chip resets.Bórralo a tiempo, o el chip se reinicia.
Stop it. First line of most examples. Key 0x5A, WDTHOLD = BIT7.Detenerlo. Primera línea de casi todo ejemplo. Clave 0x5A, WDTHOLD = BIT7.
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.
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.
Six digits, A1 to A6.Seis dígitos, de A1 a A6.
14-segment digits: A1 lives in LCDM10 + LCDM11.Dígitos de 14 segmentos: A1 vive en LCDM10 + LCDM11.
Each bit switches one segment.Cada bit enciende un segmento.
Middle bar = two halves, G and M. Diagonals and DP live in LCDM11.Barra central = dos mitades, G y M. Diagonales y DP viven en LCDM11.
LaunchPad map. The simulator does not model the LCD: try it on the board.Mapa de la LaunchPad. El simulador no modela el LCD: pruébalo en la placa.
Six bytes, six digits.Seis bytes, seis dígitos.
call #lcdInit
mov.b #0x60, &LCDM10 ; 1
mov.b #0xDB, &LCDM6 ; 2
mov.b #0xF3, &LCDM4 ; 3
mov.b #0x67, &LCDM19 ; 4
mov.b #0xB7, &LCDM15 ; 5
mov.b #0xBF, &LCDM8 ; 6
Digit order on the LaunchPad does not follow LCDM order.El orden de los dígitos en la LaunchPad no sigue el orden de LCDMx.
Which byte turns the 6 into an 8?¿Qué byte convierte el 6 en un 8?
From a single bit to a whole microcontroller, twelve modules.De un solo bit a un microcontrolador completo, doce módulos.
Bits, registers, addressing modes, instructions and formats.Bits, registros, modos de direccionamiento, instrucciones y formatos.
Memory map, assembly with C, interrupts and power, digital I/O.Mapa de memoria, ensamblador con C, interrupciones y energía, E/S digital.
Timers, cooperative multitasking, and the system modules.Temporizadores, multitarea cooperativa y los módulos del sistema.
The system modules, in three lines.Los módulos del sistema, en tres líneas.
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.
PMM keeps it powered, LPM turns clocks off, the watchdog catches hangs.El PMM la alimenta, los LPM apagan relojes, el watchdog atrapa cuelgues.
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.