English
Language : 

W78ERD2 Datasheet, PDF (43/72 Pages) Winbond – 8-BIT MICROCONTROLLER
W78ERD2
11. PROGRAMMABLE COUNTER ARRAY (PCA)
The PCA is 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 pulse width modulator. Each module has a pin
associate with it in port 1. module0 is connected to p1.3(CEX0), module1 is connected to p1.4(CEX1),
etc.
Module0
P1.3/CEX0
Module1
P1.4/CEX1
PCA Timer/Counter
CH
CL
16-bit Up-Counter
time base for PCA modules
Module Functions:
16-bit Capture
16-bit Timer/Compare
16-bit High Speed Output
8-bit PWM
Watchdog Timer (Module 4 Only)
Module2
Module3
Module4
P1.5/CEX2
P1.6/CEX3
P1.7/CEX4
Programmable Counter Array (PCA)
Each module in the PCA has a special function register associated with it. These register are:
CCAPM0 for module0, CCAPM1 for module1, etc. The registers contain the bits that control the mode
that each module will operate in. The ECCF bit enables the CCF flag in the CCON SFR to generate an
interrupt when a match or compare occurs in the associated module. PWM enables the pulse width
modulation mode. The TOG bit 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 compare/capture register. The
match bit MAT when set will cause the CCF bit in the CCON register to be set when there is a match
between the PCA counter and the module’s compare/capture register. The bits CAPP and CAPN
determine the edge that a capture input will be active on. The CAPP bit enables the positive edge, and
the CAPN bit enables the negative edge. If both bits are set both edges will be enabled and a capture
will occur for either transition. The bit ECOM enables the comparator function.
The PCA Timer is a common time base for all five modules and can be programmed to select the
different timer source. The default value is 12 clocks (T) per machine cycle. 12T / 6T can be set by
the option bit. The option bits only are set by the writer. The timer count source is determined from the
CPS1 and CPS2 bits in the CMOD SFR as follows:
CPS1
0
0
1
1
CPS0
0
1
0
1
PCA TIMER COUNT SOURCE FOR 12T
Oscillator frequency / 12
Oscillator frequency / 4
Timer0 overflow
External input at ECI pin
PCA TIMER COUNT SOURCE FOR 6T
Oscillator frequency / 6
Oscillator frequency / 2
Timer0 overflow
External input at ECI pin
CMOD(D8H)
- 43 -
Publication Release Date: April 20, 2005
Revision A4