15 16-BIT PWM TIMER (T16A5)
S1C33L26 TECHNICAL MANUAL
Seiko Epson Corporation
15-3
Notes: • Make sure the counter is halted before setting the count clock.
• When using an external clock, the external clock cycle must be at least two CPU operating
clock cycles.
For controlling the prescaler, refer to the “Prescaler (PSC)” chapter.
T16A5 Operating Modes
15.4
T16A5 provides some operating modes to support various usages. This section describes the functions of each op-
erating mode and how to enter the mode.
Comparator Mode and Capture Mode
15.4.1
The T16A_CCA
x
and T16A_CCB
x
registers that are embedded in the comparator/capture block can be set to com-
parator mode or capture mode, individually. The T16A_CCA
x
register mode is selected using CCAMD/T16A_
CCCTL
x
register and the T16A_CCB
x
register mode is selected using CCBMD/T16A_CCCTL
x
register.
Comparator mode (CCAMD/CCBMD = 0, default)
The comparator mode compares the counter value and the comparison value set by software. It generates an
interrupt and toggles the timer output signal level when the values are matched. The T16A_CCA
x
and T16A_
CCB
x
registers function as the compare A and compare B registers that are used for loading comparison values
in this mode.
The counter channel (Ch.0 or Ch.1) to be used can be selected using T16SEL[1:0]/T16A_CTL
x
register. This
selection enables the both channels output compare A and compare B signals in sync with one 16-bit counter.
When the counter reaches the value set in the compare A register during counting, the comparator asserts the
compare A signal. At the same time the compare A interrupt flag is set and an interrupt signal is output to the
ITC if the interrupt has been enabled.
When the counter reaches the value set in the compare B register, the comparator asserts the compare B signal.
At the same time the compare B interrupt flag is set and an interrupt signal is output to the ITC if the interrupt
is enabled. Furthermore, the counter is reset to 0.
Note: The intervals of the compare A and compare B interrupts must be longer than three count clock
cycles. Otherwise, the second interrupt will be omitted by T16A5.
The compare A and compare B signals are also used to generate a timer output waveform. See Section 15.6,
“Timer Output Control,” for more information.
To generate PWM waveform, the T16A_CCA
x
and T16A_CCB
x
registers must be both placed into comparator
mode.
Compare buffers
Comparison data can be read or written directly from/to the compare registers. Comparison data for system
A or B can also be written to the compare buffer so that it will be loaded to the compare A or compare B
register by the compare B signal. The CBUFEN/T16A_CTL
x
register is used to select whether comparison
data is written to the compare register or buffer.
Setting CBUFEN to 0 (default) selects the compare registers. Setting it to 1 selects the compare buffers.
Although the T16A_CCA
x
and T16A_CCB
x
registers are used to write compare data even if CBUFEN = 1,
compare buffers will be accessed. Note that compare data is always read from the compare register regard-
less of whether the compare buffer is enabled or not.
Capture mode (CCAMD/CCBMD = 1)
The capture mode captures the counter value when an external event such as a key entry occurs (at the speci-
fied edge of the external input signal). In this mode, the T16A_CCA
x
and/or T16A_CCB
x
registers function as
the capture A and/or capture B registers for loading the captured data. To input a counter capture trigger signal,
the capture A circuit uses the T16A_ATMA_
x
pin and the capture B circuit uses the T16A_ATMB_
x
pin. The
T16A_ATMA_
x
and T16A_ATMB_
x
pins are shared with the timer outputs. They are configured for input
when the system A or B is set to capture mode.