Hardware Reference
In-Depth Information
7
6
5
4
3
2
1
0
C7F
C6F
C5F
C4F
C3F
C2F
C1F
C0F
Reset:
0
0
0
0
0
0
0
0
C
F: input-capture/output-compare interrupt flag bits
0 = interrupt condition has not occurred.
1 = interrupt condition has occurred.
n
Figure 8.8 Timer Interrupt Flag register 1 (TFLG1)
To clear a flag in the TFLG1 register, write a 1 to it. However, there is a better way to clear the
flag that incurs less overhead. Setting bit 4 (TFFCA) of the TSCR1 register allows clearing a flag by
reading the corresponding input-capture register or writing a new value into the output-compare
register. This operation is needed for the normal operation of the input-capture or output-compare
function.
Each input-capture channel has a 16-bit register (TC x , x 5 0 to 7) to hold the count value
when the selected signal edge arrives at the pin. This register is also used as the output-compare
register when the output-compare function is selected instead.
8.5.4 Input-Capture Applications
There are many applications for the input-capture function. Examples include the following:
Event arrival-time recording . Some applications, for example, swimming
competitions, need to compare the arrival times of several different swimmers.
The input-capture function is very suitable for this application. The number of
events that can be compared is limited by the number of input-capture channels.
Period measurement . To measure the period of an unknown signal, the input-
capture function should be configured to capture the timer values corresponding
to two consecutive rising or falling edges, as illustrated in Figure 8.9.
Pulse-width measurement . To measure the width of a pulse, two adjacent rising
and falling edges are captured, as shown in Figure 8.10.
One period
(a) Capture two rising edges
One period
(b) Capture two falling edges
Figure 8.9 Period measurement by capturing two consecutive edges
 
Search WWH ::




Custom Search