8-3
TIMER/COUNTERS AND WATCHDOG TIMER
For timer operation (C/Tx# = 0), the timer register counts the divided-down system clock. The
timer register is incremented once every peripheral cycle, i.e., once every six states (see section
2.2.2, “Clock and Reset Unit”). Since six states equals 12 clock cycles, the timer clock rate is
F
OSC
/12. Exceptions are the timer 2 baud rate and clock-out modes, where the timer register is
incremented by the system clock divided by two.
For counter operation (C/Tx# = 1), the timer register counts the negative transitions on the Tx ex-
ternal input pin. The external input is sampled during every S5P2 state. Section 2.2.2, “Clock and
Reset Unit,” describes the notation for the states in a peripheral cycle. When the sample is high
in one cycle and low in the next, the counter is incremented. The new count value appears in the
register during the next S3P1 state after the transition was detected. Since it takes 12 states (24
oscillator periods) to recognize a negative transition, the maximum count rate is 1/24 of the os-
cillator frequency. There are no restrictions on the duty cycle of the external input signal, but to
ensure that a given level is sampled at least once before it changes, it should be held for at least
one full peripheral cycle.
8.3
TIMER 0
Timer 0 functions as either a timer or event counter in four modes of operation. Figures 8-2, 8-3,
and 8-4 show the logical configuration of each mode.
Timer 0 is controlled by the four low-order bits of the TMOD register (Figure 8-5) and bits 5, 4,
1, and 0 of the TCON register (Figure 8-6). The TMOD register selects the method of timer gating
(GATE0), timer or counter operation (T/C0#), and mode of operation (M10 and M00). The
TCON register provides timer 0 control functions: overflow flag (TF0), run control (TR0), inter-
rupt flag (IE0), and interrupt type control (IT0).
Table 8-2. External Signals
Signal
Name
Type
Description
Alternate
Function
T2
I/O
Timer 2 Clock Input/Output. This signal is the external clock input
for the timer 2 capture mode; and it is the timer 2 clock-output for the
clock-out mode.
P1.0
T2EX
I
Timer 2 External Input. In timer 2 capture mode, a falling edge
initiates a capture of the timer 2 registers. In auto-reload mode, a
falling edge causes the timer 2 registers to be reloaded. In the up-
down counter mode, this signal determines the count direction:
high = up, low = down.
P1.1
INT1:0#
I
External Interrupts 1:0. These inputs set the IE1:0 interrupt flags in
the TCON register. TCON bits IT1:0 select the triggering method:
IT1:0 = 1 selects edge-triggered (high-to-low);IT1:0 = 0 selects level-
triggered (active low). INT1:0# also serves as external run control for
timer 1:0 when selected by TCON bits GATE1:0#.
P3.3:2
T1:0
I
Timer 1:0 External Clock Inputs. When timer 1:0 operates as a
counter, a falling edge on the T1:0 pin increments the count.
P3.5:4
Summary of Contents for 8XC251SA
Page 2: ......
Page 3: ...May 1996 8XC251SA 8XC251SB 8XC251SP 8XC251SQ Embedded Microcontroller User s Manual...
Page 18: ......
Page 19: ...1 Guide to This Manual...
Page 20: ......
Page 30: ......
Page 31: ...2 Architectural Overview...
Page 32: ......
Page 41: ...3 Address Spaces...
Page 42: ......
Page 63: ...4 Device Configuration...
Page 64: ......
Page 81: ...5 Programming...
Page 82: ......
Page 102: ......
Page 103: ...6 Interrupt System...
Page 104: ......
Page 120: ......
Page 121: ...7 Input Output Ports...
Page 122: ......
Page 132: ......
Page 133: ...8 Timer Counters and Watchdog Timer...
Page 134: ......
Page 153: ...9 Programmable Counter Array...
Page 154: ......
Page 170: ......
Page 171: ...10 Serial I O Port...
Page 172: ......
Page 187: ...11 Minimum Hardware Setup...
Page 188: ......
Page 197: ...12 Special Operating Modes...
Page 198: ......
Page 206: ......
Page 207: ...13 External Memory Interface...
Page 208: ......
Page 239: ...14 Programming and Verifying Nonvolatile Memory...
Page 240: ......
Page 250: ......
Page 251: ...A Instruction Set Reference...
Page 252: ......
Page 390: ......
Page 391: ...B Signal Descriptions...
Page 392: ......
Page 400: ......
Page 401: ...C Registers...
Page 402: ......
Page 436: ......
Page 437: ...Glossary...
Page 438: ......
Page 446: ......
Page 447: ...Index...
Page 448: ......
Page 458: ......