M16C/62P Group (M16C/62P, M16C/62PT)
15. Timers
Rev.2.41
Jan 10, 2006
Page 139 of 390
REJ09B0185-0241
15.1
Timer A
Figure 15.3 shows a Timer A Block Diagram. Figures 15.4 to 15.7 show registers related to Timer A. Timer A
supports the following four modes. Except in event counter mode, Timers A0 to A4 all have the same function. Use
the TMOD1 to TMOD0 bits in the TAiMR register (i = 0 to 4) to select the desired mode.
•
Timer Mode:
The timer counts an internal count source.
•
Event Counter Mode:
The timer counts pulses from an external device or overflows and
underflows of other timers.
•
One-shot Timer Mode:
The timer outputs a pulse only once before it reaches the minimum
count “0000h”.
•
Pulse Width Modulation (PWM) Mode: The timer outputs pulses in a given width successively.
Figure 15.3
Timer A Block Diagram
TAi
Addresses
TAj
TAk
Timer A0 0387h - 0386h
Timer A4 Timer A1
Timer A1 0389h - 0388h
Timer A0 Timer A2
Timer A2 038Bh - 038Ah
Timer A1 Timer A3
Timer A3 038Dh - 038Ch
Timer A2 Timer A4
Timer A4 038Fh - 038Eh
Timer A3 Timer A0
f1 or f2
f8
f32
fC32
TAiS
Increment / decrement
Select Count Source
· Timer (gate function): TMOD1 to TMOD0=00,
MR2=1
· Timer
:TMOD1 to TMOD0=00, MR2=0
· One-Shot Timer
:TMOD1 to TMOD0=10
· Pulse Width Modulation
:
TMOD1 to TMOD0=11
TAiIN
· Event counter :TMOD1 to TMOD0=01
Select clock
TAj Overflow
(1)
Pulse Output
Toggle Flip Flop
TAiOUT
Always decrement except
in event counter mode
8 low-order
bits
Counter
Low-Order Bits of Data Bus
TAiUD
Decrement
TAk Overflow
(1)
Polarity
Selector
00
01
11
10
TCK1 to TCK0
TB2 Overflow
(1)
00
01
10
11
TAiTGH to TAiTGL
11
01
01
00
0
1
MR2
TMOD1 to TMOD0
TCK1 to TCK0, TMOD1 to TMOC0, MR2 to MR1 : Bits in TAiMR register
TAiTGH to TAiTGL : Bits in ONSF register if i=0 or bits in TRGSR register if i=1 to 4
TAiS : Bits in the TABSR register
TAiUD : Bits in the UDF register
TMOD1 to TMOD0,
MR2
i=0 to 4
j=i-1, however, j=4 if i=0
k=i+1, however, k=0 if i=4
8 high-
order bits
To external
trigger circuit
High-Order Bits of Data Bus
Reload Register
NOTES:
1. Overflow or underflow
The M16C/62P (80-pin version) and M16C/62PT (80-pin version) do not include TA1IN and TA1OUT pins
of Timer A1, and TA2IN and TA2OUT pins of Timer A2
.
[Precautions when using Timer A1 and Timer A2]
• Timer Mode
The Gate Function and the Pulse Output Function cannot be used.
Set the MR2 to
MR0 bits in the TA1MR and TA2MR registers to “000b” when using Timer
Mode.
• Event Counter Mode
The Pulse Output Function cannot be used and external input signals cannot be counted.
Two-phase Pulse Signal of Timer A2 cannot be used. Set the MR2 to MR0 bits in the
TA1MR and TA2MR registers to “000b” when using the Event Counter Mode.
• One-shot Timer Mode The Pulse Output Function cannot be used and count start by the external trigger cannot
be counted. Set the MR1 to MR0 bits in the TA1MR and TA2MR registers to “00b”
when using the One-shot Timer Mode.
• Pulse Width
Modulation Mode
PWM pulse cannot be outputted.
Note
http://www.xinpian.net
提供单片机解密、IC解密、芯片解密业务
010-62245566 13810019655