CHAPTER 9 TIMER/COUNTER FUNCTION
328
User’s Manual U15195EJ5V0UD
(1) Timers 20, 21 (TM20, TM21)
The features of TM2n are listed below.
•
Free-running counter that enables counter clearing by compare match of subchannel 0 and subchannel 5
•
Can be used as a 32-bit capture timer when TM20 and TM21 are connected in cascade.
•
Up/down control, counter clear, and count operation enable/disable can be controlled by external pin
(TCLR2)
•
Counter up/down and clear operation control method can be set by software.
•
Stop upon occurrence of count value 0 and count operation start/stop can be controlled by software.
(2) Timer 2 subchannel 0 capture/compare register (CVSE00)
The CVSE00 register is the 16-bit capture/compare register of subchannel 0.
In the capture register mode, it captures the TM20 count value.
In the compare register mode, it detects a match with TM20.
This register can be read/written in 16-bit units.
14
13
12
2
3
4
5
6
7
8
9
10
11
15
1
0
CVSE00
Address
FFFFF660H
After reset
0000H
(3) Timer 2 subchannel n main capture/compare register (CVPEn0) (n = 1 to 4)
The CVPEn0 register is the subchannel n 16-bit main capture/compare register.
In the capture register mode, this register captures the value of TM21 when the BFEEn bit of the CMSEm0
register = 0 (m = 12, 34). When the BFEEn bit = 1, this register holds the value of TM20 or TM21.
In compare register mode, a match between this register and TM2x is detected (TM2x = timer/counter
selected by TB1En and TB0En bits).
If the capture register mode is selected in the 32-bit mode (value of TB1En, TB0En bits of CMSEm0 register
= 11B), this register captures the contents of TM21 (higher 16 bits).
This register is read-only, in 16-bit units.
Caution When the BFEEn bit = 1, a compare match occurs on starting the timer in the compare
register mode because the values of both the TM2x and CVPEn0 registers are 0 after reset
(TM2x = timer/counter selected by TB1En and TB0En bits (n = 1 to 4)). After that, the value
of the sub register (CVSEn0) is written to the main register (CVPEn0).
14
13
12
2
3
4
5
6
7
8
9
10
11
15
1
0
CVPE10
Address
FFFFF652H
After reset
0000H
14
13
12
2
3
4
5
6
7
8
9
10
11
15
1
0
CVPE20
Address
FFFFF656H
After reset
0000H
14
13
12
2
3
4
5
6
7
8
9
10
11
15
1
0
CVPE30
Address
FFFFF65AH
After reset
0000H
14
13
12
2
3
4
5
6
7
8
9
10
11
15
1
0
CVPE40
Address
FFFFF65EH
After reset
0000H