void loop() stopped shortly after initializing

Hi. I'm quite new to using Arduino and would like to produce a 16 MHz PWM on pin 9 (Not sure if my approach is right). To test it out, I outputted the state of the timer every second. However, the loop() stopped shortly after i uploaded the code to my Arduino Uno. I tried to flash a LED to test. However it stopped lighting up after a few seconds. Also the serial monitor only writes one character and stoppped. Can anybody help? Please take a look at my code:

void setup()
{
  // value of OC0A goes to 9
  pinMode(9, OUTPUT);

  // OCR0A is the timer reset bit, and when it resets, toggle OC0A
  OCR0A = 1;

  TCCR0A =
    // toggle mode, toggling OC0A on TOP (1)
    // OC0A1:0 = 0b01
    bit(COM0A0) |

    // not using OC0B
    // OC0B1:0 = 0b00

    // fast PWM mode
    // setting TOP (clock resets when reaching this value) to OCR0A (1)
    // WGM02:0 = 0b111, WGM02 will be set later
    bit(WGM01) | bit(WGM00);

  TCCR0B =
    // WGM02 = 1, see above
    bit(WGM02) |

    // not using prescaling function
    // CS02:0 = 0b001
    bit(CS00);

    TCNT0 = 0;
  /* ---------------------------------- */
  Serial.begin(9600);
}

// the loop function runs over and over again until power down or reset
void loop() {
  Serial.println(TCNT0);
  delay(1000);
}

Thanks in advance!

Regards,
Sunny

How do you expect to get 16MHz PWM on a 16MHz processor?

Why do you think this is a bootloader issue?

Why is it impossible?
I don't know where should I post..

Do you understand how PWM works?

AFAIK, PWM is square waves alternating btw HIGH and LOW. Did i misunderstood anything? Thanks!

The only way to get 16 MHz out of a 328P, 1284P, or 2560 based 16 MHz Arduino is to set a bit in one of the fuses, it then outputs the system clock, 16 MHz, on one of the pins.

Anything that takes even one clock cycle to run will result in 8 MHz tops, and it just goes down from there.

I see... Thanks for the reply. But I don't know about setting fuses. (cuz I'm noob) It sounds complicated.
But what if I want to get a 8MHz clock? Is the code I sent above valid?
Thanks in advance!

err_username_already_exists:
AFAIK, PWM is square waves alternating btw HIGH and LOW.

No.
Unless the duty-cycle is exactly 50%, a PWM waveform is rectangular, not square.

So yes, you did misunderstand something.

ic. So according to you, this code can produce 8MHz @ 50% duty cycle right?

void setup()
{
  // value of OC0A goes to 9
  pinMode(9, OUTPUT);

  // OCR0A is the timer reset bit, and when it resets, toggle OC0A
  OCR0A = 1;

  TCCR0A =
    // toggle mode, toggling OC0A on TOP (1)
    // OC0A1:0 = 0b01
    bit(COM0A0) |

    // not using OC0B
    // OC0B1:0 = 0b00

    // fast PWM mode
    // setting TOP (clock resets when reaching this value) to OCR0A (1)
    // WGM02:0 = 0b111, WGM02 will be set later
    bit(WGM01) | bit(WGM00);

  TCCR0B =
    // WGM02 = 1, see above
    bit(WGM02) |

    // not using prescaling function
    // CS02:0 = 0b001
    bit(CS00);

    TCNT0 = 0;
  /* ---------------------------------- */
  Serial.begin(9600);
}

// the loop function runs over and over again until power down or reset
void loop() {
  Serial.println(TCNT0);
  delay(1000);
}