Philips Semiconductors Product data
P89C660/P89C662/P89C664/
P89C668
80C51 8-bit Flash microcontroller family
16KB/32KB/64KB ISP/IAP Flash with 512B/1KB/2KB/8KB RAM
2002 Oct 28
58
CF CR CCF4 CCF3 CCF2 CCF1 CCF0––
CCON
(C0H)
–– ECOMn CAPPn CAPNn MATn TOGn PWMn ECCFn
CCAPMn, n: 0..4
(C2H – C6H)
CH CL
CCAPnH CCAPnL
PCA INTERRUPT
PCA TIMER/COUNTER
1000
16–BIT COMPARATOR
(TO CCFn)
WRITE TO
CCAPnH
RESET
WRITE TO
CCAPnL
01
ENABLE
CEXn
TOGGLE
MATCH
SU01103
Figure 49. PCA High Speed Output Mode
CL < CCAPnL
–– ECOMn CAPPn CAPNn MATn TOGn PWMn ECCFn
CCAPMn, n: 0..4
(C2H – C6H)
PCA TIMER/COUNTER
0000
CL
CCAPnL
CEXn
8–BIT
COMPARATOR
OVERFLOW
CCAPnH
ENABLE
0
1
CL >= CCAPnL
0
SU01104
Figure 50. PCA PWM Mode
Philips Semiconductors Product data
P89C660/P89C662/P89C664/
P89C668
80C51 8-bit Flash microcontroller family
16KB/32KB/64KB ISP/IAP Flash with 512B/1KB/2KB/8KB RAM
2002 Oct 28
59
–– ECOMn CAPPn CAPNn MATn TOGn PWMn ECCFn
CCAPM4
(C6H)
CH CL
CCAP4H CCAP4L
RESET
PCA TIMER/COUNTER
X000
16–BIT COMPARATOR
MATCH
ENABLE
WRITE TO
CCAP4L
RESET
WRITE TO
CCAP4H
10
1
CMOD
(C1H)
CIDL WDTE –– –– –– CPS1 CPS0 ECF
X
SU01105
MODULE 4
Figure 51. PCA Watchdog Timer m(Module 4 only)
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 51 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.
In order to hold off the reset, the user has three options:
1. periodically change the compare value so it will never match the
PCA timer,
2. periodically change the PCA timer value so it will never match
the compare values, or
3. 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.
Figure 52 shows the code for initializing the watchdog timer.
Module 4 can be configured in either compare mode, and the WDTE
bit in CMOD must also be set. The users software 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 in
Figure 52.
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 will still be serviced and the watchdog will
keep getting 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.
Philips Semiconductors Product data
P89C660/P89C662/P89C664/
P89C668
80C51 8-bit Flash microcontroller family
16KB/32KB/64KB ISP/IAP Flash with 512B/1KB/2KB/8KB RAM
2002 Oct 28
60
INIT_WATCHDOG:
MOV CCAPM4, #4CH ; Module 4 in compare mode
MOV CCAP4L, #0FFH ; Write to low byte first
MOV CCAP4H, #0FFH ; Before PCA timer counts up to
; FFFF Hex, these compare values
; must be changed
ORL CMOD, #40H ; Set the WDTE bit to enable the
; watchdog timer without changing
; the other bits in CMOD
;
;********************************************************************
;
; Main program goes here, but CALL WATCHDOG periodically.
;
;********************************************************************
;
WATCHDOG:
CLR EA ; Hold off interrupts
MOV CCAP4L, #00 ; Next compare value is within
MOV CCAP4H, CH ; 255 counts of the current PCA
SETB EA ; timer value
RET
Figure 52. PCA Watchdog Timer Initialization Code

P89C662HBA/00,512

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