user4024: I've got this code from the MultiWii project, which is relevant to the hardware, ATmega32u4, I have. It is part of a function called initOutput().
In the comment it says "connect pin 6", which is the bit of that which specifies pin 6 as I would like to change it to another pin, specifically A0.
// Enhanced PWM mode
TCCR4E |= (1<<ENHC4);

// Prescaler to 16
TCCR4B &= ~(1<<CS41);
TCCR4B |= (1<<CS42) | (1<<CS40);

// Phase and frequency correct mode and top to 1023, but
// with enhanced PWM mode we have 2047.
TCCR4D |= (1<<WGM40);
TC4H = 0x3;
OCR4C = 0xFF;

// Connect pin 6 to timer 4 channel D
TCCR4C |= (1<<COM4D1) | (1<<PWM4D);


user368: It's the (1<<COM4D1) that enables pin 6, or more specifically OC4D for timer output. You cannot use A0 instead, since there is no output compare capability on that pin; only pins 13, 5, 10, 9, 6, and 12 can be connected to timer 4. See the datasheet for details.

4024: <p>I've got this code from the <a href="http://www.multiwii.com/" rel="nofollow">MultiWii</a> project, which is relevant to the hardware, <a href="http://www.atmel.com/devices/ATMEGA32U4.aspx" rel="nofollow">ATmega32u4</a>, I have. It is part of a function called <code>initOutput()</code>.</p>

<p>In the comment it says "connect pin 6", which is the bit of that which specifies pin 6 as I would like to change it to another pin, specifically A0.</p>

<pre><code>// Enhanced PWM mode
TCCR4E |= (1&lt;&lt;ENHC4);

// Prescaler to 16
TCCR4B &amp;= ~(1&lt;&lt;CS41);
TCCR4B |= (1&lt;&lt;CS42) | (1&lt;&lt;CS40);

// Phase and frequency correct mode and top to 1023, but
// with enhanced PWM mode we have 2047.
TCCR4D |= (1&lt;&lt;WGM40);
TC4H = 0x3;
OCR4C = 0xFF;

// Connect pin 6 to timer 4 channel D
TCCR4C |= (1&lt;&lt;COM4D1) | (1&lt;&lt;PWM4D);
</code></pre>
 368: <p>It's the <code>(1&lt;&lt;COM4D1)</code> that enables pin 6, or more specifically <strong>OC4D</strong> for timer output. You cannot use A0 instead, since there is no output compare capability on that pin; only pins 13, 5, 10, 9, 6, and 12 can be connected to timer 4. See the datasheet for details.</p>
