49
ATmega161(L)
1228B–09/01
Timer/Counter1
Figure 36 shows the block diagram for Timer/Counter1.
Figure 36.
Timer/Counter1 Block Diagram
The 16-bit Timer/Counter1 can select clock source from CK, prescaled CK or an exter-
nal pin. In addition, it can be stopped as described in “Timer/Counter1 Control Register
B
–
TCCR1B”. The different status flags (overflow, compare match, and capture event)
are found in the Timer/Counter Interrupt Flag Register (TIFR). Control signals are found
in the Timer/Counter1 Control Registers (TCCR1A and TCCR1B). The interrupt
enable/disable settings for Timer/Counter1 are found in the Timer/Counter Interrupt
Mask Register (TIMSK).
When Timer/Counter1 is externally clocked, the external signal is synchronized with the
oscillator frequency of the CPU. To assure proper sampling of the external clock, the
minimum time between two external clock transitions must be at least one internal CPU
clock period. The external clock signal is sampled on the rising edge of the internal CPU
clock.
The 16-bit Timer/Counter1 features both a high-resolution and a high-accuracy usage
with the lower prescaling opportunities. Similarly, the high-prescaling opportunities
make the Timer/Counter1 useful for lower speed functions or exact timing functions with
infrequent actions.
The Timer/Counter1 supports two Output Compare functions using the Output Compare
Register 1 A and B (OCR1A and OCR1B) as the data sources to be compared to the
Timer/Counter1 contents. The Output Compare functions include optional clearing of
the counter on compareA match and actions on the Output Compare pins on both com-
pare matches.
TOIE0
TOIE1
OCIE1A
OCIE1B
TICIE1
TOIE2
OCIE2
OCIE0
TOV0
TOV1
OCF1A
OCF1B
ICF1
TOV2
OCF2
OCF0
TIMER INT. FLAG
REGISTER (TIFR)
CONTROL
LOGIC
TIMER/COUNTER1 (TCNT1)
TIMER INT. MASK
REGISTER (TIMSK)
T/C1 INPUT CAPTURE REGISTER (ICR1)
T/C1 OVER-
FLOW IRQ
T/C1 COMPARE
MATCHA IRQ
T/C1 COMPARE
MATCHB IRQ
T/C1 INPUT
CAPTURE IRQ
8-BIT DATA BUS
16 BIT COMPARATOR
TIMER/COUNTER1 OUTPUT COMPARE REGISTER A
16 BIT COMPARATOR
TIMER/COUNTER1 OUTPUT COMPARE REGISTER B
CAPTURE
TRIGGER
CK
0
7
8
15
0
7
8
15
0
7
8
15
0
7
8
15
0
7
8
15
0
7
8
15
T/C CLEAR
T/C CLOCK SOURCE
UP/DOWN
T/C1 CONTROL
REGISTER A (TCCR1A)
T/C1 CONTROL
REGISTER B (TCCR1B)
FOC1A
FOC1B
COM1A1
COM1A0
COM1B1
COM1B0
PWM11
PWM10
ICNC1
ICES1
CTC1
CS12
CS11
CS10
PSR2
PSR10
SPECIAL FUNCTIONS
IO REGISTER (SFIOR)
TOV1
OCF1B
OCF1A
ICF1
TOV2
OCF2
OCF0
TOV0
T1