15 16-BIT PWM TIMERS (T16B)
S1C17M20/M21/M22/M23/M24/M25
Seiko Epson Corporation
15-9
TECHNICAL MANUAL (Rev. 1.0)
Counter
0xffff
0x0000
Count cycle
Time
Comparison value
(T16BnCCRm register)
MAX value
(T16BnMC register)
RUN = 1
CMPCAPmIF = 1
CNTMAXIF = 1
CMPCAPmIF = 1
CNTZEROIF = 1
CMPCAPmIF = 1
CNTMAXIF = 1
PRESET = 1
(3) Repeat up/down count mode
Compare period
during counting down
Compare period
during counting up
(Note that the T16BnINTF.CMPCAPmIF/CNTMAXIF/CNTZEROIF bit clearing operations via software are omitted from the figure.)
Figure 15.4.3.1 Operation Examples in Comparator Mode
The time from counter = 0x0000 or MAX value to occurrence of a compare interrupt (compare period) and the
time to occurrence of a counter MAX or counter zero interrupt (count cycle) can be calculated as follows:
During counting up
(CC + 1)
(MAX + 1)
Compare period = ————— [s]
Count cycle = —————— [s]
(Eq. 15.1)
f
CLK_T16B
f
CLK_T16B
During counting down
(MAX - CC + 1)
(MAX + 1)
Compare period = ——————— [s]
Count cycle = —————— [s]
(Eq. 15.2)
f
CLK_T16B
f
CLK_T16B
Where
CC: T16B
n
CCR
m
register setting value (0 to 65,535)
MAX: T16B
n
MC register setting value (0 to 65,535)
f
CLK_T16B
: Count clock frequency [Hz]
The comparator MATCH signal and counter MAX/ZERO signals are also used to generate a timer output wave-
form (TOUT). Refer to “TOUT Output Control” for more information.
Compare buffer
The comparator loads the comparison value, which has been written to the T16B
n
CCR
m
register, to the
compare buffer before comparing it with the counter value. For example, when generating a PWM wave-
form, the waveform with the desired duty ratio may not be generated if the comparison value is altered
asynchronous to the count operation. To avoid this problem, the timing to load the comparison value to the
compare buffer can be configured using the T16B
n
CCCTL
m
.CBUFMD[2:0] bits for synchronization with
the count operation.
Counter
0xffff
0x0000
(1.1) T16BnCCCTLm.CBUFMD[2:0] bits = 0x0
(1) Repeat up count mode
Time
RUN = 1
Data (W)
→
MC[15:0]
Data (W)
→
CC[15:0]
Data (W)
→
CC[15:0]
Data (W)
→
CC[15:0]
MODEN = 1
Count cycle
Compare buffer
value
MAX value
(T16BnMC register)
CMPCAPmIF = 1
CMPCAPmIF = 1
CMPCAPmIF = 1
CMPCAPmIF = 1
CNTMAXIF = 1 CNTMAXIF = 1
CNTMAXIF = 1
PRESET = 1
Software operation
Hardware operation
Compare period