Timers
LH79524/LH79525 User’s Guide
15-2
Version 1.0
15.1 Theory of Operation
Each counter can use either one of the supported internal divided-by-n HCLKs or an exter-
nal clock as its count clock. Clock selection is accomplished using the Timer Control Reg-
ister (CTRLx) for the timer to be programmed.
The clock can be changed only when the counter is in Stop Mode. Attempts to change the
count clock while the counter is running are ignored.
To change the count clock:
1.
Stop the counter by writing a 0 to CTRLx:CS.
2.
Select a desired clock by writing the value to CTRLx:SEL.
3.
Start the counter by writing a 1 to CTRLx:CS.
If an external clock on the CTCLK pin is selected in step 2, the timer increments the counter
of the corresponding timer on the third rising edge of HCLK after a rising edge by CTCLK.
The pulse length of CTCLK must be equal to or longer than, two HCLK periods plus the
setup and hold time (see the Data Sheet for timing information). Shorter pulses can cause
incorrect counts. If CTCLK is not in phase with HCLK, inaccurate counts can occur.
Figure 15-1. Timer Block Diagram
TIMER 0 COUNTER
CTCLK
INPUT CAPTURE × 5
CAPTURE
INPUT
COMPARE
OUTPUT
INTERRUPT CONTROL
TIMER 0 BLOCK
TIMER 1 BLOCK
TIMER 2 BLOCK
INTERRUPT
REQUEST
ADVANCED
PERIPHERAL
BUS (APB)
COMPARE REGISTER × 2
LH79525-29
TIMER 1 COUNTER
INPUT CAPTURE × 2
CAPTURE
INPUT
COMPARE
OUTPUT
INTERRUPT CONTROL
INTERRUPT
REQUEST
COMPARE REGISTER × 2
TIMER 2 COUNTER
INPUT CAPTURE × 2
CAPTURE
INPUT
COMPARE
OUTPUT
INTERRUPT CONTROL
INTERRUPT
REQUEST
COMPARE REGISTER × 2