18. Timer Unit (TMU)
Rev.1.00 Jan. 10, 2008 Page 810 of 1658
REJ09B0261-0100
18.4
Operation
Each channel has a 32-bit timer counter (TCNT) and a 32-bit timer constant register (TCOR).
Each TCNT performs count-down operation. The channels have an auto-reload function that
allows cyclic count operations, and can also perform external event counting. Channel 2 also has
an input capture function.
18.4.1
Counter Operation
When one of bits STR0 to STR2 in TSTR is set to 1, the TCNT for the corresponding channel
starts counting. When TCNT underflows, the UNF flag in TCR is set. If the UNIE bit in TCR is
set to 1 at this time, an interrupt request is sent to the CPU. At the same time, the value is copied
from TCOR into TCNT, and the count-down continues (auto-reload function).
(1)
Example of Counter Operation Setting Procedure
Figure 18.2 shows an example of the counter operation setting procedure.
Counter operation setup
Select counter clock
Set up underflow
interrupt
g
eneration
Set up input capture
interrupt
g
eneration
When usin
g
input capture
function
Set timer constant
re
g
ister
Load the counter with
the initial value
Start countin
g
(1)
(1)
(2)
(3)
(4)
(5)
(6)
(2)
(3)
(4)
(5)
(6)
Note:
When an interrupt is
g
enerated, clear the source fla
g
in the interrupt handler processin
g
.
If the interrupt is enabled without clearin
g
the fla
g
, another interrupt will be
g
enerated.
Select the counter clock with the TPSC2 to TPSC0 bits
in TCR. When the external clock (TCLK) is selected,
specify the external clock ed
g
e with the CKEG1 and
CKEG0 bits in TCR.
Specify whether an interrupt is
g
enerated on TCNT
underflow with the UNIE bit in TCR.
When the input capture function is used, set the ICPE
bits in TCR, which also specify the use of the interrupt
function.
Set a value in TCOR.
Set the initial value in TCNT.
Set the STR bit in TSTR to 1 to start countin
g
.
Figure 18.2 Example of Count Operation Setting Procedure
Summary of Contents for SH7781
Page 4: ...Rev 1 00 Jan 10 2008 Page iv of xxx REJ09B0261 0100 ...
Page 74: ...2 Programming Model Rev 1 00 Jan 10 2008 Page 44 of 1658 REJ09B0261 0100 ...
Page 272: ...8 Caches Rev 1 00 Jan 10 2008 Page 242 of 1658 REJ09B0261 0100 ...
Page 376: ...10 Interrupt Controller INTC Rev 1 00 Jan 10 2008 Page 346 of 1658 REJ09B0261 0100 ...
Page 694: ...13 PCI Controller PCIC Rev 1 00 Jan 10 2008 Page 664 of 1658 REJ09B0261 0100 ...
Page 762: ...14 Direct Memory Access Controller DMAC Rev 1 00 Jan 10 2008 Page 732 of 1658 REJ09B0261 0100 ...
Page 788: ...15 Clock Pulse Generator CPG Rev 1 00 Jan 10 2008 Page 758 of 1658 REJ09B0261 0100 ...
Page 828: ...17 Power Down Mode Rev 1 00 Jan 10 2008 Page 798 of 1658 REJ09B0261 0100 ...
Page 846: ...18 Timer Unit TMU Rev 1 00 Jan 10 2008 Page 816 of 1658 REJ09B0261 0100 ...
Page 1292: ...24 Multimedia Card Interface MMCIF Rev 1 00 Jan 10 2008 Page 1262 of 1658 REJ09B0261 0100 ...
Page 1326: ...25 Audio Codec Interface HAC Rev 1 00 Jan 10 2008 Page 1296 of 1658 REJ09B0261 0100 ...
Page 1482: ...28 General Purpose I O Ports GPIO Rev 1 00 Jan 10 2008 Page 1452 of 1658 REJ09B0261 0100 ...
Page 1538: ...30 User Debugging Interface H UDI Rev 1 00 Jan 10 2008 Page 1508 of 1658 REJ09B0261 0100 ...
Page 1688: ...Appendix Rev 1 00 Jan 10 2008 Page 1658 of 1658 REJ09B0261 0100 ...
Page 1691: ......
Page 1692: ...SH7785 Hardware Manual ...