Datasheet
46
ATmega323(L)
1457E–11/01
Timer/Counter0 and 2 can also be used as 8-bit Pulse Width Modulators. In this mode,
the Timer/Counter and the output compare register serve as a glitch-free, stand-alone
PWM with centered pulses. Refer to page 48 for a detailed description on this function.
Timer/Counter0 Control
Register – TCCR0
Timer/Counter2 Control
Register – TCCR2
• Bit 7 - FOC0/FOC2: Force Output Compare
Writing a logical one to this bit, forces a change in the compare match output pin PB3
(Timer/Counter0) and PD7 (Timer/Counter2) according to the values already set in
COMn1 and COMn0. If the COMn1 and COMn0 bits are written in the same cycle as
FOC0/FOC2, the new settings will not take effect until next compare match or Forced
Output Compare match occurs. The Force Output Compare bit can be used to change
the output pin without waiting for a compare match in the timer. The automatic action
programmed in COMn1 and COMn0 happens as if a Compare Match had occurred, but
no interrupt is generated and the Timer/Counters will not be cleared even if CTC0/CTC2
is set. The corresponding I/O pin must be set as an output pin for the FOC0/FOC2 bit to
have effect on the pin. The FOC0/FOC2 bits will always be read as zero. Setting the
FOC0/FOC2 bits has no effect in PWM mode.
• Bit 6 - PWM0/PWM2: Pulse Width Modulator Enable
When set (one) this bit enables PWM mode for Timer/Counter0 or Timer/Counter2. This
mode is described on page 48.
• Bits 5,4 - COM01, COM00/COM21, COM20: Compare Output Mode, Bits 1 and 0
The COMn1 and COMn0 control bits determine any output pin action following a com-
pare match in Timer/Counter0 or Timer/Counter2. Output pin actions affect pins
PB3(OC0) or PD7(OC2). This is an alternative function to an I/O port, and the corre-
sponding direction control bit must be set (one) to control an output pin. The control
configuration is shown in Table 12.
Notes: 1. In PWM mode, these bits have a different function. Refer to Table 15 for a
description.
2. n = 0 or 2
Bit 76543210
$33 ($53) FOC0 PWM0 COM01 COM00 CTC0 CS02 CS01 CS00 TCCR0
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value00000000
Bit 76543210
$25 ($45) FOC2 PWM2 COM21 COM20 CTC2 CS22 CS21 CS20 TCCR2
Read/Write R/W R/W R/W R/W R/W R/W R/W R/W
Initial Value00000000
Table 12. Compare Mode Select
(1)
COMn1
(2)
COMn0 Description
0 0 Timer/Counter Disconnected from Output Pin OCn
0 1 Toggle the OCn Output Line.
1 0 Clear the OCn Output Line (to Zero).
1 1 Set the OCn Output Line (to One).