variable issues

I have wrote a simple program to output PWM using Timer1. The problem that I’m facing is when TIMSK1 is enabled, the variable tiltPWM doesn’t change. Why is this happenning? I’m using Arduino 0010 Alpha on P3 833MHz laptop.

//#include <avr\interrupt.h>
//#include <avr\io.h>

int rcvdBytes;
int tiltPWM = 2000; //this is the initial value
void setup()
//PB1 & PB2 are outputs. PB1/PB2 are OC1A/OC1B respectively. OC1A will control the pan PWM signal
DDRB |= 1<<DDB2 | 1<<DDB1;

//Timer1 initialization.
TCCR1A = 1<<COM1A1 | 0<<COM1A0 | 1<<COM1B1 | 0<<COM1B0 | 1<<WGM11 | 0<<WGM10; //clear OC1A/B when match and set when bottom
TCCR1B = 0<<ICNC1 | 0<<ICES1 | 1<<WGM13 | 1<<WGM12 | 0<<CS12 | 1<<CS11 | 0<<CS10; //Fast PWM, TOP = ICR1, Update OCR1 at bottom, TOV flag at top, clock / 8
OCR1A = 3000; // 1.5ms high state
OCR1B = 3000; // 1.5ms high state
ICR1 = 40000; // 20ms period
TIMSK1 |= 1<<OCIE1B | 1<<OCIE1A | 1<<TOIE1; //try comment this line and observe the tiltPWM variable

void loop()
//read from serial port
if (Serial.available() > 0)
rcvdBytes =;

tiltPWM = tiltPWM - 10; //every time it receives input from serial decrement tiltPWM by 10.
Serial.print("tiltPWM : ");

try setting it as: volatile int, since interrupts sometimes do bad things with your registers.

You're enabling interrupts but where is the interrupt routine? Maybe an unset interrupt vector defaults to zero (RESET), so the Arduino is just repeatedly resetting every time the counter generates an interrupt?