8-bit AVR Microcontrollers

Compare Match Output Unit

The Compare Output mode bits in the Timer/Counter Control Register A (TCCR0A.COM0x) have two functions:

The figure below shows a simplified schematic of the logic affected by COM0x. 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 that are affected by the COM0x bits are shown, namely PORT and DDR.

On system reset the OC0x register is reset to 0x00.

Note: 'OC0x state' is always referring to internal OC0x registers, not the OC0x pin.
Figure 1. Compare Match Output Unit, Schematic
Note: The ā€œnā€ in the register and bit names indicates the device number (n = 0 for Timer/Counter 0), and the ā€œxā€ indicates output compare unit (A/B).

The general I/O port function is overridden by the Output Compare (OC0x) from the waveform generator if either of the COM0x[1:0] bits are set. However, the OC0x pin direction (input or output) is still controlled by the Data Direction Register (DDR) for the port pin. In the DDR, the bit for the OCnx pin (DDR.OC0x) must be set as output before the OC0x 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 OC0x register state before the output is enabled. Some TCCR0A.COM0x[1:0] bit settings are reserved for certain modes of operation.

The TCCR0A.COM0x[1:0] bits have no effect on the input capture unit.