Amctimer A
Amctimer A
The timer has four modes of operation, selected with the MCx bits:
Stop (MC = 0): The timer is halted. All registers, including TAR, retain
their values so that the timer can be restarted later where it left off.
Continuous (2): The counter runs freely through its full range from 0x0000
to 0xFFFF, at which point it overflows and rolls over back to 0. The period
is 2 ^6 = 65,536 counts. This mode is most convenient for capturing inputs
and is also used when channels provide outputs with different frequencies
or that are not periodic at all.
Up (1): The counter counts from 0 up to the value in TACCR0, the
capture/compare register for channel 0. It returns to 0 on the next clock
transition. The period is (TACCR0 + 1) counts.Up mode is usually used
when all channels provide outputs at the same frequency, often for pulse-
width modulation.
Up/Down (3): The counter counts from 0 up to TACCR0, then down again
to 0 and repeats. The period is 2 × TACCR0 counts. This is a specialized
mode, typically used for centered pulse-width modulation.
The count in TAR and the divider can be cleared by writing a 1 to the
TACLR bit in TACTL. The TACLR bit automatically clears itself after use.
The flag TAIFG in TACTL is set when the timer counts to 0 and a
maskable interrupt is requested if the TAIE bit is set.
Often timer clock is not synchronous with the CPU clock, such as when
the timer is supplied from ACLK. In this case it is best to stop the timer
before reading the value of TAR.
An event can be a rising edge, falling edge, or either edge on the input
according to the capture mode bits CMx. The CCISx bits in TACCTLn
select the input to be captured.
The state of the selected input can always be read in the CCI bit of
TACCTLn. The capture hardware includes a synchronizer, which is
enabled by setting the SCS bit.
The capture overflow bit COV is set if another capture occurs before
TACCRn has been read following the previous event.