
HT80C51 User Manual
Peripheral Modules – Timers 0 and 1
Handshake Solutions
© Philips Electronics N.V. 2005
Page 29 of 132
5.2.4.
Operation
The timer- or counter-function is selected by control bits C/Tx in the special function register TMOD.
These two timer/counters have four operating modes, which are selected by bit-pairs (M1, M0) in TMOD.
Modes 0, 1, and 2 are the same for both timers/counters.
Mode 3 is different. The four operating modes are described in the following text.
5.2.4.1.
Mode 0
Putting either timer into mode 0 makes it look like an 8048 timer, which is an 8-bit counter with a di-
vide-by-32 prescaler.[Figure 9] shows the mode 0 operation as it applies to timer 1.
In this mode, the timer register is configured as a 13-bit register. As the count rolls over from all 1s to
all 0s, it sets the timer interrupt flag TF1. The counted input is enabled to the timer when TR1 = 1 and
either GATE1 = 0 or pin t01_int1_n_i = 1. Setting GATE1 = 1 allows the timer to be controlled by
external input t01_int1_n_i, to facilitate pulse width measurements). TR1 is a control bit in the spe-
cial function register TCON. GATE1 is in TMOD.
The 13-bit register consists of all 8 bits of TH1 and the lower 5 bits of TL1. The upper 3 bits of TL1 are
indeterminate and should be ignored. Setting the run flag (TR1) does not clear the registers.
Mode 0 operation is the same for the timer 0 as for timer 1. Substitute TR0, TF0, GATE0, C/T0,
t0_count_i and t01_int0_n_i for the corresponding timer 1 signals in [Figure 9].
t
01_clk_i
t1_count_i
t01_int1_n_i
GATE1
TR1
TH1
(5 Bits)
TH1
(8 Bits)
TF1
interrupt
Control
C/T1=1
C/T1=0
[Figure 9]
Timer/Counter mode 0: 13bit counter
5.2.4.2.
Mode 1
Mode 1 is the same as mode 0, except that the timer register is being run with all 16 bits.
5.2.4.3.
Mode 2
Mode 2 configures the timer register as an 8bit counter (TL1) with automatic reload, as shown in
[Figure 10]. Overflow from TL1 not only sets TF1, but also reloads TL1 with the contents of TH1, which is
preset by software. The reload leaves TH1 unchanged. Mode 2 operation is the same for timer/counter
0.