P89LV51RB2_RC2_RD2_5 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 05 — 15 December 2009 46 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
8-bit microcontrollers with 80C51 core
6.9 PCA
The PCA includes a special 16-bit Timer that has five 16-bit capture/compare modules
associated with it. Each of the modules can be programmed to operate in one of four
modes: rising and/or falling edge capture, software timer, high-speed output, or PWM.
Each module has a pin associated with it in port 1. Module 0 is connected to P1.3 (CEX0),
module 1 to P1.4 (CEX1), etc. Registers CH and CL contain the current values of the free
running up counting 16-bit PCA timer. The PCA timer is a common time base for all five
modules and can be programmed to run at:
1
6
the oscillator frequency,
1
2
the oscillator
frequency, the Timer 0 overflow, or the input on the ECI pin (P1.2). The timer count source
is determined from the CPS1 and CPS0 bits in the CMOD SFR (see Table 35 and
Table 36).
Table 33. WDTC - Watchdog control register (address COH) bit allocation
Bit addressable; reset value: 00H.
Bit 7 6 5 4 3 2 1 0
Symbol - - - WDOUT WDRE WDTS WDT SWDT
Table 34. WDTC - Watchdog control register (address COH) bit descriptions
Bit Symbol Description
7 to 5 - Reserved for future use. Should be set to
‘0’ by user programs.
4 WDOUT Watchdog output enable. When this bit and WDRE are both set, a
Watchdog reset will drive the reset pin active for 32 clocks.
3 WDRE Watchdog timer reset enable. When set enables a watchdog timer
reset.
2 WDTS Watchdog timer reset flag, when set indicates that a WDT reset
occurred. Reset in software.
1 WDT Watchdog timer refresh. Set by software to force a WDT reset.
0 SWDT Start watchdog timer, when set starts the WDT. When cleared, stops
the WDT.
Fig 20. Programmable counter array
MODULE0
PCA TIMER/COUNTER
P1.3/CEX0
MODULE1
P1.4/CEX1
MODULE2
P1.5/CEX2
MODULE3
P1.6/CEX3
MODULE4
P1.7/CEX4
time base for PCA modules
Module functions:
- 16-bit capture
- 16-bit timer
- 16-bit high speed output
- 8-bit PWM
- watchdog timer (module 4 only)
16 bits
16 bits
002aaa532
P89LV51RB2_RC2_RD2_5 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 05 — 15 December 2009 47 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
8-bit microcontrollers with 80C51 core
In the CMOD SFR there are three additional bits associated with the PCA. They are CIDL
which allows the PCA to stop during Idle mode, WDTE which enables or disables the
Watchdog function on module 4, and ECF which when set causes an interrupt and the
PCA overflow flag CF (in the CCON SFR) to be set when the PCA timer overflows.
The watchdog timer function is implemented in module 4 of PCA.
The CCON SFR contains the run control bit (CR) for the PCA and the flags for the PCA
timer (CF) and each module (CCF4:0). To run the PCA the CR bit (CCON.6) must be set
by software. The PCA is shut off by clearing this bit. The CF bit (CCON.7) is set when the
PCA counter overflows and an interrupt will be generated if the ECF bit in the CMOD
register is set. The CF bit can only be cleared by software. Bits 0 through 4 of the CCON
register are the flags for the modules (bit 0 for module 0, bit 1 for module 1, etc.) and are
set by hardware when either a match or a capture occurs. These flags can only be cleared
by software. All the modules share one interrupt vector. The PCA interrupt system is
shown in Figure 21.
Each module in the PCA has a special function register associated with it. These registers
are: CCAPM0 for module 0, CCAPM1 for module 1, etc. The registers contain the bits that
control the mode that each module operates in.
The ECCFn bit (from CCAPMn.0 where n = 0, 1, 2, 3, or 4 depending on the module)
enables the CCFn flag in the CCON SFR to generate an interrupt when a match or
compare occurs in the associated module (see Figure 21).
PWM (CCAPMn.1) enables the pulse width modulation mode.
The TOGn bit (CCAPMn.2) when set causes the CEX output associated with the module
to toggle when there is a match between the PCA counter and the module’s
capture/compare register.
The match bit MATn (CCAPMn.3) when set will cause the CCFn bit in the CCON register
to be set when there is a match between the PCA counter and the module’s
capture/compare register.
The next two bits CAPNn (CCAPMn.4) and CAPPn (CCAPMn.5) determine the edge that
a capture input will be active on. The CAPN bit enables the negative edge, and the
CAPPn bit enables the positive edge. If both bits are set, both edges will be enabled and a
capture will occur for either transition.
The last bit in the register ECOMn (CCAPMn.6) when set enables the comparator
function.
There are two additional registers associated with each of the PCA modules. They are
CCAPnH and CCAPnL and these are the registers that store the 16-bit count when a
capture occurs or a compare should occur. When a module is used in the PWM mode
these registers are used to control the duty cycle of the output.
P89LV51RB2_RC2_RD2_5 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 05 — 15 December 2009 48 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
8-bit microcontrollers with 80C51 core
Fig 21. PCA interrupt system
002aaa533
PCA TIMER/COUNTER
MODULE0
CF CR - CCF4 CCF3 CCF2 CCF1 CCF0
MODULE1
MODULE2
MODULE3
MODULE4
ECF
ECCFn
IE.6
EC
IE.7
EA
CCAPMn.0CMOD.0
CCON
(D8H)
to
interrupt
priority
decoder
Table 35. CMOD - PCA counter mode register (address D9H) bit allocation
Not bit addressable; reset value: 00H.
Bit 7 6 5 4 3 2 1 0
Symbol CIDL WDTE - - - CPS1 CPS0 ECF
Table 36. CMOD - PCA counter mode register (address D9H) bit descriptions
Bit Symbol Description
7 CIDL Counter Idle Control: CIDL = 0 programs the PCA Counter to continue
functioning during Idle mode. CIDL = 1 programs it to be gated off
during idle.
6 WDTE Watchdog Timer Enable: WDTE = 0 disables watchdog timer function
on module 4. WDTE = 1 enables it.
5 to 3 - Reserved for future use. Should be set to
‘0’ by user programs.
2 to 1 CPS1,
CPS0
PCA Count Pulse Select (see
Table 37 below).
0 ECF PCA Enable Counter Overflow Interrupt: ECF = 1 enables CF bit in
CCON to generate an interrupt. ECF = 0 disables that function.

P89LV51RD2BN,112

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