15 16-BIT PWM TIMER (T16A5)
S1C33L26 TECHNICAL MANUAL
Seiko Epson Corporation
15-5
The counter is reset by the hardware if the counter reaches the compare B register value after the count starts.
Note: The counter is reset in sync with the counter clock. It may take long time depending on the count
clock selected. To make sure that the reset operation has finished, check if PRESET is set to 0 or
BUSY/T16A_CTL
x
register is set to 0 (idle) by reading these bits.
Counter RUN/STOP Control
15.5.2
Make the following settings before starting the count operation.
(1) Switch the input/output pin functions to be used for T16A5. Refer to the “I/O Port (GPIO)” chapter.
(2) Select operating modes. See Section 15.4.
(3) Select the clock source. See Section 15.3.
(4) Configure the timer outputs. See Section 15.6.
(5) If using interrupts, set the interrupt level and enable the T16A5 interrupts. See Section 15.7.
(6) Reset the counter to 0. See Section 15.5.1.
(7) Set comparison data (in comparator mode). See Section 15.4.1.
The T16A5 module provides PRUN/T16A_CTL
x
register to control the counter operation.
The counter starts counting when 1 is written to PRUN. Writing 0 to PRUN disables clock input and stops the
count.
This control does not affect the counter data. The counter data is retained even when the count is halted, allowing
resumption of the count from that data.
If PRUN and PRESET are written as 1 simultaneously, the counter starts counting after reset.
Notes: • Always make sure that BUSY/T16A_CTL
x
register is set to 0 (idle) before writing to the T16A_
CTL
x
register.
• Setting PRUN to 1 may not start the counter immediately as the counter starts counting in
sync with the count clock. The counter operation should be checked by reading PRUN (check
if it is set to 1) or BUSY (check if it is set to 0).
Reading Counter Values
15.5.3
The counter value can be read from T16ATC[15:0]/T16A_TC
x
register even if the counter is running. However, the
counter value should be read at once using a 16-bit transfer instruction. If data is read twice using an 8-bit transfer
instruction, the correct value may not be obtained due to occurrence of count up between readings.
Note: The counter value must be read from the T16A_TC
x
register of the channel selected using
T16SEL[1:0]/T16A_CTL
x
register.
Timing Charts
15.5.4
Comparator mode
PRUN
PRESET
T16A_ATMA_
x
T16A_ATMB_
x
Count clock
T16A_TC
x
Reset
Compare A
interrupt
Reset and
compare B
interrupt
Compare A
interrupt
Reset and
compare B
interrupt
0x2
0
1
2
3
4
5
0
1
2
3
4
5
0
1
0x5
5.4.1 Operation Timing in Comparator Mode
Figure 15.