Download Print this page

Epson S1C31D50 Technical Instructions page 152

Cmos 32-bit single chip microcontroller
Hide thumbs Also See for S1C31D50:

Advertisement

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_nCTL.MODEN bit to 1.
3. Set the T16_nMOD.TRMD bit.
4. Set the T16_nTR register.
5. Set the following bits when using the interrupt:
Write 1 to the T16_nINTF.UFIF bit. (Clear interrupt flag)
-
Set the T16_nINTE.UFIE bit to 1.
-
6. Set the following T16_nCTL register bits:
Set the T16_nCTL.PRESET bit to 1. (Preset reload data to counter)
-
Set the T16_nCTL.PRUN bit to 1.
-
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_nTR register.
The following shows the equations to calculate the underflow cycle and frequency:
�� =
��������_��16_��
Where
T:
fT:
TR:
f
:
CLK_T16_n
12.4.3. Operations in Repeat Mode
T16 Ch.n enters repeat mode by setting the T16_nMOD.TRMD bit to 0.
In repeat mode, the count operation starts by writing 1 to the T16_nCTL.PRUN bit and continues until 0
is written. A counter underflow presets the T16_nTR 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.
0xffff
Counter
0x0000
Software control
Underflow interrupt
S1C31D50 TECHNICAL MANUAL
(Rev. 1.00)
(Enable count operation clock)
(Select operation mode (Repeat mode or One-shot mode)).
(Set reload data (counter preset data))
(Enable underflow interrupt)
(Start counting)
����+1
���� =
Underflow cycle [s]
Underflow frequency [Hz]
T16_nTR register setting
T16 Ch.n operating clock frequency [Hz]
Underflow cycle
PRESET = 1
PRUN = 1
Figure 12.4.3.1 Count Operations in Repeat Mode
Seiko Epson Corporation
��������_��16_��
(Eq. 12.1)
����+1
PRUN = 0
PRUN = 1
T16_nTR
register setting
Time
12-3

Advertisement

loading