15 16-BIT PWM TIMERS (T16B)
15-4
Seiko Epson Corporation
S1C17M20/M21/M22/M23/M24/M25
TECHNICAL MANUAL (Rev. 1.0)
15.4 Operations
15.4.1 Initialization
T16B Ch.
n
should be initialized and started counting with the procedure shown below. Perform initial settings for
comparator mode when using T16B as an interval timer, PWM waveform generator, or external event counter. Per-
form initial settings for capture mode when using T16B to measure external event periods/cycles.
Initial settings for comparator mode
1. Configure the T16B Ch.
n
operating clock.
2 Set the T16B
n
CTL.MODEN bit to 1.
(Enable T16B operations)
3. Set the following T16B
n
CCCTL0 and T16B
n
CCCTL1 register bits:
- Set the T16B
n
CCCTL
m
.CCMD bit to 0. *
(Set comparator mode)
- T16B
n
CCCTL
m
.CBUFMD[2:0] bits
(Configure compare buffer)
*
Another circuit in the comparator/capture circuit pair (circuits 0 and 1, 2 and 3, 4 and 5) can be set to
capture mode.
Set the following bits when the TOUT
nm
output is used.
- T16B
n
CCCTL
m
.TOUTMT bit
(Select waveform generation signal)
- T16B
n
CCCTL
m
.TOUTMD[2:0] bits
(Select TOUT signal generation mode)
- T16B
n
CCCTL
m
.TOUTINV bit
(Select TOUT signal polarity)
4. Set the T16B
n
MC register.
(Set MAX counter data)
5. Set the T16B
n
CCR0 and T16B
n
CCR1 registers.
(Set the counter comparison value)
6. Set the following bits when using the interrupt:
- Write 1 to the interrupt flags in the T16B
n
INTF register.
(Clear interrupt flags)
- Set the interrupt enable bits in the T16B
n
INTE register to 1. (Enable interrupts)
7. Set the following T16B
n
CTL register bits:
- T16B
n
CTL.CNTMD[1:0] bits
(Select count up/down operation)
- T16B
n
CTL.ONEST bit
(Select one-shot/repeat operation)
- Set the T16B
n
CTL.PRESET bit to 1.
(Reset counter)
- Set the T16B
n
CTL.RUN bit to 1.
(Start counting)
Initial settings for capture mode
1. Configure the T16B Ch.
n
operating clock.
2 Set the T16B
n
CTL.MODEN bit to 1.
(Enable T16B operations)
3. Set the following T16B
n
CCCTL0 and T16B
n
CCCTL1 register bits:
- Set the T16B
n
CCCTL
m
.CCMD bit to 1. *
(Set capture mode)
- T16B
n
CCCTL
m
.SCS bit
(Set synchronous/asynchronous mode)
- T16B
n
CCCTL
m
.CAPIS[1:0] bits
(Set trigger signal)
- T16B
n
CCCTL
m
.CAPTRG[1:0] bits
(Select trigger edge)
*
Another circuit in the comparator/capture circuit pair (circuits 0 and 1, 2 and 3, 4 and 5) can be set to
comparator mode.
4. Set the T16B
n
MC register.
(Set MAX counter data)
5. Set the following bits when using the interrupt:
- Write 1 to the interrupt flags in the T16B
n
INTF register.
(Clear interrupt flags)
- Set the interrupt enable bits in the T16B
n
INTE register to 1. (Enable interrupts)
6. Set the following T16B
n
CTL register bits:
- T16B
n
CTL.CNTMD[1:0] bits
(Select count up/down operation)
- T16B
n
CTL.ONEST bit
(Select one-shot/repeat operation)
- Set the T16B
n
CTL.PRESET bit to 1.
(Reset counter)
- Set the T16B
n
CTL.RUN bit to 1.
(Start counting)