11 16-BiT TiMeRS (T16)
S1C17624/604/622/602/621 TeChniCal Manual
Seiko epson Corporation
11-5
One-shot mode
Counter
Repeat mode
Counter
0
1
n-1
n
n
Preset by resetting the timer
Preset by resetting the timer
Preset automatically
Underflow
Preset automatically
(n = Reload data)
0
1
n-1
n
n
Underflow
Timer starts
Timer starts
Preset automatically
0
1
n-1
n
Underflow
5.1 Preset Timing
Figure 11.
The underflow cycle can be calculated as follows:
TR + 1
ct_clk
Underflow interval = ———— [s]
Underflow cycle = ———— [Hz]
ct_clk
TR + 1
ct_clk: Count clock frequency [Hz]
TR:
Reload data (0–65535)
Timer Reset
11.6
The timer is reset by writing 1 to PRESER/T16_CTL
x
register. The reload data is preset and the counter is initial-
ized.
Timer Run/STOP Control
11.7
Make the following settings before starting the timer.
(1) Select the operating mode (internal clock mode, external clock mode, or pulse width measurement mode). See
Section 11.3.
(2) For internal clock or pulse width measurement mode, select the count clock (divided PCLK clock). See Section
11.3.1.
(3) Set the count mode (one-shot or repeat). See Section 11.4.
(4) Calculate the initial counter value and set it to the reload data register. See Section 11.5.
(5) Reset the timer to preset the counter to the initial value. See Section 11.6.
(6) When using timer interrupts, set the interrupt level and enable interrupts for the relevant timer channel. See
Section 11.9.
To start the timer, write 1 to PRUN/T16_CTL
x
register.
The timer starts counting down from the initial value or from the current counter value if no initial value was preset.
When the counter underflows, the timer outputs an underflow pulse and presets the counter to the initial value. An
interrupt request is sent simultaneously to the interrupt controller (ITC).
In one-shot mode, the timer stops counting.
In repeat mode, the timer continues counting from the reloaded initial value.
Write 0 to PRUN to stop the timer via the application program. The counter stops counting and retains the current
counter value until either the timer is reset or restarted. To restart the count from the initial value, the timer should be
reset before writing 1 to PRUN.
In pulse width measurement mode, the timer counts only while PRUN is set to 1 and the external input signal is at
the specified active level. When the external input signal becomes inactive, the timer stops counting and retains the
counter value until the next active level input. (See Figure 11.3.3.1.)