Mega pin 13

I am using a Mega rev 3.
I need to use pin 13 as well as timer 1.
When I setup timer 1 timer then I don't have any control over pin 13.
If, however I remove the setup for timer 1, I have full control over pin 13.
Does anyone know what is going on?

The setup code for timer 1 is:
//Timer 1 setup
//This will cause the timer to run in Phase Correct PWM mode, non-inverting mode with no pre scaler.
TCCR1A = B10101001;
TCCR1B = B00000001;
//Timer 1 setup done

I need this timer for PWM.

Can someone shed some light here?

Pin 13 is OC1C in the Atmega 2560 pinouts

The following, from the Atmega 26560 datasheet seems to have the answer. Section 17.11.4 in my copy

The COMnA1:0, COMnB1:0, and COMnC1:0 control the output compare pins (OCnA, OCnB,
and OCnC respectively) behavior. If one or both of the COMnA1:0 bits are written to one, the
OCnA output overrides the normal port functionality of the I/O pin it is connected to. If one or
both of the COMnB1:0 bits are written to one, the OCnB output overrides the normal port func-
tionality of the I/O pin it is connected to. If one or both of the COMnC1:0 bits are written to one,
the OCnC output overrides the normal port functionality of the I/O pin it is connected to. How-
ever, note that the Data Direction Register (DDR) bit corresponding to the OCnA, OCnB or
OCnC pin must be set in order to enable the output driver.

...R

 TCCR1A = B10101001;

You are turning on PWM on pins OC1A (Pin 11), OC1B (Pin 12), and OC1C (Pin 13). If you don't want Timer1 to take control of Pin 13, change it to:

 TCCR1A = B10100001;

But according to the info I have, Pin 13 is connected to OCR0A and has nothing to do with timer 1. So I am setting up timer 1 and not timer 0. If I set up timer 0 then Pin 13 will be affected. But I'm setting up timer 1 and not timer 0.

KerneelsM:
But according to the info I have, Pin 13 is connected to OCR0A and has nothing to do with timer 1

Please post a link to your info - I suspect it is incorrect.

...R

According to the Mega Schematic Pin 13 is connected to both OCR0A as well as OCR1C. This means that if timer 0 PWM (OCR0A) is used OCR1C is not available and vice versa. Is this correct?

KerneelsM:
According to the Mega Schematic Pin 13 is connected to both OCR0A as well as OCR1C. This means that if timer 0 PWM (OCR0A) is used OCR1C is not available and vice versa. Is this correct?

I had missed the fact the the Atmega 2560 connects both of those outputs to pin 26 on the chip which is Arduino pin 13. Your conclusion seems to be correct.

...R

If I set
TCCR1A = B10100001;
This puts Pin 13 in normal port operation from Timer 1 perspective.
Can I still set timer 0 for PWM operation on OCR0A even if TCCR1A set it to normal port operation?

KerneelsM:
If I set
TCCR1A = B10100001;
This puts Pin 13 in normal port operation from Timer 1 perspective.
Can I still set timer 0 for PWM operation on OCR0A even if TCCR1A set it to normal port operation?

I sure hope that is true. I can't think of any other way to keep Timer1 from taking over Pin 13.

Thank you. I will test this further.