OC1A is initially HIGH for phase/freq correct mode with zero duty cycle

Hi there,
I have been trying to generate a phase and frequency correct PWM output on pin9 with an initial duty cycle of 0%, i.e. completely off (in future code revisions this duty cycle would be modified later in the program).

The following code has been directly copied/pasted immediately after uploading to my Arduino UNO clone (i.e. ATMega328P):

void setup(){
  cli(); //disable global interrupts
  //explicitly clear timer/counter1 control registers and counter
  TCCR1A = 0;
  TCCR1B = 0;

  //set duty cycle to zero
  OCR1A = 0;

  //reset counter
  TCNT1 = 0;
  //phase and frequency correct with ICR1 as TOP
  TCCR1B |= (1<<WGM13);

  //set prescaler to 256
  TCCR1B |= (1<<CS12);
  //set timer1 period to 1 second
  ICR1 = 31250;
  //tie OC1A to pin 9, and set pin 9 as an output
  TCCR1A |= (1<<COM1A1); //clear OC1A on match when downcounting, set on match when upcounting
  DDRB |= (1<<DDB1);
  sei(); //enable global interrupts

void loop(){
  //do nothing

I have an LED wired to digital I/O pin 9.

When the above code runs, the LED turns on immediately, and remains on for about 1 second, after which it turns off and remains off (which I'm guessing is because it is turned off after one timer cycle; after the counter returns to zero and matches with OCR1A).

My question is: why does the LED turn on at all?

While searching around the Arduino forum a bit for other people who have had this problem (none of which I found), I came across people saying that OC1A is unset (off) by default. I have set the Compare Output Mode such that OC1A is set when a match occurs while the counter is down-counting and cleared when a match occurs while up-counting.

Since the LED turns on when the program starts, one could deduce that a compare match (between TCNT1 and OCR1A) has occurred while down-counting, or there's an underlying problem.

Is this the behaviour intended by the designers of the chip, or a boundary condition glitch?

Does anyone know a solution or workaround for this, while still using phase and frequency correct mode?

No experience with the specifics. So I might be totally wrong.

How is the LED wired? If it's between 5V and pin and the pin is initially low, current will flow.

It is wired in the 'conventional' way - cathode to GND, anode to pin 9 via a 220 ohm resistor.

Just so you can be sure of my wiring, I've just uploaded to the Arduino, and directly copy-pasted into this forum, the following code:

void setup() {
  pinMode(9, OUTPUT);
  digitalWrite(9, HIGH);

void loop() {
  // do nothing

and the LED, wired as described above, is definitely on.