206 6. TIMER SYSTEMS
• 10 - Ground
• 11 - Supply voltage Vcc
The Capture Mode (CAP) bit (bit 8) of the Timer_A Capture Control Register (TACCTLx)
register is used to conﬁgure channel x to be either as an input capture (1) channel or as an output
compare (0) channel. When the event designated by CMx bits appears on the input channel pin, the
current value of free running counter TAR is captured in the Timer_A Capture/Compare Register
x (TACCRx) register and the corresponding ﬂag, Capture/Compare Interrupt Flag (CCIFG) (bit
0), in the TACCTLx register is set. If the Capture/Compare Interrupt Enable (CCIE) bit (bit 4) is
set and the General Interrupt Enable (GIE) bit is activated, the interrupt system is conﬁgured to
service the interrupt. If another input capture event occurs before the TACCRx is read, the Capture
Overﬂow (COV) bit (bit 1) of the TACCTLx turns to 1 (set).
&0; &0; &&,6 &&,6 6&6
28702' 28702' 28702' &&,( &&, 287 &29 &&,)*
Figure 6.20: Input Capture and Output Compare Control Register.
Example: In this input capture example, we use the MSP430 Launch Pad Development Tool.
This evaluation board is part of the MSP430 Value Line. The board is equipped with the 14 pin
MSP430G2211. The microcontroller socket on the board allows a 20 pin MSP430G2231 micro-
controller. We use the controller to capture the pulse width of an incoming signal on P1.0. We
only show the capture program segment, assuming all appropriate initialization steps are already
taken. The program uses variable ’Flag’ to count the number of incoming events (rising edge or a
falling edge). Note that by storing the TACCRO0 times when the two consecutive events occur
and computing the difference between the two times, we calculated the pulse width. Deﬁnitions for
pre-deﬁned settings are provided in the header ﬁle for the MSP430G2211. The computation for
determining elapsed time does not take into account events lasting longer than the rollover time of
the counter. That computation is left as a homework assignment at the end of the chapter.
bic.b #01, &P1DIR ;setup P1.0 as input