if ((TIFR1 & _BV(ICF1)) == 0)
return;
- sei();
- icp = ICR1;
cli();
+ icp = ICR1;
+ sei();
rising = TCCR1B & _BV(ICES1);
/* change the edge type */
TCCR1B ^= _BV(ICES1);
- /* clear the flag */
+ /* clear the flag by writing a one */
TIFR1 = TIFR1 | _BV(ICF1);
diff = icp - icp_prev;
uint8_t i;
uint8_t t, diff;
uint8_t tmp;
+ uint8_t cnt = 10;
/* use pull-up for inputs */
PORTC |= 0x3f;
/* LED */
DDRB = 0x02;
-#if 0 /* LED debug */
- while (1) {
+ while (cnt > 0) {
+#if 1 /* disable for LED debug only */
+ cnt--;
+#endif
LED_ON();
wait_ms(100);
LED_OFF();
wait_ms(100);
}
-#endif
/* servo outputs PD2-PD7 */
DDRD = 0xfc;