16 16-BIT PWM TIMERS (T16A3)
16-4
Seiko epson Corporation
S1C17F13 TeChniCal Manual
(Rev. 1.0)
6. Set the following T16A
n
CTL register bits:
- T16A
n
CTL.HCM bit
(Select half-clock or normal clock mode)
- T16A
n
CTL.CCABCNT[1:0] bits
(Select counter channel)
- T16A
n
CTL.CBUFEN bit
(Enable/disable compare buffer)
- T16A
n
CTL.TRMD bit
(Select one-shot or repeat mode)
- Set the T16A
n
CTL.PRESET bit to 1.
(Reset counter)
- Set the T16A
n
CTL.MODEN bit to 1.
(Enable count operations)
- Set the T16A
n
CTL.PRUN bit to 1.
(Start counting)
Initial settings for capture mode
1. Configure the T16A3 Ch.
n
operating clock.
2. Set the T16A0CLK.MULTIMD bit.
(Select multi-comparator/capture or normal channel mode)
3. Set the following T16A
n
CCCTL register bits:
- Set the T16A
n
CCCTL.CCAMD bit to 1. * (Set the T16A
n
CCA register to capture mode)
- Set the T16A
n
CCCTL.CCBMD bit to 1. * (Set the T16A
n
CCB register to capture mode)
- T16A
n
CCCTL.CAPATRG[1:0] bits
(Select capture A trigger edge)
- T16A
n
CCCTL.CAPBTRG[1:0] bits
(Select capture B trigger edge)
*
One of the T16A
n
CCA or T16A
n
CCB register can be set to comparator mode.
4. Set the following bits when using the interrupt:
- Write 1 to the interrupt flags in the T16A
n
INTF register.
(Clear interrupt flags)
- Set the interrupt enable bits in the T16A
n
INTE register to 1. (Enable interrupts)
5. Set the following T16A
n
CTL register bits:
- T16A
n
CTL.CCABCNT[1:0] bits
(Select counter channel)
- T16A
n
CTL.TRMD bit
(Select one-shot or repeat mode)
- Set the T16A
n
CTL.PRESET bit to 1.
(Reset counter)
- Set the T16A
n
CTL.MODEN bit to 1.
(Enable count operations)
- Set the T16A
n
CTL.PRUN bit to 1.
(Start counting)
Counter Block Operations
16.4.2
The counter in each counter block channel is a 16-bit up counter that counts the selected operating clock (count
clock).
Counter reset
Setting the T16A
n
CTL.PRESET bit to 1 clears the counter to 0. In comparator mode, the counter is also cleared
to 0 by the compare B signal (generated when the counter value reaches the T16A
n
CCB register value).
Counting start
To start counting, set the T16A
n
CTL.MODEN bit to 1 (start clock supply) and the T16A
n
CTL.PRUN bit to 1
(start counting). The counting stop control depends on the count mode set.
Count mode (repeat mode and one-shot mode)
Each counter features two count modes: repeat mode and one-shot mode. The count mode can be selected using
the T16A
n
CTL.TRMD bit.
Repeat mode (T16A
n
CTL.TRMD bit = 0)
This mode enables the counter to run continuously. Once the count starts, the counter continues running un-
til 0 is written to the T16A
n
CTL.PRUN bit. The counter continues counting even if the counter returns to 0
due to a counter overflow or by the compare B signal. Select this mode to generate periodic interrupts at de-
sired intervals, to measure pulse width or external event intervals, or to generate a timer output waveform.
One-shot mode (T16A
n
CTL.TRMD bit = 1)
This mode enables the counter to run for specified periods. The T16A
n
CTL.PRUN bit is cleared to 0 and
the counter stops automatically as soon as the compare B signal is generated. Select this mode to stop the
counter after an interrupt has occurred once, such as for checking a specific lapse of time.