From: R. Steve McKown Date: Thu, 8 Dec 2011 03:05:19 +0000 (-0700) Subject: Ensure proper behavior in timer_cwait X-Git-Tag: 1.0~41 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=rgblamp.git;a=commitdiff_plain;h=250129a53a803f2c5c1359f89f1e9a834e8c37a7 Ensure proper behavior in timer_cwait Ah, the Hi-Tech compiler's lovely interpretation of promotions. See 3.6.1, Integral Promotion. This may affect the conditional in timer_cwait(), so force a cast of the result to be sure it is correct. --- diff --git a/timer.h b/timer.h index c28ed0b..20e0c8b 100644 --- a/timer.h +++ b/timer.h @@ -44,7 +44,7 @@ #define timer_cwait(c) \ { \ unsigned t0 = TMR0; \ - while ((TMR0 - t0) <= c); \ + while ((unsigned)(TMR0 - t0) <= c); /* cast prevents integral promotion */ \ } while (0) void timer_uwait(unsigned us);