16-bit Software Timer/
Compare Mode
The PCA Modules can be used as software timers by setting both the ECOM and MAT
bits in the Modules CCAPMn register. The PCA timer will be compared to the Module's
capture registers and when a match occurs, an interrupt will occur if the CCFn (CCON
SFR) and the ECCFn (CCAPMn SFR) bits for the Module are both set (see Figure 14).
Figure 14. PCA Compare Mode and PCA Watchdog Timer
Write to
CCAPnL Reset
Write to
CCAPnH
1
0
Enable
CF CR
CCAPnH
CCAPnL
16 bit Comparator
CCON
CCF4 CCF3 CCF2 CCF1 CCF0 0xD8
PCA IT
Match
CH
CL
PCA Counter/Timer
RESET(1)
CCAPMn, n = 0 to 4
ECOMn CAPPn CAPNn MATn TOGn PWMn ECCFn
0xDA to 0xDE
CIDL WDTE
CPS1 CPS0 ECF CMOD
0xD9
Note: 1. Only for Module 4
Before enabling ECOM bit, CCAPnL and CCAPnH should be set with a non zero value,
otherwise an unwanted match could occur. Writing to CCAPnH will set the ECOM bit.
Once ECOM set, writing CCAPnL will clear ECOM so that an unwanted match doesn’t
occur while modifying the compare value. Writing to CCAPnH will set ECOM. For this
reason, user software should write CCAPnL first, and then CCAPnH. Of course, the
ECOM bit can still be controlled by accessing to CCAPMn register.
40 AT89C51RB2/RC2
4180E–8051–10/06