16-Bit Timer Run/Stop Control - Epson S1C17001 Technical Manual

Cmos 16-bit single chip microcontroller
Table of Contents

Advertisement

11 16-BIT TIMER (T16)

11.6 16-bit Timer RUN/STOP Control

Make the following settings before starting the 16-bit timer.
(1) Select the operating mode (Internal clock, External clock, or Pulse width measurement). See Section 11.2.
(2) For Internal clock or Pulse width measurement mode, select the count clock (prescaler output clock). See Sec-
tion 11.2.1.
(3) Set the count mode (One-shot or Repeat). See Section 11.3.
(4) Calculate the initial counter value and set the reload data register. See Section 11.4.
(5) Reset the timer and preset the counter to the initial value. See Section 11.5.
(6) If using timer interrupts, set the interrupt level and allow interrupts for the relevant timer channel. See Section
11.8.
To start the 16-bit timer, write 1 to PRUN (D0/T16_CTLx register).
∗ PRUN: Timer Run/Stop Control Bit in the 16-bit Timer Ch.x Control (T16_CTLx) Register (D0/0x4226/0x4246/
0x4266)
The timer starts counting down from the initial value or from the current counter value if no initial value was pre-
set. 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).
If One-shot mode is set, the timer stops the count.
If Repeat mode is set, the timer continues to count from the reloaded initial value.
Write 0 to PRUN to stop the 16-bit 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.
One-shot mode
Count clock
PRESER writing
PRUN
Counter
Interrupt request
Repeat mode
Count clock
PRESER writing
PRUN
Counter
Interrupt request
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 16-bit timer stops counting and re-
tains the counter value until the next active level input. (See Figure 11.2.3.1.)
114
Set by software
n
n-1
1
0
Set by software
n
n-1
1
0
Figure 11.6.1: Count operation
EPSON
Reset by hardware
n
Reset by software
n
n-1
1
0
S1C17001 TECHNICAL MANUAL
n
n-1

Advertisement

Table of Contents
loading

Table of Contents