File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,14 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
147
147
148
148
TIMER_Stop ((TIMER_T * ) NU_MODBASE (timer3_modinit .modname ));
149
149
150
- int delta = (timestamp > now ) ? (timestamp - now ) : (uint32_t ) ((uint64_t ) timestamp + 0xFFFFFFFFu - now );
150
+ /**
151
+ * FIXME: Scheduled alarm may go off incorrectly due to wrap around.
152
+ * Conditions in which delta is negative:
153
+ * 1. Wrap around
154
+ * 2. Newly scheduled alarm is behind now
155
+ */
156
+ //int delta = (timestamp > now) ? (timestamp - now) : (uint32_t) ((uint64_t) timestamp + 0xFFFFFFFFu - now);
157
+ int delta = (int ) (timestamp - now );
151
158
if (delta > 0 ) {
152
159
cd_major_minor_clks = (uint64_t ) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC ;
153
160
lp_ticker_arm_cd ();
Original file line number Diff line number Diff line change @@ -146,7 +146,14 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
146
146
147
147
TIMER_Stop ((TIMER_T * ) NU_MODBASE (timer3_modinit .modname ));
148
148
149
- int delta = (timestamp > now ) ? (timestamp - now ) : (uint32_t ) ((uint64_t ) timestamp + 0xFFFFFFFFu - now );
149
+ /**
150
+ * FIXME: Scheduled alarm may go off incorrectly due to wrap around.
151
+ * Conditions in which delta is negative:
152
+ * 1. Wrap around
153
+ * 2. Newly scheduled alarm is behind now
154
+ */
155
+ //int delta = (timestamp > now) ? (timestamp - now) : (uint32_t) ((uint64_t) timestamp + 0xFFFFFFFFu - now);
156
+ int delta = (int ) (timestamp - now );
150
157
if (delta > 0 ) {
151
158
cd_major_minor_clks = (uint64_t ) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC ;
152
159
lp_ticker_arm_cd ();
You can’t perform that action at this time.
0 commit comments