Datasheet

Table Of Contents
21.6. Compare Match Output Unit
The Compare Output mode (COM01:0) bits have two functions. The waveform generator uses the
COM01:0 bits for defining the Output Compare (OC0) state at the next Compare Match. Also, the
COM01:0 bits control the OC0 pin output source. The figure below shows a simplified schematic of the
logic affected by the COM01:0 bit setting. The I/O Registers, I/O bits, and I/O pins in the figure are shown
in bold. Only the parts of the general I/O Port Control Registers (DDR and PORT) that are affected by the
COM01:0 bits are shown. When referring to the OC0 state, the reference is for the internal OC0 Register,
not the OC0 pin. If a System Reset occur, the OC0 Register is reset to "0".
Figure 21-4. Compare Match Output Unit, Schematic
PORT
DDR
D Q
D Q
OCn
Pin
OCn
D Q
Waveform
Generator
COMn1
COMn0
0
1
DATABUS
FOCn
clk
I/O
The general I/O port function is overridden by the Output Compare (OC0) from the waveform generator if
either of the COM01:0 bits are set. However, the OC0 pin direction (input or output) is still controlled by
the Data Direction Register (DDR) for the port pin. The Data Direction Register bit for the OC0 pin
(DDR_OC0) must be set as output before the OC0 value is visible 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 OC0 state before the output is
enabled. Note that some COM01:0 bit settings are reserved for certain modes of operation. See Register
Description.
21.6.1. Compare Output Mode and Waveform Generation
The Waveform Generator uses the COM01:0 bits differently in normal, CTC, and PWM modes. For all
modes, setting the COM01:0 = 0 tells the waveform generator that no action on the OC2 Register is to be
performed on the next Compare Match. For compare output actions in the non-PWM modes refer to Table
21-3. For fast PWM mode, refer to Table 21-4, and for phase correct PWM refer to Table 21-5.
A change of the COM01: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 FOC0 strobe bits.
Atmel ATmega32A [DATASHEET]
Atmel-8155I-ATmega32A_Datasheet_Complete-08/2016
166