T16A5: Reading Counter Values - Epson S1C33L26 Technical Manual

Cmos 32-bit single chip microcontroller
Table of Contents

Advertisement

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_CTLx register is set to 0 (idle) by reading these bits.
15.5.2
Counter RUN/STOP Control
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_CTLx 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_CTLx register is set to 0 (idle) before writing to the T16A_
CTLx 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).
15.5.3
Reading Counter Values
The counter value can be read from T16ATC[15:0]/T16A_TCx 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_TCx register of the channel selected using
T16SEL[1:0]/T16A_CTLx register.
15.5.4
Timing Charts
Comparator mode
PRUN
PRESET
T16A_ATMA_x
T16A_ATMB_x
Count clock
T16A_TCx
Reset
S1C33L26 TECHNICAL MANUAL
0
1
2
3
4
Compare A
interrupt
Figure 15.
5.4.1 Operation Timing in Comparator Mode
Seiko Epson Corporation
15 16-BIT PWM TIMER (T16A5)
0x2
0x5
5
0
1
2
3
Reset and
Compare A
compare B
interrupt
interrupt
4
5
0
1
Reset and
compare B
interrupt
15-5

Advertisement

Table of Contents
loading

Table of Contents