12-3
Seiko Epson Corporation
S1C31D50 TECHNICAL MANUAL
(Rev. 1.00)
12.4.
Operations
12.4.1.
Initialization
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)
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)
12.4.2.
Counter Underflow
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:
𝑇 =
𝑇𝑅+1
𝑓𝐶𝐿𝐾_𝑇16_𝑛
𝑓𝑇 =
𝑓𝐶𝐿𝐾_𝑇16_𝑛
𝑇𝑅+1
(Eq. 12.1)
Where
T:
Underflow cycle [s]
fT:
Underflow frequency [Hz]
TR:
T16_
n
TR register setting
f
CLK_T16_n
:
T16 Ch.
n
operating clock frequency [Hz]
12.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 peripheral circuit.
Figure 12.4.3.1 Count Operations in Repeat Mode
PRESET = 1
PRUN = 1
PRUN = 1
PRUN = 0
0xffff
0x0000
Counter
Underflow cycle
T16_nTR
register setting
Time
Software control
Underflow interrupt
Содержание S1C31D50
Страница 461: ...25 1 Seiko Epson Corporation S1C31D50 TECHNICAL MANUAL Rev 1 00 25 Package TQFP12 48PIN ...
Страница 462: ...25 2 Seiko Epson Corporation S1C31D50 TECHNICAL MANUAL Rev 1 00 QFP13 64PIN ...
Страница 463: ...25 3 Seiko Epson Corporation S1C31D50 TECHNICAL MANUAL Rev 1 00 TQFP14 80PIN ...
Страница 464: ...25 4 Seiko Epson Corporation S1C31D50 TECHNICAL MANUAL Rev 1 00 QFP15 100PIN ...