beautypg.com

Texas Instruments MSP430x1xx User Manual

Page 194

background image

Timer Modes

11-18

Overflow bit COVx is reset by the software as described in the following
example:

; Software example for the handling of captured data
; looking for overflow condition
;
; The data of the capture/compare register CCRx are taken
; by the software and immediately with the next
; instruction the overflow bit is tested and a decision is
; made to proceed regularly or with an error handler
;
CCRx_Int_hand

...

; Start of handler Interrupt

...
...

MOV

&CCRx,RAM_Buffer

BIT

#COV,&CCTLx

JNZ

Overflow_Hand

...
...

; correct capture data

...

RETI

Overflow_Hand

BIC

#COV,&CCTLx

; reset capture
; overflow flag
; get back to lost
; synchronization

...

; Proceed

;

RETI

Note:

Capture With Timer Halted

The capture should be disabled when the timer is halted. The sequence to
follow is: stop the capture, then stop the timer. When the capture function is
restarted, the sequence should be: start the capture, then start the timer.

11.4.1.1 Capture/Compare Block, Capture Mode—Capture Initiated by Software

In addition to internal and external signals, captures can be initiated by
software. This is useful for various purposes, such as:

-

To measure time used by software routines

-

To measure time between hardware events

-

To measure the system frequency

Two bits, CCISx1 and CCISx0, and the capture mode selected by bits CCMx1
and CCMx0 are used by the software to initiate the capture. The simplest
realization is when the capture mode is selected to capture on both edges of
CCIx and bit CCISx1 is set. Software then toggles bit CCISx0 to switch the
capture signal between V

CC

and GND, initiating a capture each time the input

is toggled, as shown in Figure 11–21.