English
Language : 

Z8F1680SH020SG Datasheet, PDF (127/412 Pages) Zilog, Inc. – High-Performance 8-Bit Microcontrollers
Z8 Encore! XP® F1680 Series
Product Specification
102
9.2.3.12. CAPTURE/COMPARE Mode
In CAPTURE/COMPARE Mode, the timer begins counting on the first external Timer
Input transition. The appropriate transition (rising edge or falling edge) is set by the TPOL
bit in the Timer Control 1 Register. The Timer counts timer clocks up to the 16-bit reload
value.
Every subsequent appropriate transition (after the first) of the Timer Input signal captures
the current count value. The Capture value is written to the Timer PWM0 High and Low
Byte registers. When the Capture event occurs, an interrupt is generated, the count value
in the Timer High and Low Byte registers is reset to 0001H and counting resumes. The
INPCAP bit in Timer Control 0 Register is set to indicate the timer interrupt is due to an
input capture event.
If no Capture event occurs, the timer counts up to the 16-bit Compare value stored in the
Timer Reload High and Low Byte registers. Upon reaching the Compare value, the timer
generates an interrupt, the count value in the Timer High and Low Byte registers is reset to
0001H and counting resumes. The INPCAP bit in Timer Control 0 Register is cleared to
indicate the timer interrupt is not due to an input capture event.
Observe the following steps to configure a timer for CAPTURE/COMPARE Mode and
initiate the count:
1. Write to the Timer Control 1 Register to:
– Disable the timer
– Configure the timer for CAPTURE/COMPARE Mode
– Set the prescale value
– Set the Capture edge (rising or falling) for the Timer Input
2. Write to the Timer High and Low Byte registers to set the starting count value (typi-
cally 0001H).
3. Write to the Timer Control 2 Register to choose the timer clock source.
4. Write to the Timer Control 0 Register to set the timer interrupt configuration field
TICONFIG.
5. Write to the Timer Reload High and Low Byte registers to set the Compare value.
6. If required, enable the timer interrupt and set the timer-interrupt priority by writing to
the relevant interrupt registers. By default, the timer interrupt will be generated for
both input capture and reload events. If required, configure the timer interrupt to be
generated only at the input Capture event or the Reload event by setting TICONFIG
field of the Timer Control 0 Register.
7. Configure the associated GPIO port pin for the Timer Input alternate function.
8. Write to the Timer Control 1 Register to enable the timer.
PS025015-1212
PRELIMINARY
Timers