9 16-BIT TIMERS (T16)
S1C17F13 TeChniCal Manual
Seiko epson Corporation
9-3
(Rev. 1.0)
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)
Counter Underflow
9.4.2
Normally, the T16 counter starts counting down from the reload data value preset and generates an underflow signal
when an underflow occurs. This signal is used to generate an interrupt and may be output to a specific peripheral
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. 9.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]
Operations in Repeat Mode
9.4.3
T16 Ch.
n
enters repeat mode by setting 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_
n
TR
register setting
PRESET = 1
PRUN = 1
PRUN = 1
PRUN = 0
4.3.1 Count Operations in Repeat Mode
Figure 9.
Operations in One-shot Mode
9.4.4
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.