Datasheet
Table 20-1. Definitions
Constant Description
BOTTOM The counter reaches the BOTTOM when it becomes zero (0x00 for 8-bit counters, or 0x0000
for 16-bit counters).
MAX The counter reaches its maximum when it becomes 0xFF (decimal 255, for 8-bit counters) or
0xFFFF (decimal 65535, for 16-bit counters).
TOP The counter reaches the TOP when it becomes equal to the highest value in the count
sequence. The TOP value can be assigned to be the fixed value MAX or the value stored in
the OCR1A register. The assignment is dependent on the mode of operation.
20.5 Registers
The Timer/Counter (TCNT1), Output Compare registers (OCRA/B), and Input Capture Register (ICR1)
are all 16-bit registers. Special procedures must be followed when accessing the 16-bit registers. These
procedures are described in section 20.6 Accessing 16-bit Timer/Counter Registers.
The Timer/Counter Control Registers (TCCR1A/B/C) are 8-bit registers and have no CPU access
restrictions. Interrupt requests (abbreviated to Int.Req. in the block diagram) signals are all visible in the
Timer Interrupt Flag Register (TIFR1). All interrupts are individually masked with the Timer Interrupt Mask
Register (TIMSK1). TIFR1 and TIMSK1 are not shown in the figure.
The timer/counter can be clocked internally, via the prescaler, or by an external clock source on the T1
pin. The clock select logic block controls which clock source and edge the timer/counter uses to
increment (or decrement) its value. The timer/counter is inactive when no clock source is selected. The
output from the clock select logic is referred to as the timer clock (clk
T1
).
The double buffered Output Compare Registers (OCR1A/B) are compared with the timer/counter value at
all time. The result of the compare can be used by the waveform generator to generate a PWM or
variable frequency output on the Output Compare pin (OC1A/B). See Output Compare Units. The
compare match event will also set the Compare Match Flag (OCF1A/B), which can be used to generate
an output compare interrupt request.
The Input Capture register can capture the timer/counter value at a given external (edge triggered) event
on either the Input Capture pin (ICP1) or on the analog comparator pins. The input capture unit includes a
digital filtering unit (Noise canceler) for reducing the chance of capturing noise spikes.
The TOP value, or maximum timer/counter value, can in some modes of operation be defined by either
the OCR1A register, the ICR1 register, or by a set of fixed values. When using OCR1A as TOP value in a
PWM mode, the OCR1A register cannot be used for generating a PWM output. However, the TOP value
will, in this case, be double buffered allowing the TOP value to be changed in runtime. If a fixed TOP
value is required, the ICR1 register can be used as an alternative, freeing the OCR1A to be used as
PWM output.
20.6 Accessing 16-bit Timer/Counter Registers
The TCNT1, OCR1A/B, and ICR1 are 16-bit registers that can be accessed by the AVR CPU via the 8-bit
data bus. The 16-bit register must be accessed byte-wise, using two read or write operations. Each 16-bit
timer has a single 8-bit TEMP register for temporary storing of the high byte of the 16-bit access. The
same temporary register is shared between all 16-bit registers within each 16-bit timer.
ATmega48PA/88PA/168PA
16-bit Timer/Counter1 (TC1) with PWM
© 2018 Microchip Technology Inc.
Datasheet Complete
DS40002011A-page 163