English
Language : 

ATMEGA164P_1 Datasheet, PDF (144/377 Pages) ATMEL Corporation – 8-bit Microcontroller with 16/32/64K Bytes In-System Programmable Flash
Figure 15-4. Compare Match Output Unit, Schematic
COMnx1
COMnx0
FOCnx
Waveform
Generator
DQ
1
OCnx
0
DQ
OCnx
Pin
PORT
DQ
clkI/O
DDR
15.6.1
The general I/O port function is overridden by the Output Compare (OC2x) from the Waveform
Generator if either of the COM2x1:0 bits are set. However, the OC2x pin direction (input or out-
put) is still controlled by the Data Direction Register (DDR) for the port pin. The Data Direction
Register bit for the OC2x pin (DDR_OC2x) must be set as output before the OC2x value is visi-
ble on the pin. The port override function is independent of the Waveform Generation mode.
The design of the Output Compare pin logic allows initialization of the OC2x state before the out-
put is enabled. Note that some COM2x1:0 bit settings are reserved for certain modes of
operation. See “Register Description” on page 153.
Compare Output Mode and Waveform Generation
The Waveform Generator uses the COM2x1:0 bits differently in normal, CTC, and PWM modes.
For all modes, setting the COM2x1:0 = 0 tells the Waveform Generator that no action on the
OC2x Register is to be performed on the next compare match. For compare output actions in the
non-PWM modes refer to Table 15-5 on page 155. For fast PWM mode, refer to Table 15-6 on
page 155, and for phase correct PWM refer to Table 15-7 on page 155.
A change of the COM2x1:0 bits state will have effect at the first compare match after the bits are
written. For non-PWM modes, the action can be forced to have immediate effect by using the
FOC2x strobe bits.
144 ATmega164P/324P/644P
7674F–AVR–09/09