using counter to toggle LED

Hello everyone,
I am using ATMEL mega2560 to toggle LED.

On the page 156 of the datasheet there are Timer/Counter control registers http://www.atmel.com/Images/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_datasheet.pdf

so I wrote the little program

#include <avr/io.h>
#include <util/delay.h>
 
int main(void)
{
    DDRB = 0x01;
    PORTB |= 1<<PINB6;
    TCCR1B |= 1<<CS10;
    int i = 0;
    while(1)
    {
      if (TCNT1 > 10000)
      {
        i++;
        TCNT1 = 0;
        if(i > 100)
        {
          i = 0;
          PORTB ^= 1<<PINB6;
        }          
      }
      
    }
}

But LED flashes like 5 times and after that it just stops blinking.
The LED in series with 330 ohm resistor is connected to the digital pin 12 (PINB6).

(deleted)

Arduino IDE can compile this code.

(deleted)

Your code (edited to work on an uno) seems to run without problems. It blinks the led and shows no sign of stopping.

Arduino-1.6.5-r5 was used to test.

int main(void)
{
    //DDRB = 0x01;
    DDRB |= _BV( PB5 ); // PB5 (D13), built in led is output
    //PORTB |= 1<<PINB6;
    
    TCCR1B |= 1<<CS10;
    int i = 0;
    
    while(1)
    {
      if (TCNT1 > 10000)
      {
        i++;
        TCNT1 = 0;
        if(i > 100)
        {
          i = 0;
          //PORTB ^= 1<<PINB6;
          PINB |= _BV( PB5 ); // toggle PB5 (D13)
          
        }
         
      }
     
    }

}