EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Timer;Counter; Registers Related to Timers

Default Icon
901 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
STC8A8K64D4 Series Manual
- 280 -
13 Timer/Counter
Five 16-bit Timers/Counters are integrated in STC8A8K64D4 series of microcontrollers: T0, T1, T2, T3 and T4.
All of them can be used as timer or counter. For T0 and T1, the ‘timer or ‘counter function is selected by the control
bits C/T in the special function register TMOD. For T2, the ‘timer or ‘counter function is selected by the control bit
T2_C/T in the special function register AUXR. For T3, the ‘timer or ‘counter function is selected by the control bit
T3_C/T in the special function register T4T3M. For T4, the ‘timer or ‘counter function is selected by the control bit
T4_C/T in the special function register T4T3M. The core of the timer/counter is a up counter, the essence of which is
counting pulses. The only difference of ‘timer mode and ‘counter mode is the different counting pulses sources. If the
counting pulse is from the system clock, the timer/counter runs in the timing mode, it counts once every 12 clocks or
one clock. If the counting pulse is from the microcontroller external pins, the timer/counter runs in counting mode, it
counts once every pulse.
When T0, T1 and T2 are operating in ‘timer mode, T0x12, T1x12 and T2x12 in AUXR register are used to
determine the clocks of T0, T1 and T2 are system clock/12 or system clock/1. When T3 and T4 are operating in ‘timer
mode, T3x12 and T4x12 in the T4T3M register determine the clocks of T3 and T4 are system clock/12 or system
clock/1. When the timer/counters are operating in ‘counter mode, the frequency of the external pulse is not divided.
T0 has four operating modes which are selected by bit-pairs (M1, M0) in TMOD. The four modes are mode 0 (16-
bit auto-reload mode), mode 1 (16-bit non-auto-reload mode), mode 2 (8-bit auto-reload mode) and mode 3 (16-bit
auto-reload mode whose interrupt can not be disabled). And for T1, all modes except mode 3 are the same as T0. The
mode 3 of T1 is invalid and stops counting. For T2, T3 and T4, they only have one mode: 16-bit auto-reload mode.
Besides being used as timer/counters, T2, T3 and T4 can also be as the baud-rate generators of UARTs and
programmable clock outputs.
13.1 Registers Related to Timers
Symbol
Description
Address
Bit Address and Symbol
Reset
value
B7
B6
B5
B4
B3
B2
B1
B0
TCON
Timer 0 and 1 control register
88H
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
0000,0000
TMOD
Timer 0 and 1 mode register
89H
GATE
C/T
M1
M0
GATE
C/T
M1
M0
0000,0000
TL0
Timer 0 low byte register
8AH
0000,0000
TL1
Timer 1 low byte register
8BH
0000,0000
TH0
Timer 0 high byte register
8CH
0000,0000
TH1
Timer 1 high byte register
8DH
0000,0000
AUXR
Auxiliary register 1
8EH
T0x12
T1x12
UART_M0x6
T2R
T2_C/T
T2x12
EXTRAM
S1ST2
0000,0001
INTCLKO
External interrupt and clock output
control register
8FH
-
EX4
EX3
EX2
-
T2CLKO
T1CLKO
T0CLKO
x000,x000
WKTCL
Wake-up Timer Control Register
low
AAH
1111,1111
WKTCH
Wake-up Timer Control Register
high byte
ABH
WKTEN
0111,1111
T4T3M
Timer4 and Timer 3 Control
Register
D1H
T4R
T4_C/T
T4x12
T4CLKO
T3R
T3_C/T
T3x12
T3CLKO
0000,0000
T4H
Timer 4 high byte register
D2H
0000,0000
T4L
Timer 4 low byte register
D3H
0000,0000
T3H
Timer 3 high byte register
D4H
0000,0000
T3L
Timer 3 low byte register
D5H
0000,0000
T2H
Timer 2 high byte register
D6H
0000,0000
T2L
Timer 2 low byte register
D7H
0000,0000
Symbol
Description
Address
Bit Address and Symbol
Reset
value
B7
B6
B5
B4
B3
B2
B1
B0
TM2PS
Timer 2 clock prescaler register
FEA2H
0000,0000
TM3PS
Timer 3 clock prescaler register
FEA3H
0000,0000
TM4PS
Timer 4 clock prescaler register
FEA4H
0000,0000

Table of Contents

Related product manuals