17-4
Seiko Epson Corporation
S1C31D50 TECHNICAL MANUAL
(Rev. 1.00)
17.4.
Operations
17.4.1.
Initialization
T16B Ch.n should be initialized and started counting with the procedure shown below. Perform initial
settings for comparator mode when using T16B as an interval timer, PWM waveform generator, or
external event counter. Per- form initial settings for capture mode when using T16B to measure external
event periods/cycles.
Initial settings for comparator mode
1.
Configure the T16B Ch.
n
operating clock.
2.
Set the T16B_
n
CTL.MODEN bit to 1.
(Enable T16B operations)
3.
Set the following T16B_
n
CCCTL0 and T16B_
n
CCCTL1 register bits:
-
Set the T16B_
n
CCCTL
m
.CCMD bit to 0. *
(Set comparator mode)
-
T16B_
n
CCCTL
m
.CBUFMD[2:0] bits
(Configure compare buffer)
*Another circuit in the comparator/capture circuit pair (circuits 0 and 1, 2 and 3, 4 and 5) can be set to capture
mode.
Set the following bits when the TOUT
nm
output is used.
-
T16B_
n
CCCTL
m
.TOUTMT bit
(Select waveform generation signal)
-
T16B_
n
CCCTL
m
.TOUTMD[2:0] bits
(Select TOUT signal generation mode)
-
T16B_
n
CCCTL
m
.TOUTINV bit
(Select TOUT signal polarity)
4.
Set the T16B_
n
MC register.
(Set MAX counter data)
5.
Set the T16B_
n
CCR0 and T16B_
n
CCR1 registers.
(Set the counter comparison value)
6.
Set the following bits when using the interrupt:
-
Write 1 to the interrupt flags in the T16B_
n
INTF register.
(Clear interrupt flags)
-
Set the interrupt enable bits in the T16B_
n
INTE register to 1.
(Enable interrupts)
7.
Configure the DMA controller and set the following T16B control bits when using DMA transfer:
-
Write 1 to the DMA transfer request enable bits in the
-
T16B_
n
MZDMAEN and T16B_
n
CC
m
DMAEN registers.
(Enable DMA transfer requests)
8.
Set the following T16B_
n
CTL register bits:
-
T16B_
n
CTL.CNTMD[1:0] bits
(Select count up/down operation)
-
T16B_
n
CTL.ONEST bit
(Select one-shot/repeat operation)
-
Set the T16B_
n
CTL.PRESET bit to 1.
(Reset counter)
-
Set the T16B_
n
CTL.RUN bit to 1.
(Start counting)
Initial settings for capture mode
1.
Configure the T16B Ch.n operating clock.
2.
Set the T16B_nCTL.MODEN bit to 1.
(Enable T16B operations)
3.
Set the following T16B_nCCCTL0 and T16B_nCCCTL1 register bits:
-
Set the T16B_nCCCTLm.CCMD bit to 1. *
(Set capture mode)
-
T16B_nCCCTLm.SCS bit (Set synchronous/asynchronous mode)
-
T16B_nCCCTLm.CAPIS[1:0] bits
(Set trigger signal)
-
T16B_nCCCTLm.CAPTRG[1:0] bits
(Select trigger edge)
*Another circuit in the comparator/capture circuit pair (circuits 0 and 1, 2 and 3, 4 and 5) can be set to
comparator mode.
4.
Set the T16B_nMC register. (Set MAX counter data)
5.
Set the following bits when using the interrupt:
-
Write 1 to the interrupt flags in the T16B_nINTF register.
(Clear interrupt flags)
-
Set the interrupt enable bits in the T16B_nINTE register to 1.
(Enable interrupts)
6.
Configure the DMA controller and set the following T16B control bits when using DMA transfer:
-
Write 1 to the DMA transfer request enable bits in the T16B_nMZDMAEN and T16B_nCCmDMAEN
registers.
(
Enable DMA transfer requests)
7.
Set the following T16B_nCTL register bits:
-
T16B_nCTL.CNTMD[1:0] bits
(Select count up/down operation)
-
T16B_nCTL.ONEST bit
(Select one-shot/repeat operation)
-
Set the T16B_nCTL.PRESET bit to 1.
(Reset counter)
-
Set the T16B_nCTL.RUN bit to 1.
(Start counting)
Содержание 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 ...