]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
fix compare register values (need to be set one early)
authoridgay <idgay>
Mon, 7 Aug 2006 22:57:37 +0000 (22:57 +0000)
committeridgay <idgay>
Mon, 7 Aug 2006 22:57:37 +0000 (22:57 +0000)
tos/chips/atm128/timer/Atm128AlarmC.nc

index 4cbd6337fe5be502d23d63da8e39d7be073cf12f..a25aa955b7c68f3117fd1658f2225a248ce1870b 100644 (file)
@@ -96,24 +96,27 @@ implementation
        Note also that casting compared quantities to timer_size produces
        predictable comparisons (the C integer promotion rules would make it
        hard to write correct code for the possible timer_size size's) */
+    /* Note: all HplAtm128Compare.set values have one subtracted, because
+       the comparisons are continuous, but the actual interrupt is signalled
+       at the next timer clock cycle. */
     if (t0 <= now)
       {
        /* if it's in the past or the near future, fire now (i.e., test
           guardedExpires <= now in wrap-around arithmetic). */
        if (guardedExpires >= t0 && // if it wraps, it's > now
            guardedExpires <= now) 
-         call HplAtm128Compare.set(call HplAtm128Timer.get() + mindt);
+         call HplAtm128Compare.set(call HplAtm128Timer.get() + mindt - 1);
        else
-         call HplAtm128Compare.set(expires);
+         call HplAtm128Compare.set(expires - 1);
       }
     else
       {
        /* again, guardedExpires <= now in wrap-around arithmetic */
        if (guardedExpires >= t0 || // didn't wrap so < now
            guardedExpires <= now)
-         call HplAtm128Compare.set(call HplAtm128Timer.get() + mindt);
+         call HplAtm128Compare.set(call HplAtm128Timer.get() + mindt - 1);
        else
-         call HplAtm128Compare.set(expires);
+         call HplAtm128Compare.set(expires - 1);
       }
     call HplAtm128Compare.reset();
     call HplAtm128Compare.start();