P89CV51RB2_RC2_RD2_3 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 03 — 25 August 2009 28 of 76
NXP Semiconductors
P89CV51RB2/RC2/RD2
80C51 with 1 kB RAM, SPI
6.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 fixed divide-by-32 prescaler. Figure 7 shows Mode 0 operation.
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 TFn. The count input is enabled to the
timer when TRn = 1 and either GATE = 0 or INTn = 1. (Setting GATE = 1 allows the timer
to be controlled by external input INTn, to facilitate pulse width measurements). TRn is a
control bit in the special function register TCON (Table 17). The GATE bit is in the TMOD
register.
The 13-bit register consists of all 8 bits of THn and the lower 5 bits of TLn. The upper
3 bits of TLn are indeterminate and should be ignored. Setting the run flag (TRn) does not
clear the registers.
Mode 0 operation is the same for Timer 0 and Timer 1; see Figure 7. There are two
different GATE bits, one for Timer 1 (TMOD.7) and one for Timer 0 (TMOD.3).
Table 17. TCON - Timer/Counter control register (address 88H) bit description
Bit Symbol Description
7 TF1 Timer 1 overflow Flag. Set by hardware on timer/counter overflow. Cleared
by hardware when the processor vectors to Timer 1 interrupt routine, or by
software.
6 TR1 Timer 1 Run control bit. Set/cleared by software to turn timer/counter 1
on/off.
5 TF0 Timer 0 overflow Flag. Set by hardware on timer/counter overflow. Cleared
by hardware when the processor vectors to Timer 0 interrupt routine, or by
software.
4 TR0 Timer 0 Run control bit. Set/cleared by software to turn timer/counter 0
on/off.
3 IE1 Interrupt 1 Edge flag. Set by hardware when external interrupt 1
edge/LOW-state is detected. Cleared by hardware when the interrupt is
processed, or by software.
2 IT1 Interrupt 1 Type control bit. Set/cleared by software to specify falling
edge/LOW-state that triggers external interrupt 1.
1 IE0 Interrupt 0 Edge flag. Set by hardware when external interrupt 0
edge/LOW-state is detected. Cleared by hardware when the interrupt is
processed, or by software.
0 IT0 Interrupt 0 Type control bit. Set/cleared by software to specify falling
edge/LOW-state that triggers external interrupt 0.
Fig 7. Timer/counter 0 or 1 in Mode 0 (13-bit counter)
002aaa519
osc/6
Tn pin
TRn
TnGate
INTn pin
C/T = 0
C/T = 1
TLn
(5-bits)
THn
(8-bits)
TFn
control
overflow
interrupt
P89CV51RB2_RC2_RD2_3 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 03 — 25 August 2009 29 of 76
NXP Semiconductors
P89CV51RB2/RC2/RD2
80C51 with 1 kB RAM, SPI
6.4.2 Mode 1
Mode 1 is the same as Mode 0, except that all 16 bits of the timer register (THn and TLn)
are used; see Figure 8.
6.4.3 Mode 2
Mode 2 configures the timer register as an 8-bit counter (TLn) with automatic reload, as
shown in Figure 9. Overflow from TLn not only sets TFn, but also reloads TLn with the
contents of THn, which must be preset by software. The reload leaves THn unchanged.
Mode 2 operation is the same for Timer 0 and Timer 1.
6.4.4 Mode 3
When Timer 1 is in Mode 3 it is stopped (holds its count). The effect is the same as setting
TR1=0.
Timer 0 in Mode 3 establishes TL0 and TH0 as two separate 8-bit counters. The logic for
Mode 3 and Timer 0 is shown in Figure 10. TL0 uses the Timer 0 control bits: T0C/T,
T0GATE, TR0, INT0, and TF0. 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 that require an extra 8-bit timer. With Timer 0 in
mode 3, the P89CV51RB2/RC2/RD2 can look like it has an additional timer.
Note: When Timer 0 is in Mode 3, Timer 1 can be turned on and off by switching it into
and out of its own Mode 3. It can still be used by the serial port as a baud rate generator,
or in any application not requiring an interrupt.
Fig 8. Timer/counter 0 or 1 in Mode 1 (16-bit counter)
002aaa520
osc/6
Tn pin
TRn
TnGate
INTn pin
C/T = 0
C/T = 1
TLn
(8-bits)
THn
(8-bits)
TFn
control
overflow
interrupt
Fig 9. Timer/counter 0 or 1 in Mode 2 (8-bit auto-reload)
002aaa521
osc/6
Tn pin
TRn
TnGate
INTn pin
TLn
(8-bits)
THn
(8-bits)
TFn
control
overflow
reload
interrupt
C/T = 0
C/T = 1
P89CV51RB2_RC2_RD2_3 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 03 — 25 August 2009 30 of 76
NXP Semiconductors
P89CV51RB2/RC2/RD2
80C51 with 1 kB RAM, SPI
6.5 Timer 2
Timer 2 is a 16-bit timer/counter which can operate as either an event timer or an event
counter, as selected by C/T2 in the special function register T2CON. Timer 2 has four
operating modes: Capture, Auto-reload (up or down counting), Clock-out, and Baud rate
generator which are selected according to Table 18 using T2CON (Table 19 and Table 20)
and T2MOD (Table 21 and Table 22).
Fig 10. Timer/counter 0 Mode 3 (two 8-bit counters)
002aaa522
osc/2
TR1
TR0
TnGate
INT0 pin
TL0
(8-bits)
TF0
control
overflow
interrupt
TH0
(8-bits)
TF1
control
overflow
interrupt
osc/6
T0 pin
C/T = 0
C/T = 1
Table 18. Timer 2 operating mode
RCLK + TCLK CP/RL2 TR2 T2OE Mode
0 0 1 0 16-bit auto reload
0 1 1 0 16-bit capture
0 0 1 1 Programmable clock-out
1 X 1 0 Baud rate generator
X X 0 X off
Table 19. T2CON - Timer/Counter 2 control register (address C8H) bit allocation
Bit addressable; reset value: 00H.
Bit 7 6 5 4 3 2 1 0
Symbol TF2 EXF2 RCLK TCLK EXEN2 TR2 C/
T2 CP/RL2
Table 20. T2CON - Timer/Counter 2 control register (address C8H) bit description
Bit Symbol Description
7 TF2 Timer 2 overflow flag set by a Timer 2 overflow and must be cleared by
software. TF2 will not be set when either RCLK or TCLK = 1 or when Timer
2 is in Clock-out mode.
6 EXF2 Timer 2 external flag is set when Timer 2 is in capture, reload or baud rate
mode, EXEN2 = 1 and a negative transition on T2EX occurs. If Timer 2
interrupt is enabled EXF2 = 1 causes the CPU to vector to the Timer 2
interrupt routine. EXF2 must be cleared by software.
5 RCLK Receive clock flag. When set, causes the UART to use Timer 2 overflow
pulses for its receive clock in modes 1 and 3. RCLK = 0 causes Timer 1
overflow to be used for the receive clock.

P89CV51RD2FA,512

Mfr. #:
Manufacturer:
NXP Semiconductors
Description:
IC MCU 8BIT 64KB FLASH 44PLCC
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union