222
Timer B
M
i
t
s
u
M
S
b
i
s
3
M
h
0
I
C
i
m
2
R
i
1
O
c
r
8
C
o
c
o
G
M
m
p
r
P
u
t
u
T
e
r
p
R
s
o
U
S
I
N
G
L
E
-
C
H
I
P
1
6
-
B
I
T
C
M
O
O
E
In pulse period/pulse width measurement mode, choose functions from those listed in Table 2.3.4. Op-
erations of the circled items are described below. Figure 2.3.10 shows the operation timing, and Figure
2.3.11 shows the set-up procedure.
2.3.5 Operation of Timer B (pulse width measurement mode)
Figure 2.3.10. Operation timing of pulse width measurement mode
Operation
Note
Table 2.3.4. Choosed functions
(1) Setting the count start flag to “1” causes the counter to start counting the count source.
(2) If an effective edge of a pulse to be measured is input, the value of the counter goes to
“0000
16
”, and measurement is started. In this instance, an indeterminate value is transferred
to the reload register. The timer Bi interrupt request is not generated.
(3) If an effective edge of a pulse to be measured is input again, the value of the counter is
transferred to the reload register, and the timer Bi interrupt request bit goes to “1”. Then the
value of the counter becomes “0000
16
”, and measurement is started again.
The timer Bi interrupt request bit goes to “1” when an effective edge of a pulse to be measured
is input or timer Bi overflows. The factor of interrupt request can be determined by use of the
timer Bi overflow flag within the interrupt routine.
The value of the counter at the beginning of a count is indeterminate. Thus there can be in-
stances in which the timer Bi overflow flag goes to “1” immediately after a count is performed.
The timer Bi overflow flag goes to “0” if timer Bi mode register is written to when the count start
flag is “1”. This flag cannot be set to “1” by software.
Item
Set-up
Count source
Internal count source (f
1
/ f
8
/ f
32
/ fc
32
)
Pulse width measurement (interval between measurement pulse falling edge to rising edge,
and between rising edge to falling edge)
O
Pulse period measurement (interval between measurement pulse falling edge to falling edge)
Pulse period measurement (interval between measurement pulse rising edge to rising edge)
O
Measurement
mode
Measurement pulse
“H”
“L”
Count source
Reload register
←
counter
transfer timing
Count start flag
Timer Bi interrupt request bit
Timing at which counter
reaches “0000
16”
“1”
“0”
“1”
“0”
Timer Bi overflow flag
“1”
“0”
Note 1: Counter is initialized at completion of measurement.
Note 2: Timer has overflowed.
(Note 1)
(Note 1)
(Note 1)
(Note 2)
(1) Start count
(2) Start measurement
(3) Start measurement again
Cleared to “0” when interrupt request is accepted, or cleared by software
Transfer
(indeterminate
value)
Transfer(measured value)
(Note 1)