10 16-BIT TIMERS (T16)
S1C17M12/M13 TECHNICAL MANUAL
Seiko Epson Corporation
10-3
(Rev. 1.2)
6. Set the following T16_
n
CTL register bits:
- Set the T16_
n
CTL.PRESET bit to 1. (Preset reload data to counter)
- Set the T16_
n
CTL.PRUN bit to 1. (Start counting)
10.4.2 Counter Underflow
Normally, the T16 counter starts counting down from the reload data value preset and generates an underflow sig-
nal when an underflow occurs. This signal is used to generate an interrupt and may be output to a specific periph-
eral circuit as a clock (T16 Ch.
n
must be set to repeat mode to generate a clock). The underflow cycle is determined
by the T16 Ch.
n
operating clock setting and reload data (counter initial value) set in the T16_
n
TR register.
The following shows the equations to calculate the underflow cycle and frequency:
TR + 1
f
CLK_T16_
n
T = ——————— f
T
= ——————— (Eq. 10.1)
f
CLK_T16_
n
TR + 1
Where
T:
Underflow cycle [s]
f
T
:
Underflow frequency [Hz]
TR:
T16_
n
TR register setting
f
CLK_T16_
n
: T16 Ch.
n
operating clock frequency [Hz]
10.4.3 Operations in Repeat Mode
T16 Ch.
n
enters repeat mode by setting the T16_
n
MOD.TRMD bit to 0.
In repeat mode, the count operation starts by writing 1 to the T16_
n
CTL.PRUN bit and continues until 0 is written.
A counter underflow presets the T16_
n
TR register value to the counter, so underflow occurs periodically. Select
this mode to generate periodic underflow interrupts or when using the timer to output a trigger/clock to the periph-
eral circuit.
Counter
0xffff
0x0000
Software control
Underflow interrupt
Underflow cycle
Time
T16_nTR
register setting
PRESET = 1
PRUN = 1
PRUN = 1
PRUN = 0
Figure 10.4.3.1 Count Operations in Repeat Mode
10.4.4 Operations in One-shot Mode
T16 Ch.
n
enters one-shot mode by setting the T16_
n
MOD.TRMD bit to 1.
In one-shot mode, the count operation starts by writing 1 to the T16_
n
CTL.PRUN bit and stops after the T16_
n
TR
register value is preset to the counter when an underflow has occurred. At the same time the counter stops, the T16_
n
CTL.PRUN bit is cleared automatically. Select this mode to stop the counter after an interrupt has occurred once,
such as for checking a specific lapse of time.