   TIFR1 = (1<<ICF1); // clear pending
   TIMSK1 = (1<<ICIE1); // and enable
   
-	USBGamepad.begin(rcChannels);  
+	USBGamepad.begin(rcChannels);  //send empty USB report
 
 #ifdef DEBUG
   timer = millis(); // start timer
 	Serial.begin(115200);
 #endif
-
+  sei(); //enable global interrupts
 }
 
 void loop(){
-  if (!triggered)
-    return;
-  pulse = counter - last;
-  last = counter;
-  if(pulse > (NEWFRAME_PULSE_WIDTH * TIMER_COUNT_DIVIDER)) {
-    chan = 0;  // new data frame detected, start again
-    USBGamepad.write(rcChannels);
+  if (!triggered) //wait for interrupt
+    return;  
+  pulse = (counter - last) / TIMER_COUNT_DIVIDER; //pulse width
+  last = counter; //store
+  if(pulse > (NEWFRAME_PULSE_WIDTH)) {
+    chan = 0;  // new data frame detected, start again    
+    if (first) { //discard first frame data because it may be incomplete 
+      first = false;
+      triggered = false;
+      return;
+    } else 
+    {
+      USBGamepad.write(rcChannels); //send usb report with channels data
+    }
   }
   else {
-    if(pulse > (MIN_PULSE_WIDTH * TIMER_COUNT_DIVIDER - THRESHOLD) 
-      && pulse < (MAX_PULSE_WIDTH * TIMER_COUNT_DIVIDER + THRESHOLD) 
-      && chan < RC_CHANNELS_COUNT) 
+    if(pulse > (MIN_PULSE_WIDTH - THRESHOLD) 
+      && pulse < (MAX_PULSE_WIDTH + THRESHOLD) 
+      && chan < RC_CHANNELS_COUNT && !first) 
     {
-      rcChannels[chan] = pulse / TIMER_COUNT_DIVIDER; //store detected value      
+      rcChannels[chan] = pulse; //store detected value      
     }
     chan++; //no value detected within expected range, move to next channel
   }

uint16_t rcChannels[RC_CHANNELS_COUNT];
uint8_t chan = 0; // current channel

void setup() {
  pinMode(PPM_CAPTURE_PIN, INPUT_PULLUP);

  // Input Capture setup
  // ICNC1: =0 Disable Input Capture Noise Canceler to prevent delay in reading

  }
  #endif
  
  triggered = false; //wait for another interrupt
}
