Product Info

Table Of Contents
R01UH0823EJ0110 Rev.1.10 Page 691 of 1852
Nov 30, 2020
RX23W Group 25. 16-Bit Timer Pulse Unit (TPUa)
25.3 Operation
25.3.1 Basic Functions
Each channel has a TPUm.TCNT and a TPUm.TGRy register (y = A to D).
TCNT is a 16-bit up-counter, which can function as a free-running counter, periodic counter, or event counter.
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 TPU.TSTR is set to 1, the TCNT for the corresponding channel starts counting.
(a) Example of count operation setting procedure
Figure 25.2 shows an example of the count operation setting procedure.
Figure 25.2 Example of Counter Operation Setting Procedure
Operation selection
Periodic counter Free-run counter
Select counter clearing source
Select count clock
Set period
Start count Start count
Select output compare register
<Periodic counter> <Free-running counter>
[1]
[2]
[3]
[4]
[5] [5]
[1] Select the count 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.
[2] For periodic counter operation, select
the TGRy register to be used as the
TCNT clearing source with the
CCLR[2:0] bits in TCR.
[3] Set the TGRy register selected in [2] as
an output compare register with TIOR
(y = A to D).
[4] Set the periodic counter cycle in the
TGRy register selected in [2].
[5] Set the TPU.TSTR.CSTj bit (j = 0 to 5)
to 1 to start the counter operation.