Texas Instruments MSC1210 manual Timer 2 in Capture Mode

Models: MSC1210

1 324
Download 324 pages 20.97 Kb
Page 89
Image 89

Using Timer 2

8.5.3Timer 2 in Capture Mode

A new mode, specific to Timer 2, is called capture mode. As the name implies, this mode captures the value of Timer 2 (TH2 and TL2) into the capture SFRs (RCAP2H and RCAP2L). To put Timer 2 in capture mode, CP/RL2 (T2CON.0) and EXEN2 (T2CON.3) must be set.

When configured as mentioned above, a capture occurs whenever a 1-0 tran- sition is detected on T2EX (P1.1). At the moment the transition is detected, the current values of TH2 and TL2 is copied into RCAP2H and RCAP2L, respec- tively. At the same time, the EXF2 (T2CON.6) bit is set, which triggers an inter- rupt, if Timer 2 interrupt is enabled.

Note:

Even in capture mode, an overflow of Timer 2 results in TF2 being set and an interrupt being triggered.

Note:

Capture mode is an efficient way to measure the time between events. At the moment that an event occurs, the current value of Timer 2 is copied into RCAP2H/L. However, Timer 2 will not stop and an interrupt will be triggered. Thus the interrupt routine must copy the value of RCAP2H/L to a temporary holding variable without stopping Timer 2. When another capture occurs, the interrupt can take the difference of the two values to determine the time tran- spired. Again, the main advantage is that Timer 2 does not need to be stopped to have its value read, as is the case with Timer 0 and Timer 1.

Timers 8-15

Page 89
Image 89
Texas Instruments MSC1210 manual Timer 2 in Capture Mode