P89LV51RB2_RC2_RD2_5 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 05 — 15 December 2009 52 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
8-bit microcontrollers with 80C51 core
6.9.3 High-speed output mode
In this mode (Figure 24) the CEX output (on port 1) associated with the PCA module will
toggle each time a match occurs between the PCA counter and the module’s capture
registers. To activate this mode the TOGn, MATn, and ECOMn bits in the module’s
CCAPMn SFR must be set.
Fig 23. PCA compare mode
002aaa539
CF CR - CCF4 CCF3 CCF2 CCF1 CCF0
CCON
(D8H)
PCA
interrupt
- ECOMn
00 100
CAPPn CAPNn MATn TOGn PWMn ECCFn
CCAPMn, n = 0 to 4
(DAH to DEH)
16-BIT COMPARATOR
PCA timer/counter
CH CL
match
(to CCFn)
CCAPnH CCAPnL
enable
write to
CCAPnH
write to
CCAPnL
reset
01
P89LV51RB2_RC2_RD2_5 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 05 — 15 December 2009 53 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
8-bit microcontrollers with 80C51 core
6.9.4 PWM mode
All of the PCA modules can be used as PWM outputs (Figure 25). Output frequency
depends on the source for the PCA timer.
All of the modules will have the same frequency of output because they all share only one
PCA timer. The duty cycle of each module is independently variable using the module’s
capture register CCAPnL. When the value of the PCA CL SFR is less than the value in the
Fig 24. PCA high-speed output mode
002aaa540
toggle
CEXn
CF CR - CCF4 CCF3 CCF2 CCF1 CCF0
CCON
(D8H)
PCA
interrupt
- ECOMn
00 100
CAPPn CAPNn MATn TOGn PWMn ECCFn
CCAPMn, n = 0 to 4
(DAH to DEH)
16-BIT COMPARATOR
PCA timer/counter
CH CL
match
(to CCFn)
CCAPnH CCAPnL
enable
write to
CCAPnH
write to
CCAPnL
reset
01
Fig 25. PCA PWM mode
002aaa541
- ECOMn
01 0 001 1
CAPPn CAPNn MATn TOGn PWMn ECCFn
CCAPMn, n = 0 to 4
(DAH to DEH)
CCAPnL
8-BIT COMPARATOR
PCA timer/counter
CCAPnH
CL
enable
CEXn
CL < CCAPnL
CL CCAPnL
0
1
P89LV51RB2_RC2_RD2_5 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 05 — 15 December 2009 54 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
8-bit microcontrollers with 80C51 core
module’s CCAPnL SFR the output will be LOW, when it is equal to or greater than, the
output will be HIGH. When CL overflows from FF to 00, CCAPnL is reloaded with the
value in CCAPnH. This allows updating the PWM without glitches. The PWMn and
ECOMn bits in the module’s CCAPMn register must be set to enable the PWM mode.
6.9.5 PCA watchdog timer
An on-board watchdog timer is available with the PCA to improve the reliability of the
system without increasing chip count. Watchdog timers are useful for systems that are
susceptible to noise, power glitches, or electrostatic discharge. Module 4 is the only PCA
module that can be programmed as a Watchdog. However, this module can still be used
for other modes if the Watchdog is not needed. Figure 25 shows a diagram of how the
Watchdog works. The user pre-loads a 16-bit value in the compare registers. Just like the
other compare modes, this 16-bit value is compared to the PCA timer value. If a match is
allowed to occur, an internal reset will be generated. This will not cause the RST pin to be
driven HIGH.
User’s software then must periodically change (CCAP4H, CCAP4L) to keep a match from
occurring with the PCA timer (CH, CL). This code is given in the WATCHDOG routine
shown below.
In order to hold off the reset, the user has three options:
Periodically change the compare value so it will never match the PCA timer.
Periodically change the PCA timer value so it will never match the compare values.
Disable the Watchdog by clearing the WDTE bit before a match occurs and then
re-enable it.
The first two options are more reliable because the watchdog timer is never disabled as in
option #3. If the program counter ever goes astray, a match will eventually occur and
cause an internal reset. The second option is also not recommended if other PCA
modules are being used. Remember, the PCA timer is the time base for all modules;
changing the time base for other modules would not be a good idea. Thus, in most
applications the first solution is the best option.
;CALL the following WATCHDOG subroutine periodically.
CLR EA ;Hold off interrupts
MOV CCAP4L,#00 ;Next compare value is within 255 counts of
current PCA timer value
MOV CCAP4H,CH
SETB EA ;Re-enable interrupts
RET
This routine should not be part of an interrupt service routine, because if the program
counter goes astray and gets stuck in an infinite loop, interrupts are still serviced and the
Watchdog continues to reset. Thus, the purpose of the Watchdog would be defeated.
Instead, call this subroutine from the main program within 2
16
count of the PCA timer.

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