A counter in hardware that keeps time so the CPU does not have to. Un contador en hardware que mide el tiempo para que la CPU no tenga que hacerlo.
Santi Scagliusi, PhD
Same wait. One way burns the CPU through it, the other sleeps.La misma espera. Una forma quema la CPU durante ella, la otra duerme.
The timer decides whether the chip burns milliamps or microamps while it waits. El timer decide si el chip quema miliamperios o microamperios mientras espera.
Four Timer_A instances plus one Timer_B. All 16-bit up-counters.Cuatro instancias de Timer_A más un Timer_B. Todos contadores ascendentes de 16 bits.
All five share the same programming model. Learn TA0 and the rest follow. Los cinco comparten el mismo modelo de programación. Aprende TA0 y el resto se deduce.
A clock feeds a divider, which feeds the 16-bit counter TAxR. The mode decides how it counts.Un reloj alimenta un divisor, que alimenta el contador de 16 bits TAxR. El modo decide cómo cuenta.
Every one of these choices is a field of a single register: TAxCTL. Cada una de estas elecciones es un campo de un solo registro: TAxCTL.
Pick a source, a divider and a mode, OR them together, store once.Elige fuente, divisor y modo, los unes con OR, y escribes una vez.
Field MC selects the shape of TAxR over time.El campo MC selecciona la forma de TAxR en el tiempo.
Halted. The counter holds.Detenido. El contador no avanza.
0 to CCR0, then 0. Sets the period.0 a CCR0, luego 0. Fija el periodo.
0 to 0xFFFF, then 0. Free running.0 a 0xFFFF, luego 0. Cuenta libre.
Up to CCR0, then back down. Symmetric.Sube a CCR0, luego baja. Simétrico.
Up mode is the workhorse: CCR0 is the period, the rest is timing inside it. El modo Up es el caballo de batalla: CCR0 es el periodo, lo demás es temporizar dentro de él.
Each channel watches the counter for one value and acts when it matches.Cada canal vigila el contador buscando un valor y actúa cuando coincide.
Sets the period and owns its own interrupt vector.Fija el periodo y tiene su propio vector de interrupción.
Extra compare points inside the same period: a PWM edge or a second event.Puntos de comparación extra dentro del periodo: un flanco PWM o un segundo evento.
CCR0 gets a private vector. Everything else shares one and is decoded by TAxIV.CCR0 tiene un vector privado. Todo lo demás comparte uno y se decodifica con TAxIV.
CCIFG: a compare matched. TAIFG: the counter rolled over. CCIFG: coincidió una comparación. TAIFG: el contador se desbordó.
Toggle an output at a visible rate from ACLK. The only real work is picking CCR0.Conmutar una salida a un ritmo visible desde ACLK. El único trabajo real es elegir CCR0.
Integer division drops the remainder: that is the source of the small frequency error.La división entera descarta el resto: ese es el origen del pequeño error de frecuencia.
The hardware toggles the pin and raises the IRQ. The ISR can be empty.El hardware conmuta el pin y lanza la IRQ. La ISR puede estar vacía.
Compare drives an event at a known time. Capture records the time of an external event.Comparación provoca un evento en un instante conocido. Captura registra el instante de un evento externo.
CM picks the edge, CCIS picks the input. The captured number is just TAxR frozen. CM elige el flanco, CCIS elige la entrada. El número capturado es simplemente TAxR congelado.
Up mode plus reset/set output: CCR0 is the period, CCR1 is the duty cycle. No CPU involved.Modo Up más salida reset/set: CCR0 es el periodo, CCR1 es el ciclo de trabajo. Sin CPU.
CCR1 sets the pulse width. The brightness of an LED, fixed by one register. CCR1 fija la anchura del pulso. El brillo de un LED, fijado por un registro.
Up mode, ACLK, toggle output, periodic IRQ on CCR0. The ISR returns immediately.Modo Up, ACLK, salida en conmutación, IRQ periódica en CCR0. La ISR vuelve enseguida.
In the Timer_A panel, TA0R ramps 0 to CCR0, CCIFG sets, the CCR0 ISR runs, then it repeats.En el panel Timer_A, TA0R sube de 0 a CCR0, se activa CCIFG, corre la ISR de CCR0 y se repite.
CCR1 and CCR2 share the second vector. The ISR reads the flag, clears it and re-arms.CCR1 y CCR2 comparten el segundo vector. La ISR lee la bandera, la borra y la re-arma.
In the Timer_A panel, TA0R runs free. CCR1 fires every 30 ticks, CCR2 every 50, both through the same ISR.En el panel Timer_A, TA0R corre libre. CCR1 dispara cada 30 ticks, CCR2 cada 50, ambos por la misma ISR.
The ISR re-arms each channel by adding its period, so the matches keep repeating.La ISR re-arma cada canal sumando su periodo, así las coincidencias se repiten.
8-bit PWM on P1.0 / TA0.1. The timer drives the output by itself, the CPU is free.PWM de 8 bits en P1.0 / TA0.1. El timer mueve la salida solo, la CPU queda libre.
Click LaunchPad, Run. TA0R counts to 255; the P1.0 output goes high at CCR0 and low at CCR1, no ISR at all.Pulsa LaunchPad, Run. TA0R cuenta hasta 255; la salida P1.0 sube en CCR0 y baja en CCR1, sin ninguna ISR.
A timer is a counter the CPU configures once and then forgets.Un temporizador es un contador que la CPU configura una vez y luego olvida.
Source, divider and mode are all fields of TAxCTL, written in one instruction.Fuente, divisor y modo son campos de TAxCTL, escritos en una instrucción.
Compare turns time into events and PWM. Capture turns events into timestamps.Comparar convierte el tiempo en eventos y PWM. Capturar convierte eventos en marcas de tiempo.
Everything else shares the second vector, decoded by TAxIV. CCIFG vs TAIFG.Todo lo demás comparte el segundo vector, decodificado por TAxIV. CCIFG vs TAIFG.