From 72ccf0b2b51dfd33c939d3ebecdb0bf72a8cde68 Mon Sep 17 00:00:00 2001 From: mjrgh Date: Tue, 21 Mar 2017 15:51:09 -0700 Subject: [PATCH] Force events into the future --- targets/TARGET_Freescale/TARGET_KLXX/us_ticker.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/targets/TARGET_Freescale/TARGET_KLXX/us_ticker.c b/targets/TARGET_Freescale/TARGET_KLXX/us_ticker.c index c29c624552..80137b5f1b 100644 --- a/targets/TARGET_Freescale/TARGET_KLXX/us_ticker.c +++ b/targets/TARGET_Freescale/TARGET_KLXX/us_ticker.c @@ -185,13 +185,14 @@ static void lptmr_isr(void) { } void us_ticker_set_interrupt(timestamp_t timestamp) { - int delta = (int)((uint32_t)timestamp - us_ticker_read()); + uint32_t tcur = us_ticker_read(); + int delta = (int)((uint32_t)timestamp - tcur); if (delta <= 0) { - // This event was in the past: - us_ticker_irq_handler(); - return; - } - + // This event was in the past. Force it into the very near + // future instead. + timestamp = tcur + 2; + } + us_ticker_int_counter = (uint32_t)(delta >> 16); us_ticker_int_remainder = (uint16_t)(0xFFFF & delta); if (us_ticker_int_counter > 0) {