17.14.1 Timer/Counter0 Control Register A

Name: TCCR0A
Offset: 0x2E
Reset: 0x00
Property: -

Bit 76543210 
 COM0An[1:0]COM0Bn[1:0]  WGM0n[1:0] 
Access R/WR/WR/WR/WR/WR/W 
Reset 000000 

Bits 7:6 – COM0An[1:0] Compare Output Mode for Channel A [n = 1:0]

Bits 5:4 – COM0Bn[1:0] Compare Output Mode for Channel B [n = 1:0]

The COM0A[1:0] and COM0B[1:0] control the Output Compare pins (OC0A and OC0B respectively) behavior. If one or both of the COM0A[1:0] bits are written to one, the OC0A output overrides the normal port functionality of the I/O pin it is connected to. If one or both of the COM0B[1:0] bit are written to one, the OC0B output overrides the normal port functionality of the I/O pin it is connected to. However, note that the Data Direction Register (DDR) bit corresponding to the OC0A or OC0B pin must be set in order to enable the output driver.

When the OC0A or OC0B is connected to the pin, the function of the COM0x[1:0] bits is dependent of the WGM0[3:0] bits setting. The table below shows the COM0x[1:0] bit functionality when the WGM0[3:0] bits are set to a Normal or a CTC mode (non-PWM).

Table 17-3. Compare Output Mode, non-PWM
COM0A1/COM0B1COM0A0/COM0B0Description
00Normal port operation, OC0A/OC0B disconnected.
01Toggle OC0A/OC0B on Compare Match.
10Clear OC0A/OC0B on Compare Match (Set output to low level).
11Set OC0A/OC0B on Compare Match (Set output to high level).

The table below shows the COM0x[1:0] bit functionality when the WGM0[3:0] bits are set to the fast PWM mode.

Table 17-4. Compare Output Mode, Fast PWM
COM0A1/COM0B1COM0A0/COM0B0Description
00Normal port operation, OC0A/OC0B disconnected.
01

WGM0[3:0]=0: Normal port operation, OC0A/OC0B disconnected

WGM0[3:0]=1: Toggle OC0A on compare match, OC0B reserved

1(1)0Clear OC0A/OC0B on Compare Match, set OC0A/OC0B at BOTTOM (non-inverting mode)
1(1)1Set OC0A/OC0B on Compare Match, clear OC0A/OC0B at BOTTOM (inverting mode)
Note:
  1. A special case occurs when OCR0A/OCR0B equals TOP and COM0A1/COM0B1 is set. In this case the compare match is ignored, but the set or clear is done at BOTTOM. Refer to Fast PWM Mode for details.

The table below shows the COM0x[1:0] bit functionality when the WGM0[3:0] bits are set to the phase correct or the phase and frequency correct, PWM mode.

Table 17-5. Compare Output Mode, Phase Correct and Phase and Frequency Correct PWM
COM0A1/COM0B1COM0A0/COM0B0Description
00Normal port operation, OC0A/OC0B disconnected.
01

WGM0[3:0]=0: Normal port operation, OC0A/OC0B disconnected

WGM0[3:0]=1: Toggle OC0A on compare match, OC0B reserved

1(1)0Clear OC0A/OC0B on Compare Match when up-counting. Set OC0A/OC0B on Compare Match when down-counting.
1(1)1Set OC0A/OC0B on Compare Match when up-counting. Clear OC0A/OC0B on Compare Match when down-counting.
Note:
  1. A special case occurs when OCR0A/OCR0B equals TOP and COM0A1/COM0B1 is set. Refer to Phase Correct PWM Mode for details.

Bits 1:0 – WGM0n[1:0] Waveform Generation Mode [n = 1:0]

Combined with the WGM0[3:2] bits found in the TCCR0B Register, these bits control the counting sequence of the counter, the source for maximum (TOP) counter value, and what type of waveform generation to be used. Modes of operation supported by the Timer/Counter unit are: Normal mode (counter), Clear Timer on Compare match (CTC) mode, and three types of Pulse Width Modulation (PWM) modes. (See Modes of Operation).

Table 17-6. Waveform Generation Mode Bit Description
ModeWGM0[3:0]Timer/Counter Mode of OperationTOPUpdate of OCR0x atTOV0 Flag Set on
00000Normal0xFFFFImmediateMAX
10001PWM, Phase Correct, 8-bit0x00FFTOPBOTTOM
20010PWM, Phase Correct, 9-bit0x01FFTOPBOTTOM
30011PWM, Phase Correct, 10-bit0x03FFTOPBOTTOM
40100CTC (Clear Timer on Compare)OCR0AImmediateMAX
50101Fast PWM, 8-bit0x00FFTOPTOP
60110Fast PWM, 9-bit0x01FFTOPTOP
70111Fast PWM, 10-bit0x03FFTOPTOP
81000PWM, Phase and Frequency CorrectICR0BOTTOMBOTTOM
91001PWM, Phase and Frequency CorrectOCR0ABOTTOMBOTTOM
101010PWM, Phase CorrectICR0TOPBOTTOM
111011PWM, Phase CorrectOCR0ATOPBOTTOM
121100CTC (Clear Timer on Compare)ICR0ImmediateMAX
131101Reserved---
141110Fast PWMICR0TOPTOP
151111Fast PWMOCR0ATOPTOP