HT46R47
Timer/Event Counter
measure time intervals or pulse widths, or to
generate an accurate time base.
A timer/event counter (TMR) is implemented in
the microcontroller. The timer/event counter
contains an 8-bit programmable count-up coun-
ter and the clock may come from an external
source or the system clock.
There are 2 registers related to the timer/event
counter; TMR ([0DH]), TMRC ([0EH]). Two phys-
ical registers are mapped to TMR location; writ-
ing TMR makes the starting value be placed in
the timer/event counter preload register and
reading TMR gets the contents of the timer/event
counter. The TMRC is a timer/event counter con-
trol register, which defines some options.
Using the internal system clock, there is only
one reference time-base. The internal clock
source comes from fSYS. The external clock in-
put allows the user to count external events,
Label (TMRC)
Bits
Function
To define the prescaler stages, PSC2, PSC1, PSC0=
000: fINT=fSYS
001: fINT=fSYS/2
010: fINT=fSYS/4
011: fINT=fSYS/8
100: fINT=fSYS/16
101: fINT=fSYS/32
110: fINT=fSYS/64
111: fINT=fSYS/128
PSC0~PSC2
0~2
To define the TMR active edge of timer/event counter
(0=active on low to high; 1=active on high to low)
TE
3
To enable/disable timer counting
(0=disabled; 1=enabled)
TON
4
5
¾
Unused bit, read as ²0²
To define the operating mode
01=Event count mode (external clock)
10=Timer mode (internal clock)
11=Pulse width measurement mode
00=Unused
TM0
TM1
6
7
TMRC register
P
W
M
(
6
+
2
)
c
o
m
p
a
r
e
0
t
o
P
D
c
i
r
c
u
i
t
f
S
Y
S
8
-
s
t
a
g
e
p
r
e
s
c
a
l
e
r
f
I
N
T
D
a
t
l
a
B
u
s
8
-
1
M
U
X
T
T
M
M
1
0
R
e
o
a
d
o
T
i
m
e
r
/
E
v
e
n
t
C
u
n
t
e
r
P
r
e
l
o
a
d
R
e
g
i
s
t
e
r
P
S
C
2
~
T
P
M
S
C
R
0
T
E
P
u
l
s
e
W
i
d
t
h
T
i
m
o
e
r
/
E
v
e
n
t
v e
O
t
r
f
l
o
w
T
T
T
M
M
O
1
0
M
e
a
s
u
r
e
m
e
n
t
C
u
n
t
e
r
o
I
D
n
t
e
r
r
u
p
t
M
o
d
e
C
o
n
t
r
o
l
N
1
/
2
P
F
Timer/Event Counter
16
Rev. 1.40
July 18, 2001