repeated crashing/reboots caused by 2x analogWrite

The extremely simple sketch below results in some unexpected behavior on my Arduino Mega2560

After setting the pinModes , if i don't include a delay before issuing my analogWrite commands the board just starts resetting every few seconds. No PWM output appears.

I can include some serial reads before the analogWrite's and see it is getting that far.

This started when i added the second channel/pin (11). prior to this, I didn't see any strange behavior.

I have no idea what is causing this. Can anyone offer some guidance?

void setup() {

  pinMode(3, OUTPUT);
  pinMode(11, OUTPUT);
  //delay(100); // without this it keeps rebooting 
  analogWrite(3, 127); 
  //delay(100);
  analogWrite(11, 127); 
}

void loop() {
  // put your main code here, to run repeatedly:

}

Why do you think that the Mega is restarting/crashing? What is connected to pins 3 and 11?

Once you turn on the PWM on a pin it will continue to output until you change it.

I put a LED flash in setup() so that when setup() runs the LED flashes 5 times. I see it flash the 5 times then no more so setup() is only running once when run on my Mega.

void setup()
{
   pinMode(13, OUTPUT);
   for (int n = 0; n < 10; n++)
   {
      digitalWrite(13, !digitalRead(13));
      delay(500);
   }
   pinMode(3, OUTPUT);
   pinMode(11, OUTPUT);
   //delay(100); // without this it keeps rebooting
   analogWrite(3, 127);
   //delay(100);
   analogWrite(11, 127);
}

void loop()
{
   // put your main code here, to run repeatedly:

}

If something in the code results in the Arduino restarting my first suspicion is that the action of the code turns on something which draws too much power from the Arduino causing the voltage to fall and a reset to occur.

...R