21.11.1 TCCR1A – Timer/Counter1 Control Register A
When using the I/O specific commands IN and OUT, the I/O addresses 0x00 - 0x3F must be used. When addressing I/O Registers as data space using LD and ST instructions, 0x20 must be added to these offset addresses.
Name: | TCCR1A |
Offset: | 0x2F |
Reset: | 0x00 |
Property: | When addressing I/O Registers as data space the offset address is 0x4F |
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
COM1An[1:0] | COM1Bn[1:0] | FOC1A | FOC1B | WGM1n[1:0] | |||||
Access | R/W | R/W | R/W | R/W | W | W | R/W | R/W | |
Reset | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Bits 7:6 – COM1An[1:0] Compare Output Mode for Channel A [n = 1:0]
Bits 5:4 – COM1Bn[1:0] Compare Output Mode for Channel B [n = 1:0]
The COM1A1:0 and COM1B1:0 control the Output Compare pins (OC1A and OC1B respectively) behavior. If one or both of the COM1A1:0 bits are written to one, the OC1A output overrides the normal port functionality of the I/O pin it is connected to. If one or both of the COM1B1:0 bit are written to one, the OC1B 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 OC1A or OC1B pin must be set in order to enable the output driver.
When the OC1A or OC1B is connected to the pin, the function of the COM1n1:0 bits is dependent of the WGM13:0 bits setting. The table below shows the COM1n1:0 bit functionality when the WGM13:0 bits are set to a Normal or a CTC mode (non-PWM).
COM1A1/COM1B1 | COM1A0/COM1B0 | Description |
---|---|---|
0 | 0 | Normal port operation, OC1A/OC1B disconnected. |
0 | 1 | Toggle OC1A/OC1B on Compare Match. |
1 | 0 | Clear OC1A/OC1B on Compare Match (Set output to low level). |
1 | 1 | Set OC1A/OC1B on Compare Match (Set output to high level). |
The next table shows the COM1x1:0 bit functionality when the WGM13:0 bits are set to the fast PWM mode.
COM1A1/COM1B1 | COM1A0/COM1B0 | Description |
---|---|---|
0 | 0 | Normal port operation, OC1A/OC1B disconnected. |
0 | 1 | WGM13:0 = 15: Toggle OC1A on Compare Match, OC1B disconnected (normal port operation). For all other WGM1 settings, normal port operation, OC1A/OC1B disconnected. |
1 | 0 | Clear OC1A/OC1B on Compare Match, set OC1A/OC1B at BOTTOM (non-inverting mode) |
1 | 1 | Set OC1A/OC1B on Compare Match, clear OC1A/OC1B at BOTTOM (inverting mode) |
The table below shows the COM1x1:0 bit functionality when the WGM13:0 bits are set to the phase correct or the phase and frequency correct, PWM mode.
COM1A1/COM1B1 | COM1A0/COM1B0 | Description |
---|---|---|
0 | 0 | Normal port operation, OC1A/OC1B disconnected. |
0 | 1 | WGM13:0 = 9 or 14: Toggle OC1A on Compare Match, OC1B disconnected (normal port operation). For all other WGM1 settings, normal port operation, OC1A/OC1B disconnected. |
1 | 0 | Clear OC1A/OC1B on Compare Match when up-counting. Set OC1A/OC1B on Compare Match when down-counting. |
1 | 1 | Set OC1A/OC1B on Compare Match when up-counting. Clear OC1A/OC1B on Compare Match when down-counting. |
Bit 3 – FOC1A Force Output Compare for channel A
Bit 2 – FOC1B Force Output Compare for channel B
The FOC1A/FOC1B bits are only active when the WGM13:0 bits specifies a non-PWM mode. However, for ensuring compatibility with future devices, these bits must be set to zero when TCCR1A is written when operating in a PWM mode. When writing a logical one to the FOC1A/FOC1B bit, an immediate Compare Match is forced on the waveform generation unit. The OC1A/OC1B output is changed according to its COM1x1:0 bits setting. Note that the FOC1A/FOC1B bits are implemented as strobes. Therefore it is the value present in the COM1x1:0 bits that determine the effect of the forced compare.
A FOC1A/FOC1B strobe will not generate any interrupt nor will it clear the timer in Clear Timer on Compare Match (CTC) mode using OCR1A as TOP.
The FOC1A/FOC1B bits are always read as zero.
Bits 1:0 – WGM1n[1:0] Waveform Generation Mode [n = 1:0]
Combined with the WGM13:2 bits found in the TCCR1B 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, refer to the table below. 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).
Mode |
WGM13 |
WGM12 (CTC1) |
WGM11 (PWM11) |
WGM10 (PWM10) |
Timer/Counter Mode of Operation(1) |
TOP |
Update of OCR1x at |
TOV1 Flag Set on |
---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | Normal | 0xFFFF | Immediate | MAX |
1 | 0 | 0 | 0 | 1 | PWM, Phase Correct, 8-bit | 0x00FF | TOP | BOTTOM |
2 | 0 | 0 | 1 | 0 | PWM, Phase Correct, 9-bit | 0x01FF | TOP | BOTTOM |
3 | 0 | 0 | 1 | 1 | PWM, Phase Correct, 10-bit | 0x03FF | TOP | BOTTOM |
4 | 0 | 1 | 0 | 0 | CTC | OCR1A | Immediate | MAX |
5 | 0 | 1 | 0 | 1 | Fast PWM, 8-bit | 0x00FF | BOTTOM | TOP |
6 | 0 | 1 | 1 | 0 | Fast PWM, 9-bit | 0x01FF | BOTTOM | TOP |
7 | 0 | 1 | 1 | 1 | Fast PWM, 10-bit | 0x03FF | BOTTOM | TOP |
8 | 1 | 0 | 0 | 0 | PWM, Phase and Frequency Correct | ICR1 | BOTTOM | BOTTOM |
9 | 1 | 0 | 0 | 1 | PWM, Phase and Frequency Correct | OCR1A | BOTTOM | BOTTOM |
10 | 1 | 0 | 1 | 0 | PWM, Phase Correct | ICR1 | TOP | BOTTOM |
11 | 1 | 0 | 1 | 1 | PWM, Phase Correct | OCR1A | TOP | BOTTOM |
12 | 1 | 1 | 0 | 0 | CTC | ICR1 | Immediate | MAX |
13 | 1 | 1 | 0 | 1 | Reserved | - | - | - |
14 | 1 | 1 | 1 | 0 | Fast PWM | ICR1 | BOTTOM | TOP |
15 | 1 | 1 | 1 | 1 | Fast PWM | OCR1A | BOTTOM | TOP |
- The CTC1 and PWM11:0 bit definition names are obsolete. Use the WGM12:0 definitions. However, the functionality and location of these bits are compatible with previous versions of the timer.