212
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
2.3 Timer B
2.3.1 Overview
The following is an overview for timer B, a 16-bit timer.
(1) Mode
Timer B operates in one of three modes:
(a) Timer mode
The internal count source is counted.
Operation in timer mode ........................................................................................................... P216
(b) Event counter mode
The number of pulses coming from outside and the number of the timer overflows are counted.
Operation in event counter mode ............................................................................................. P218
(c) Pulse period measurement/pulse width measurement mode
External pulse period or external pulse widths are measured. If pulse period measurement mode is
selected, the periods of input pulses are continuously measured. If pulse width measurement mode
is selected, widths of “H” level pulses and those of “L” level pulses are continuously measured.
Operation in pulse period measurement mode ........................................................................ P220
Operation in pulse width measurement mode .......................................................................... P222
(2) Count source
An internal count source can be selected from f
1
, f
8
, f
32
, and f
C32
. f
1
, f
8
, and f
32
are clocks obtained by
dividing the CPU main clock by 1, 8, and 32 respectively. f
C32
is the clock obtained by dividing the
CPU secondary clock by 32.
(3) Frequency division ratio
The frequency division ratio equals [the value set in the timer register + 1]. The counter underflows
when a count source equal to a frequency division ratio is input, and an interrupt request occurs.
(4) Reading the timer
In timer mode or event counter mode, the count value at the time of reading the timer register will be
read. Read the register in 16-bit increments. In both the pulse period measurement mode and pulse
width measurement mode, an indeterminate value is read until the second effective edge is input after
a count is started, otherwise, the measurement results are read.
(5) Writing to the timer
When writing to the timer register while a count is in progress, the value is written only to the reload
register. When writing to the timer register while a count has stopped, the value is written both to the
reload register and the count. Write the value in 16-bit increments. The timer register cannot be
written to in either the pulse period measurement mode or the pulse width measurement mode.