
ML66517 Family User’s Manual
Chapter 8
General-Purpose 8/16 Bit Timers
8 – 34
8.8.3 Example of Timer 5-related Register Settings
(1) Port 10 mode register (P10IO)
If TM5EVT (event input) is to be used, reset bit 7 (P10IO7) to “0” to configure the port as an input.
(2) Port 10 secondary function control register (P10SF)
If TM5EVT (event input) is to be used, disable or enable the pull-up resistor with bit 7 (P10SF7).
(3) General-purpose 8-bit timer 5 counter (TM5C)
Set the timer value that will be valid at the start of counting. When writing to TM5C, the same value will
also be simultaneously and automatically written to the general-purpose 8-bit timer 5 register (TM5R).
(4) General-purpose 8-bit timer 5 register (TM5R)
This register sets the value to be loaded after general-purpose 8-bit timer 5 counter (TM5C) overflows. If
the timer value (TM5C) and the reload value (TM5R) are identical, this register will automatically be set
just by setting TM5C. If the values are different or are to be modified, this register must be set explicitly.
(5) General-purpose 8-bit timer 5 control register (TM5CON)
Bits 0 to 2 (TM5C0 to TM5C2) of this register specify the count clock for timer 5. If TM5OUT (timer
output) is used, specify the initial level (High or Low) with bit 7 (TM5OUT). If bit 3 (TM5RUN) is set to
“1”, timer 5 will begin counting.
If reset to “0”, timer 5 will halt counting.
8.8.4 Timer 5 Operation
When the TM5RUN bit is set to “1”, timer 5 will begin counting upward, running on the count clock selected by
TM5CON. If external event input is selected as the count clock, timer 5 can also be used as an event counter.
When TM5C overflows, an interrupt request is generated, the contents of TM5R are loaded into TM5C and
TM5OUT is inverted. This operation is repeated until the TM5RUN bit is reset to “0”. Figure 8-18 shows an
operation example (for settings of 1/n counter frequency division ratio 1/1 and 1/4 TBCCLK).
Figure 8-18
Timer 5 Operation Example
[Note]
Set the minimum pulse width of the external event input longer than 1 CPU clock (CPUCLK). The external
event input signal is sampled at the falling edge of the CPUCLK to create the count clock for the timer.
55H
FEH
FFH
55H
56H
CPUCLK
TM count CLK
(1/4 TBCCLK)
TM5R
TM5C
Overflow signal
Interrupt request generated
TM5OUT