blackbox/interrupts.c

changeset 141
467e6351986e
parent 89
4b5b4c7ba03d
--- a/blackbox/interrupts.c	Wed Jun 26 11:11:04 2013 +0200
+++ b/blackbox/interrupts.c	Wed Jun 26 11:37:23 2013 +0200
@@ -122,9 +122,9 @@
     // car0 detector
     uint16_t tmp = 0;
     car0_new = TCNT1; // get current counter
-    if (car0_old < car0_new) {
+    if ((car0 == 0) && (car0_old < car0_new)) {
         // calculate difference
-        if (car0 == 0) tmp = car0_new-car0_old;
+        tmp = car0_new-car0_old;
         if ( (tmp > 54) && (tmp < 74) ) car0 = 1;
         if ( (tmp > 118) && (tmp < 138) ) car0 = 2;
         if ( (tmp > 186) && (tmp < 206) ) car0 = 3;
@@ -139,9 +139,9 @@
     // car1 detector
     uint16_t tmp = 0;
     car1_new = TCNT1; // get current counter
-    if (car1_old < car1_new) {
+    if ((car1 == 0) && (car1_old < car1_new)) {
         // calculate difference
-        if (car1 == 0) tmp = car1_new-car1_old;
+        tmp = car1_new-car1_old;
         if ( (tmp > 54) && (tmp < 74) ) car1 = 1;
         if ( (tmp > 118) && (tmp < 138) ) car1 = 2;
         if ( (tmp > 186) && (tmp < 206) ) car1 = 3;

mercurial