Fast PWM with Arduino, the inputs outputs don't work
This line:
TIMSK = (1&lt;&lt;OCIE1A) | (1&lt;&lt;TOIE1);

enables a couple of interrupts generated by Timer 1. Whenever you
enable an interrupt source, you should make sure that the matching ISR
has been defined. Otherwise, the interrupt request is routed to
__bad_interrupt(), which by default jumps to the reset vector, thus
resetting your program.