9 16-BIT TIMERS (T16)
9-2
Seiko epson Corporation
S1C17F13 TeChniCal Manual
(Rev. 1.0)
Clock Settings
9.3
T16 Operating Clock
9.3.1
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)
Clock Supply in SLEEP Mode
9.3.2
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.
Clock Supply in DEBUG Mode
9.3.3
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.
Event Counter Clock
9.3.4
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.
EXCL
m
pin input
Counter
x
x
- 1
x
- 2
x
- 3
3.3.1 Count Down Timing
Figure 9.
Note that the EXOSC clock is selected for the channel that does not support the event counter function.
Operations
9.4
Initialization
9.4.1
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)