Datasheet

Section 11 16-Bit Cycle Measurement Timer (TCM)
Rev. 3.00 Sep. 28, 2009 Page 309 of 910
REJ09B0350-0300
11.3.1 TCM Timer Counter (TCMCNT)
TCMCNT is a 16-bit readable/writable up-counter. The input clock is selected by the bits CKS2 to
CKS0 in TCMCR. When CKS2 to CKS0 are set to B'111, the external clock is selected. In this
case, the rising or falling edge is selected by CKSEG in TCMCR.
When TCMCNT overflows (counting changes the value from H'FFFF to H'0000), OVF in
TCMCSR is set to 1. When the CST bit in TCMCR is cleared in timer mode, TCMCR is
initialized to H'0000. In cycle measurement mode, TCMCNT is cleared by detection of the first
edge (the edge selected with the IEDG bit in TCMCR) of the measurement period (one period of
the input waveform forms one measurement period).
In timer mode, TCMCNT is always writable. TCMCNT cannot be modified in cycle measurement
mode. TCMCNT should always be accessed in 16-bit units and cannot be accessed in 8-bit units.
TCMCNT is initialized to H'0000.
11.3.2 TCM Cycle Upper Limit Register (TCMMLCM)
TCMMLCM is a 16-bit readable/writable register. TCMMLCM is available as a compare match
register when the TCMMDS bit in TCMCR is cleared (operation is in timer mode). TCMMLCM
is available as a cycle upper limit register when the TCMMDS bit in TCMCR is set to 1 (operation
is in cycle measurement mode).
In timer mode, the value in TCMMLCM is constantly compared with that in TCMCNT, when the
values match, CMF in TCMCSR is set to 1. However, comparison is disabled in the second half of
a cycle of writing to TCMMLCM.
In cycle measurement mode, a value that sets an upper limit on the measurement period can be set
in TCMMLCM. When the second edge (first edge of the following cycle) of the measurement
period is detected, the value in TCMCNT is transferred to TCMICR. At this time, the values in
TCMICR and TCMMLCM are compared. The MAXOVF flag in TCMCSR is set to 1 if the value
in TCMICR is greater than that in TCMMLCM. TCMMLCM should always be accessed in 16-bit
units and cannot be accessed in 8-bit units. TCMMLCM is initialized to H'FFFF.