15 16-BIT PWM TIMER (T16A5)
15-4
Seiko Epson Corporation
S1C33L26 TECHNICAL MANUAL
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 capture values of the same 16-bit counter.
The trigger edge of the input signal can be selected using the CAPATRG[1:0]/T16A_CCCTL
x
register for cap-
ture A and CAPBTRG[1:0]/T16A_CCCTL
x
register for capture B.
4.1.1 Capture Trigger Edge Selection
Table 15.
CAPATRG[1:0]/ CAPBTRG[1:0]
Trigger edge
0x3
Falling edge and rising edge
0x2
Falling edge
0x1
Rising edge
0x0
Not triggered
(Default: 0x0)
When a specified trigger edge is input during counting, the current counter value is loaded to the capture regis-
ter. At the same time the capture A or capture B interrupt flag is set and an interrupt signal is output to the ITC
if the interrupt has been enabled. This interrupt can be used to read the captured data from the T16A_CCA
x
or
T16A_CCB
x
register. For example, external event cycles and pulse widths can be measured from the difference
between two captured counter values read.
If the captured data is overwritten by the next trigger when the capture A or capture B interrupt flag has already
been set, the overwrite interrupt flag will be set. This interrupt can be used to execute an overwrite error han-
dling. To avoid occurrence of unnecessary overwrite interrupt, the capture A or capture B interrupt flag must be
reset after the captured data has been read from the T16A_CCA
x
or T16A_CCB
x
register.
Notes: • The correct captured data may not be obtained if the captured data is read at the same time
the next value is being captured. Read the capture register twice to check if the read data is
correct as necessary.
• To capture counter data properly, both the High and Low period of the T16A_ATMA_
x
/T16A_
ATMB_
x
trigger signal must be longer than three count clock cycles.
The setting of CAPATRG[1:0] or CAPBTRG[1:0] is ineffective in comparator mode. No counter capturing op-
eration will be performed, as the T16A_ATMA_
x
/T16A_ATMB_
x
pin is configured for output.
The capture mode cannot generate/output the timer signal, as no compare signal is generated.
Repeat Mode and One-Shot Mode
15.4.2
Each counter features two count modes: repeat mode and one-shot mode. The count mode is selected using TMMD
/T16A_CTL
x
register.
Repeat mode (TMMD = 0, default)
Setting TMMD to 0 sets the counter to repeat mode.
In this mode, once the count starts, the counter continues running until stopped by the application program. If
the counter is reset to 0 or returns to 0 due to a counter overflow, the counter continues the count. The counter
should be set to this mode to generate periodic interrupts at desired intervals or to generate a timer output wave-
form.
One-shot mode (TMMD = 1)
Setting TMMD to 1 sets the counter to one-shot mode.
In this mode, the counter stops automatically as soon as the counter is reset or it overflows. The counter should
be set to this mode to set a specific wait time or for pulse width measurement.
Counter Control
15.5
Counter Reset
15.5.1
The counter can be reset to 0 by writing 1 to PRESET/T16A_CTL
x
register.
Normally, the counter should be reset by writing 1 to this bit before starting the count.