HD404669 Series
62
Timer C Operations
Free-running/reload timer operation:
The free-running/reload operation, input clock source, and
prescaler division ratio are selected by timer mode register C1 (TMC1: $00D).
Timer C is initialized to the value set in timer write register C (TWCL: $00E, TWCU: $00F) by software
and incremented by one at each clock input. If an input clock is applied to timer C after it has reached $FF,
an overflow is generated. In this case, if the reload timer function is enabled, timer C is initialized to its
initial value set in timer write register C (TWCL: $00E, TWCU: $00F); if the free-running timer function is
enabled, the timer is initialized to $00 and then incremented again.
The overflow sets the timer C interrupt request flag (IFTC: $002, bit 2 ). The timer C interrupt request flag
is reset by the program, an MCU reset or a transition to stop mode. For details, see figure 3, Configuration
of Interrupt Control Bits and Register Flag Area, and table 1, Initial Values after MCU Reset.
Watchdog timer operation:
Timer C is used as a watchdog timer for detecting out-of-control program
routines by setting the watchdog on flag (WDON: $020, bit 1) to 1. If a program routine runs out of control
and an overflow is generated, the MCU is reset. Program run can be controlled by initializing timer C by
software before it reaches $FF.
Timer output operation:
The following four output modes can be selected for timer C by setting timer
mode register C2 (TMC2: $014). With timer C, the R3
1
/TOC pin is designated as the TOC pin, and toggle
waveform output, low-level output, high-level output, or PWM waveform output can be selected, by timer
mode register C2 (TMC2: $014). TOC pin output is initialized to the low level by an MCU reset.
Toggle output
With toggle output, the output level is changed upon input of the next clock pulse after the timer C
value reaches $FF. Use of this function in combination with the reload timer allows a clock signal with
any period to be output, enabling it to be used as buzzer output. The output waveform is shown in
figure 42.
Low-level output
With low-level output, the output is changed to the low level when timer C overflows. This function
should be used when the output is high.
High-level output
With high-level output, the output is changed to the high level when timer C overflows. This function
should be used when the output is low.
PWM output
With PWM output, variable-duty pulses are output. The output waveform is as shown in figure 42,
according to the contents of timer mode register C1 (TMC1: $00D) and timer write register C (TWCL:
$00E, TWCU: $00F).