DatasheetQ Logo
Electronic component search and free download site. Transistors,MosFET ,Diode,Integrated circuits

P89C51 Просмотр технического описания (PDF) - Philips Electronics

Номер в каталоге
Компоненты Описание
производитель
P89C51 Datasheet PDF : 39 Pages
First Prev 11 12 13 14 15 16 17 18 19 20 Next Last
Philips Semiconductors
80C51 8-bit microcontroller family
4K/8K/16K/32K Flash
Product data
89C51/89C52/89C54/89C58
TIMER 0 AND TIMER 1 OPERATION
Timer 0 and Timer 1
The “Timer” or “Counter” function is selected by control bits C/T 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.
Mode 0
Putting either Timer into Mode 0 makes it look like an 8048 Timer,
which is an 8-bit Counter with a divide-by-32 prescaler. Figure 2
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 GATE = 0 or INT1 = 1. (Setting GATE = 1 allows the
Timer to be controlled by external input INT1, to facilitate pulse width
measurements). TR1 is a control bit in the Special Function Register
TCON (Figure 3). GATE 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, and INT0 for the corresponding Timer 1
signals in Figure 2. There are two different GATE bits, one for Timer
1 (TMOD.7) and one for Timer 0 (TMOD.3).
Mode 1
Mode 1 is the same as Mode 0, except that the Timer register is
being run with all 16 bits.
Mode 2
Mode 2 configures the Timer register as an 8-bit Counter (TL1) with
automatic reload, as shown in Figure 4. 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.
Mode 3
Timer 1 in Mode 3 simply holds its count. The effect is the same as
setting TR1 = 0.
Timer 0 in Mode 3 establishes TL0 and TH0 as two separate
counters. The logic for Mode 3 on Timer 0 is shown in Figure 5. TL0
uses the Timer 0 control bits: C/T, GATE, TR0, and TF0, as well as
the INT0 pin. TH0 is locked into a timer function (counting machine
cycles) and takes over the use of TR1 and TF1 from Timer 1. Thus,
TH0 now controls the “Timer 1” interrupt.
Mode 3 is provided for applications requiring an extra 8-bit timer on
the counter. With Timer 0 in Mode 3, an 80C51 can look like it has
three Timer/Counters. When Timer 0 is in Mode 3, Timer 1 can be
turned on and off by switching it out of and into its own Mode 3, or
can still be used by the serial port as a baud rate generator, or in
fact, in any application not requiring an interrupt.
TMOD
Address = 89H
Not Bit Addressable
Reset Value = 00H
7
6
5
4
3
2
1
0
GATE C/T M1 M0 GATE C/T
M1
M0
TIMER 1
TIMER 0
GATE
C/T
Gating control when set. Timer/Counter “x” is enabled only while “INTx” pin is high and
“TRx” control pin is set. when cleared Timer “x” is enabled whenever “TRx” control bit is set.
Timer or Counter Selector cleared for Timer operation (input from in=ternal system clock.)
Set for Counter operation (input from “Tx” input pin).
M1
M0
OPERATING
0
0
8048 Timer “TLx” serves as 5-bit prescaler.
0
1
16-bit Timer/Counter “THx” and “TLx” are cascaded; there is no prescaler.
1
0
8-bit auto-reload Timer/Counter “THx” holds a value which is to be reloaded
into “TLx” each time it overflows.
1
1
(Timer 0) TL0 is an 8-bit Timer/Counter controlled by the standard Timer 0 control bits.
TH0 is an 8-bit timer only controlled by Timer 1 control bits.
1
1
(Timer 1) Timer/Counter 1 stopped.
SU01514
Figure 1. Timer/Counter 0/1 Mode Control (TMOD) Register
2002 Jan 15
11

Share Link: 

datasheetq.com  [ Privacy Policy ]Request Datasheet ] [ Contact Us ]