Skip to content

Commit c2760be

Browse files
committed
Fix for issue #6054 - interrupts scheduled in the past.
When ticker is not driven by the 1 MHz clock and HAL driver need to perform conversion between microseconds and ticks, then the interrupt might be scheduled in the past. For details see: #6054. This patch provides fix for such case. Interrupt is fired immidiatelly when last read tick is equal to the calculated tick when interrupt should be generated.
1 parent 04f0f2b commit c2760be

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

hal/mbed_ticker_api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,14 @@ static void schedule_interrupt(const ticker_data_t *const ticker)
235235
}
236236

237237
timestamp_t match_tick = compute_tick(ticker, match_time);
238+
// The time has been checked to be future, but it could still round
239+
// to the last tick as a result of us to ticks conversion
240+
if (match_tick == queue->tick_last_read) {
241+
// Match time has already expired so fire immediately
242+
ticker->interface->fire_interrupt();
243+
return;
244+
}
245+
238246
ticker->interface->set_interrupt(match_tick);
239247
timestamp_t cur_tick = ticker->interface->read();
240248

0 commit comments

Comments
 (0)