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
CCON
0xD8
CCF4
CF
CCF3 CCF2 CCF1 CCF0
CR
Write to
CCAPnL Reset
PCA IT
Write to
CCAPnH
CCAPnH
CCAPnL
Enable
1
0
Match
16 bit Comparator
RESET(1)
CH
CL
PCA Counter/Timer
CCAPMn, n = 0 to 4
0xDA to 0xDE
ECOMnCAPPn CAPNn MATn TOGn PWMn ECCFn
CMOD
0xD9
CIDL
CPS1 CPS0 ECF
WDTE
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