98
ATtiny25/45/85 [DATASHEET]
2586Q–AVR–08/2013
When the counter value match the content of OCR1A, the OC1A and output is set or cleared according to the
COM1A1/COM1A0 bits in the Timer/Counter1 Control Register A - TCCR1, as shown in
Table 13-1.
Timer/Counter1 acts as an up-counter, counting from $00 up to the value specified in the output compare register
OCR1C, and starting from $00 up again. A compare match with OCR1C will set an overflow interrupt flag (TOV1)
after a synchronization delay following the compare event.
Note that in PWM mode, writing to the Output Compare Register OCR1A, the data value is first transferred to a
temporary location. The value is latched into OCR1A when the Timer/Counter reaches OCR1C. This prevents the
occurrence of odd-length PWM pulses (glitches) in the event of an unsynchronized OCR1A. See
Figure 13-4 for an
e xample.
Figure 13-4. Effects of Unsynchronized OCR Latching
During the time between the write and the latch operation, a read from OCR1A will read the contents of the tempo-
rary location. This means that the most recently written value always will read out of OCR1A.
When OCR1A contains $00 or the top value, as specified in OCR1C register, the output PB1(OC1A) is held low or
high according to the settings of COM1A1/COM1A0. This is shown in
Table 13-2.
Table 13-1.
Compare Mode Select in PWM Mode
COM1A1
COM1A0
Effect on Output Compare Pin
0
OC1A not connected.
0
1
OC1A not connected.
1
0
OC1A cleared on compare match. Set when TCNT1 = $00.
1
OC1A set on compare match. Cleared when TCNT1 = $00.
Table 13-2.
PWM Outputs OCR1A = $00 or OCR1C
COM1A1
COM1A0
OCR1A
Output OC1A
01
$00
L
0
1
OCR1C
H
10
$00
L
PWM Output OC1A
Unsynchronized OC1A Latch
Synchronized OC1A Latch
Counter Value
Compare Value
Counter Value
Compare Value
Compare Value changes
Glitch
Compare Value changes