11 16-BIT TIMERS (T16)
11-2
Seiko Epson Corporation
S1C17M20/M21/M22/M23/M24/M25
TECHNICAL MANUAL (Rev. 1.0)
11.3 Clock Settings
11.3.1 T16 Operating Clock
When using T16 Ch.
n
, the T16 Ch.
n
operating clock CLK_T16_
n
must be supplied to T16 Ch.
n
from the clock
generator. The CLK_T16_
n
supply should be controlled as in the procedure shown below.
1. Enable the clock source in the clock generator if it is stopped (refer to “Clock Generator” in the “Power Supply,
Reset, and Clocks” chapter).
2. Set the following T16_
n
CLK register bits:
- T16_
n
CLK.CLKSRC[1:0] bits (Clock source selection)
- T16_
n
CLK.CLKDIV[3:0] bits (Clock division ratio selection = Clock frequency setting)
11.3.2 Clock Supply in SLEEP Mode
When using T16 during SLEEP mode, the T16 operating clock CLK_T16_
n
must be configured so that it will keep
supplying by writing 0 to the CLGOSC.
xxxx
SLPC bit for the CLK_T16_
n
clock source.
If the CLGOSC.
xxxx
SLPC bit for the CLK_T16_
n
clock source is 1, the CLK_T16_
n
clock source is deactivated
during SLEEP mode and T16 stops with the register settings and counter value maintained at those before entering
SLEEP mode. After the CPU returns to normal mode, CLK_T16_
n
is supplied and the T16 operation resumes.
11.3.3 Clock Supply in DEBUG Mode
The CLK_T16_
n
supply during DEBUG mode should be controlled using the T16_
n
CLK.DBRUN bit.
The CLK_T16_
n
supply to T16 Ch.
n
is suspended when the CPU enters DEBUG mode if the T16_
n
CLK.DBRUN
bit = 0. After the CPU returns to normal mode, the CLK_T16_
n
supply resumes. Although T16 Ch.
n
stops operat-
ing when the CLK_T16_
n
supply is suspended, the counter and registers retain the status before DEBUG mode
was entered. If the T16_
n
CLK.DBRUN bit = 1, the CLK_T16_
n
supply is not suspended and T16 Ch.
n
will keep
operating in DEBUG mode.
11.3.4 Event Counter Clock
The channel that supports the event counter function counts down at the rising edge of the EXCL
m
pin input signal
when the T16_
n
CLK.CLKSRC[1:0] bits are set to 0x3.
EXCLm pin input
Counter
x
x - 1
x - 2
x - 3
Figure 11.3.4.1 Count Down Timing
Note that the EXOSC clock is selected for the channel that does not support the event counter function.
11.4 Operations
11.4.1 Initialization
T16 Ch.
n
should be initialized and started counting with the procedure shown below.
1. Configure the T16 Ch.
n
operating clock (see “T16 Operating Clock”).
2. Set the T16_
n
CTL.MODEN bit to 1. (Enable count operation clock)
3. Set the T16_
n
MOD.TRMD bit.
(Select operation mode (Repeat mode or One-shot mode)).
4. Set the T16_
n
TR register.
(Set reload data (counter preset data))
5. Set the following bits when using the interrupt:
- Write 1 to the T16_
n
INTF.UFIF bit. (Clear interrupt flag)
- Set the T16_
n
INTE.UFIE bit to 1.
(Enable underflow interrupt)