RX610 Group
15. 16-Bit Timer Pulse Unit (TPU)
R01UH0032EJ0120 Rev.1.20
Page 485 of 1006
Feb 20, 2013
15.3
Operation
15.3.1
Basic Functions
Each channel has a TPUm.TCNT counter and a TPUm.TGRy register (y = A to D).
TCNT is a 16-bit up-counter, and is also capable of free-running operation, periodic counting, and external event
counting.
TGRy can be used as an input capture register or output compare register.
(1)
Counter Operation
When the CSTj bit (j = 0 to 5) in TSTRA or the CSTj bit (j = 0 to 5) in TSTRB is set to 1, the TCNT counter for the
corresponding channel starts counting. TCNT can operate as a free-running counter, periodic counter, and so on.
(a)
Example of count operation setting procedure
Figure 15.3 shows an example of the count operation setting procedure.
Operation selection
Periodic counter
Free-run counter
Select counter clearing
source
Select counter clock
Set period
Start count
Start count
Select output compare
register
<Periodic counter>
<Free-run counter>
[1]
[2]
[3]
[4]
[5]
Select the counter clock
with the TPSC[2:0] bits in
TCR. At the same time,
select the input clock
edge with the CKEG[1:0]
bits in TCR.
[1]
For periodic counter
operation, select the
TGRm register to be used
as the TCNT clearing
source with the
CCLR[2:0] bits in TCR.
[2]
[3]
Set the TGRm register
selected in [2] as an
output compare register
with TIOR (y = A to D).
[4]
Set the periodic counter
cycle in the TGRm register
selected in [2].
Set the CSTi bit in TSTRm
to 1 to start the counter
operation (y = A, B, i = 0
to 5)
[5]
[5]
Figure 15.3 Example of Counter Operation Setting Procedure