31 / 132 page

HT80C51 User Manual
Peripheral Modules – Timers 0 and 1
Handshake Solutions
© Philips Electronics N.V. 2005
Page 31 of 132
5.2.5.
Setting up the Timers
[Table 3] and [Table 4] give some values for TMOD, which can be used to set up Timer 0 in different
modes.
For these tables it is assumed that only one timer is being used at a time. If it is desired to run Timers
0 and 1 simultaneously, in any mode, the value in TMOD for Timer 0 must be ORed with the value
shown for Timer 1 ([Table 5] and [Table 6]).
For example, if it is desired to run Timer 0 in mode 1 GATE (external control), and Timer 1 in mode 2
COUNTER, then the value that must be loaded into TMOD is 69H (09H from [Table 3] ORed with 60H
from [Table 6]). Moreover, it is assumed that the user, at this point, is not ready to turn the timers on
and will do that at a different point in the program by setting bit TRx (in TCON) to 1.
5.2.5.1.
TIMER/COUNTER 0
TMOD
mode timer 0
function
internal control
(note 1)
external control
(note 2)
0
1
2
3
13bit timer
16bit timer
8bit auto-reload
two 8bit timers
00H
01H
02H
03H
08H
09H
0AH
0BH
[Table 3]
Timer 0 as a Timer
TMOD
mode timer 0
function
internal control
(note 1)
external control
(note 2)
0
1
2
3
13bit timer
16bit timer
8bit auto-reload
two 8bit timers
04H
05H
06H
07H
0CH
0DH
0EH
0FH
[Table 4]
Timer 0 as a Counter
NOTES:
1.
The Timer is turned ON/OFF by setting/clearing bit TR0 in the software.
2.
The Timer is turned ON, if both t01_int0_n_i = 1 and TR0 = 1 (hardware control).